Skip to content
Permalink
Browse files

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

git-svn-id: https://svn.macports.org/repository/macports/trunk/base@18724 d073be05-634f-4543-b044-5fe20cf6d1d6
  • Loading branch information
pguyot committed Jul 25, 2006
1 parent 120dd12 commit b4ed6460bcafae971a0a90a24cb8737f2077e485
Showing with 25 additions and 9 deletions.
  1. +2 −0 doc/portfile.7
  2. +23 −9 src/port1.0/portlivecheck.tcl
@@ -907,6 +907,8 @@ Can be
(uses the modification date of some URL resource),
.Em regex
(retrieve the version by applying a regex to some URL resource),
.Em regexm
(retrieve the version by applying a multi-line regex to some URL resource),
.Em md5
(compares the md5 sum of some URL resource) or
.Em none
@@ -1,7 +1,7 @@
# et:ts=4
# portlivecheck.tcl
#
# $Id: portlivecheck.tcl,v 1.7 2006/04/17 21:49:19 pguyot Exp $
# $Id: portlivecheck.tcl,v 1.8 2006/07/25 08:05:26 pguyot Exp $
#
# Copyright (c) 2005-2006 Paul Guyot <pguyot@kallisys.net>,
# All rights reserved.
@@ -78,27 +78,41 @@ proc livecheck_main {args} {
}

switch ${livecheck.check} {
"regex" {
"regex" -
"regexm" {
# single and multiline regex
if {[catch {curl fetch ${livecheck.url} $tempfile} error]} {
ui_error "cannot check if $portname was updated ($error)"
} else {
# let's extract the version from the file.
set chan [open $tempfile "r"]
set updated -1
while {1} {
if {[gets $chan line] < 0} {
break
}
set the_re [eval "concat ${livecheck.regex}"]
if {[regexp $the_re $line line updated_version]} {
set the_re [eval "concat ${livecheck.regex}"]
if {${livecheck.check} == "regexm"} {
set data [read $chan]
if {[regexp $the_re $data data updated_version]} {
if {$updated_version != ${livecheck.version}} {
set updated 1
} else {
set updated 0
}
break
}
} else {
while {1} {
if {[gets $chan line] < 0} {
break
}
if {[regexp $the_re $line line updated_version]} {
if {$updated_version != ${livecheck.version}} {
set updated 1
} else {
set updated 0
}
break
}
}
}
close $chan
if {$updated < 0} {
ui_error "cannot check if $portname was updated (regex didn't match)"
}

0 comments on commit b4ed646

Please sign in to comment.
You can’t perform that action at this time.