New Ticket     Wiki     Browse Source     Timeline     Roadmap     Ticket Reports     Search

Ticket #10919: portunarchive.diff

File portunarchive.diff, 2.5 KB (added by elcascador@…, 6 years ago)

portunarchive patch

  • portunarchive.tcl

    old new  
    5151default unarchive.post_args {} 
    5252 
    5353default unarchive.srcpath {${portarchivepath}} 
     54default unarchive.binhost {${portarchivebinhost}} 
    5455default unarchive.type {} 
    5556default unarchive.file {} 
    5657default unarchive.path {} 
     
    6364        global portname portversion portrevision portvariants portpath 
    6465        global unarchive.srcpath unarchive.type unarchive.file unarchive.path 
    6566 
     67        global fetch.user fetch.password fetch.use_epsv unarchive.binhost 
     68        global portverbose 
     69        set fetch_options {} 
     70        if {[string length ${fetch.user}] || [string length ${fetch.password}]} { 
     71                lappend fetch_options -u 
     72                lappend fetch_options "${fetch.user}:${fetch.password}" 
     73        } 
     74        if {${fetch.use_epsv} != "yes"} { 
     75                lappend fetch_options "--disable-epsv" 
     76        } 
     77        if {$portverbose == "yes"} { 
     78                lappend fetch_options "-v" 
     79        } 
     80 
    6681        # Check mode in case archive called directly by user 
    6782        if {[option portarchivemode] != "yes"} { 
    6883                return -code error "Archive mode is not enabled!" 
     
    8499        if {![string equal ${unarchive.srcpath} ${workpath}] && ![string equal ${unarchive.srcpath} ""]} { 
    85100                set unarchive.srcpath [file join ${unarchive.srcpath} [option os.platform] [option os.arch]] 
    86101        } 
     102        # Define achive binhost url 
     103        if {![string equal ${unarchive.binhost} ""]} { 
     104                set unarchive.binhost "${unarchive.binhost}/[option os.platform]/[option os.arch]" 
     105        } 
    87106 
    88107        # Determine if unarchive should be skipped 
    89108        set skipped 0 
     
    109128                                        set found 1 
    110129                                        break 
    111130                                } else { 
    112                                         ui_debug "No [string toupper ${unarchive.type}] archive: ${unarchive.path}" 
     131                                        # file does not exist locally, we will try to download it from the binhost 
     132                                        set effectiveURL "" 
     133                                        set file_url "${unarchive.binhost}/${unarchive.file}" 
     134                                        ui_msg "$UI_PREFIX [format [msgcat::mc "Checking binhost for %s %s_%s%s"] $portname $portversion $portrevision $portvariants]" 
     135                                        if {![catch {eval curl fetch --effective-url effectiveURL $fetch_options {$file_url} ${unarchive.srcpath}/${unarchive.file}.TMP} result] && 
     136                                                ![catch {system "mv ${unarchive.srcpath}/${unarchive.file}.TMP ${unarchive.srcpath}/${unarchive.file}"}] } { 
     137                                                set found 1 
     138                                                break 
     139                                        } else { 
     140                                                ui_debug "No [string toupper ${unarchive.type}] archive: ${unarchive.path}" 
     141                                                exec rm -f ${unarchive.srcpath}/${unarchive.file}.TMP 
     142                                        } 
    113143                                } 
    114144                        } else { 
    115145                                ui_debug "Skipping [string toupper ${unarchive.type}] archive: $errmsg"