Ticket #18889: patch-portlivecheck.tcl.2.diff

File patch-portlivecheck.tcl.2.diff, 5.8 KB (added by lperry (Perry Lee), 15 years ago)

a new version of portlivecheck.tcl that has no site-specific references

  • portlivecheck.tcl

     
    7474    ui_debug "Portfile modification date is [clock format $port_moddate]"
    7575    ui_debug "Port (livecheck) version is ${livecheck.version}"
    7676
    77     # Determine the default type depending on the mirror.
    78     if {${livecheck.check} eq "default"} {
    79         if {$has_master_sites} {
    80             foreach {master_site} ${master_sites} {
    81                 if {[regexp {^(sourceforge|freshmeat|googlecode|gnu)(?::([^:]+))?} ${master_site} _ site subdir]} {
    82                     if {${subdir} ne "" && ${livecheck.name} eq "default"} {
    83                         set livecheck.name ${subdir}
    84                     }
    85                     set livecheck.check ${site}
    86 
    87                     break
    88                 }
    89             }
    90         }
    91         if {${livecheck.check} eq "default"} {
    92             set livecheck.check "freshmeat"
    93         }
    94         if {$has_homepage} {
    95             if {[regexp {^http://code.google.com/p/([^/]+)} $homepage _ tag]} {
    96                 if {${livecheck.name} eq "default"} {
    97                     set livecheck.name $tag
    98                 }
    99                 set livecheck.check "googlecode"
    100             } elseif {[regexp {^http://www.gnu.org/software/([^/]+)} $homepage _ tag]} {
    101                 if {${livecheck.name} eq "default"} {
    102                     set livecheck.name $tag
    103                 }
    104                 set livecheck.check "gnu"
    105             }
    106         }
    107     }
    108     if {${livecheck.name} eq "default"} {
    109         set livecheck.name $name
    110     }
    111 
    11277    # Copied over from portfetch in parts
    11378    set fetch_options {}
    11479    if {[string length ${fetch.user}] || [string length ${fetch.password}]} {
     
    12287        lappend fetch_options "--ignore-ssl-cert"
    12388    }
    12489
    125     # Perform the check depending on the type.
    126     switch ${livecheck.check} {
    127         "freshmeat" {
    128             if {!$has_homepage || ${livecheck.url} eq ${homepage}} {
    129                 set livecheck.url "http://freshmeat.net/projects/${livecheck.name}/releases.atom"
     90    # Check _resources/port1.0/livecheck for available types.
     91    set types_dir [getdefaultportresourcepath "port1.0/livecheck"]
     92    if {[catch {set available_types [glob -directory $types_dir -tails -types f *.tcl]} result]} {
     93        return -code 1 "No available types were found. Check '$types_dir'."
     94    }
     95
     96    # Convert available_types from a list of files (e.g., { freshmeat.tcl
     97    # gnu.tcl ... }) into a string in the format "type|type|..." (e.g.,
     98    # "freshmeat|gnu|...").
     99    set available_types [regsub -all {\.tcl} [join $available_types |] {}]
     100
     101    if {${livecheck.check} eq "default"} {
     102        # Determine the default type depending on the mirror.
     103        if {$has_master_sites} {
     104            foreach {master_site} ${master_sites} {
     105                if {[regexp "^($available_types)(?::(\[^:\]+))?" ${master_site} _ site subdir]} {
     106                    if {${subdir} ne "" && ${livecheck.name} eq "default"} {
     107                        set livecheck.name ${subdir}
     108                    }
     109                    set livecheck.check ${site}
     110
     111                    break
     112                }
    130113            }
    131             if {${livecheck.regex} eq ""} {
    132                 set livecheck.regex [list "(?i)<title>${livecheck.name} (.*)</title>"]
    133             }
    134             set livecheck.check "regex"
    135114        }
    136         "sourceforge" {
    137             if {!$has_homepage || ${livecheck.url} eq ${homepage}} {
    138                 set livecheck.url "http://sourceforge.net/export/rss2_projfiles.php?project=${livecheck.name}"
    139             }
    140             if {${livecheck.distname} eq "default"} {
    141                 set livecheck.distname ${livecheck.name}
    142             }
    143             if {${livecheck.regex} eq ""} {
    144                 set livecheck.regex [list "<title>[quotemeta ${livecheck.distname}] (.*) released.*</title>"]
    145             }
    146             set livecheck.check "regex"
     115        # If the default type cannot be determined from the mirror, use the
     116        # fallback type (which is specified by a symlink).
     117        if {${livecheck.check} eq "default"} {
     118            set livecheck.check "fallback"
    147119        }
    148         "googlecode" {
    149             if {!$has_homepage || ${livecheck.url} eq ${homepage}} {
    150                 set livecheck.url "http://code.google.com/p/${livecheck.name}/downloads/list"
    151             }
    152             if {${livecheck.distname} eq "default"} {
    153                 set livecheck.distname [regsub ***=[quotemeta ${livecheck.version}] [quotemeta [file tail [lindex ${distfiles} 0]]] (.*)]
    154             }
    155             if {${livecheck.regex} eq ""} {
    156                 set livecheck.regex [list "<a href=\"http://[quotemeta ${livecheck.name}].googlecode.com/files/${livecheck.distname}\""]
    157             }
    158             set livecheck.check "regex"
     120
     121        # Load the defaults from _resources/port1.0/livecheck/${livecheck.check}.tcl.
     122        set defaults_file "$types_dir/${livecheck.check}.tcl"
     123        ui_debug "Loading the defaults from '$defaults_file'"
     124        if {[catch {source $defaults_file} result]} {
     125            return -code 1 "The defaults could not be loaded from '$defaults_file'."
    159126        }
    160         "gnu" {
    161             if {!$has_homepage || ${livecheck.url} eq ${homepage}} {
    162                 set livecheck.url "http://ftp.gnu.org/gnu/${livecheck.name}/?C=M&O=D"
    163             }
    164             if {${livecheck.distname} eq "default"} {
    165                 set livecheck.distname ${livecheck.name}
    166             }
    167             if {${livecheck.regex} eq ""} {
    168                 set livecheck.regex [list "[quotemeta ${livecheck.distname}]-(\\d+(?:\\.\\d+)*)"]
    169             }
    170             set livecheck.check "regex"
    171         }
    172127    }
    173128
    174129    # de-escape livecheck.url