Ticket #44894: patch-base-src-port1.0-portlivecheck.tcl.diff

File patch-base-src-port1.0-portlivecheck.tcl.diff, 3.4 KB (added by pixilla (Bradley Giesbrecht), 8 years ago)
  • base/src/port1.0/portlivecheck.tcl

     
    4747}
    4848
    4949# define options
    50 options livecheck.url livecheck.type livecheck.md5 livecheck.regex livecheck.name livecheck.distname livecheck.version livecheck.ignore_sslcert
     50options livecheck.url livecheck.type livecheck.md5 livecheck.regex livecheck.name livecheck.distname livecheck.version livecheck.version_display livecheck.moddate livecheck.ignore_sslcert
    5151
    5252# defaults
    5353default livecheck.url {$homepage}
     
    5757default livecheck.name default
    5858default livecheck.distname default
    5959default livecheck.version {$version}
     60default livecheck.version_display {${livecheck.version}}
     61default livecheck.moddate {[file mtime ${portpath}/Portfile]}
    6062default livecheck.ignore_sslcert yes
    6163
    6264proc portlivecheck::livecheck_main {args} {
    6365    global livecheck.url livecheck.type livecheck.md5 livecheck.regex livecheck.name livecheck.distname livecheck.version \
    64            livecheck.ignore_sslcert \
    65            homepage portpath workpath \
     66           livecheck.moddate livecheck.version_display livecheck.ignore_sslcert \
     67           homepage workpath \
    6668           master_sites name subport distfiles
    6769
    6870    set updated 0
     
    7173    set has_homepage [info exists homepage]
    7274
    7375    set tempfile [mktemp "/tmp/mports.livecheck.XXXXXXXX"]
    74     set port_moddate [file mtime ${portpath}/Portfile]
    7576
    76     ui_debug "Portfile modification date is [clock format $port_moddate]"
     77    ui_debug "Portfile modification date is [clock format ${livecheck.moddate}]"
    7778    ui_debug "Port (livecheck) version is ${livecheck.version}"
    7879
    7980    set curl_options {}
     
    211212            }
    212213        }
    213214        "moddate" {
    214             set port_moddate [file mtime ${portpath}/Portfile]
    215             if {[catch {set updated [curl isnewer ${livecheck.url} $port_moddate]} error]} {
     215            if {[catch {set updated [curl isnewer ${livecheck.url} ${livecheck.moddate}]} error]} {
    216216                ui_error "cannot check if $subport was updated ($error)"
    217217                set updated -1
    218218            } else {
     
    221221                }
    222222            }
    223223        }
     224        "moddate2" {
     225            if {[catch {set moddate [curl getmoddate ${livecheck.url} ${livecheck.moddate}]} error]} {
     226                ui_error "cannot check if $subport was updated ($error)"
     227                set updated -1
     228            } else {
     229                if {$moddate < ${livecheck.moddate}} {
     230                    ui_debug "${livecheck.url} is older than Portfile"
     231                    set updated 0
     232                } else {
     233                    set updated 1
     234                    set updated_version [clock format ${moddate}]
     235                    livecheck.version_display [clock format ${livecheck.moddate}]
     236                }
     237            }
     238        }
    224239        "none" {
    225240        }
    226241        default {
     
    232247
    233248    if {${livecheck.type} != "none"} {
    234249        if {$updated > 0} {
    235             ui_msg "$subport seems to have been updated (port version: ${livecheck.version}, new version: $updated_version)"
     250            ui_msg "$subport seems to have been updated (port version: [join ${livecheck.version_display} { }], new version: $updated_version)"
    236251        } elseif {$updated == 0} {
    237252            ui_info "$subport seems to be up to date"
    238253        }