Changeset 18724 for trunk/base


Ignore:
Timestamp:
Jul 25, 2006, 8:05:26 AM (18 years ago)
Author:
pguyot (Paul Guyot)
Message:

New livecheck mode: regexm (matches the whole resource).

Location:
trunk/base
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/base/doc/portfile.7

    r17563 r18724  
    908908.Em regex
    909909(retrieve the version by applying a regex to some URL resource),
     910.Em regexm
     911(retrieve the version by applying a multi-line regex to some URL resource),
    910912.Em md5
    911913(compares the md5 sum of some URL resource) or
  • trunk/base/src/port1.0/portlivecheck.tcl

    r17563 r18724  
    22# portlivecheck.tcl
    33#
    4 # $Id: portlivecheck.tcl,v 1.7 2006/04/17 21:49:19 pguyot Exp $
     4# $Id: portlivecheck.tcl,v 1.8 2006/07/25 08:05:26 pguyot Exp $
    55#
    66# Copyright (c) 2005-2006 Paul Guyot <pguyot@kallisys.net>,
     
    7979       
    8080        switch ${livecheck.check} {
    81                 "regex" {
     81                "regex" -
     82                "regexm" {
     83                        # single and multiline regex
    8284                        if {[catch {curl fetch ${livecheck.url} $tempfile} error]} {
    8385                                ui_error "cannot check if $portname was updated ($error)"
     
    8688                                set chan [open $tempfile "r"]
    8789                                set updated -1
    88                                 while {1} {
    89                                         if {[gets $chan line] < 0} {
    90                                                 break
    91                                         }
    92                                         set the_re [eval "concat ${livecheck.regex}"]
    93                                         if {[regexp $the_re $line line updated_version]} {
     90                                set the_re [eval "concat ${livecheck.regex}"]
     91                                if {${livecheck.check} == "regexm"} {
     92                                        set data [read $chan]
     93                                        if {[regexp $the_re $data data updated_version]} {
    9494                                                if {$updated_version != ${livecheck.version}} {
    9595                                                        set updated 1
     
    9797                                                        set updated 0
    9898                                                }
    99                                                 break
     99                                        }
     100                                } else {
     101                                        while {1} {
     102                                                if {[gets $chan line] < 0} {
     103                                                        break
     104                                                }
     105                                                if {[regexp $the_re $line line updated_version]} {
     106                                                        if {$updated_version != ${livecheck.version}} {
     107                                                                set updated 1
     108                                                        } else {
     109                                                                set updated 0
     110                                                        }
     111                                                        break
     112                                                }
    100113                                        }
    101114                                }
     115                                close $chan
    102116                                if {$updated < 0} {
    103117                                        ui_error "cannot check if $portname was updated (regex didn't match)"
Note: See TracChangeset for help on using the changeset viewer.