Ticket #8571: dp_remote_archive.patch

File dp_remote_archive.patch, 3.9 KB (added by danielluke (Daniel J. Luke), 19 years ago)

Enable archive mode to pull archives from a remote machine

  • src/darwinports1.0/darwinports.tcl

    RCS file: /Volumes/src/cvs/od/proj/darwinports/base/src/darwinports1.0/darwinports.tcl,v
    retrieving revision 1.212
    diff -u -r1.212 darwinports.tcl
     
    3737
    3838namespace eval darwinports {
    3939    namespace export bootstrap_options portinterp_options open_dports ui_priorities
    40     variable bootstrap_options "portdbpath libpath binpath auto_path extra_env sources_conf prefix portdbformat portinstalltype portarchivemode portarchivepath portarchivetype portautoclean porttrace portverbose destroot_umask variants_conf rsync_server rsync_options rsync_dir startupitem_type xcodeversion xcodebuildcmd"
    41     variable portinterp_options "portdbpath portpath portbuildpath auto_path prefix portsharepath registry.path registry.format registry.installtype portarchivemode portarchivepath portarchivetype portautoclean porttrace portverbose destroot_umask rsync_server rsync_options rsync_dir startupitem_type"
     40    variable bootstrap_options "portdbpath libpath binpath auto_path extra_env sources_conf prefix portdbformat portinstalltype portarchivemode remotearchiveurl portarchivepath portarchivetype portautoclean porttrace portverbose destroot_umask variants_conf rsync_server rsync_options rsync_dir startupitem_type xcodeversion xcodebuildcmd"
     41    variable portinterp_options "portdbpath portpath portbuildpath auto_path prefix portsharepath registry.path registry.format registry.installtype portarchivemode remotearchiveurl portarchivepath portarchivetype portautoclean porttrace portverbose destroot_umask rsync_server rsync_options rsync_dir startupitem_type"
    4242    # deferred options are only computed when needed.
    4343    # they are not exported to the trace thread.
    4444    # they are not exported to the interpreter in system_options array.
     
    360360                global darwinports::portarchivemode
    361361        }
    362362
     363        if {[info exists remotearchiveurl]} {
     364                set darwinports::remotearchiveurl $remotearchiveurl
     365                global darwinports::remotearchiveurl
     366        }
     367
    363368        # Archive path, where to store/retrieve binary archive packages
    364369        if {![info exists portarchivepath]} {
    365370                set darwinports::portarchivepath [file join $portdbpath packages]
  • src/package1.0/portunarchive.tcl

    RCS file: /Volumes/src/cvs/od/proj/darwinports/base/src/package1.0/portunarchive.tcl,v
    retrieving revision 1.8
    diff -u -r1.8 portunarchive.tcl
     
    6262        global ports_force ports_source_only ports_binary_only
    6363        global portname portversion portrevision portvariants portpath
    6464        global unarchive.srcpath unarchive.type unarchive.file unarchive.path
     65        global remotearchiveurl portverbose remotearchiveurl
    6566
    6667        # Check mode in case archive called directly by user
    6768        if {[option portarchivemode] != "yes"} {
     
    108109                                if {[file exist ${unarchive.path}]} {
    109110                                        set found 1
    110111                                        break
     112                                } elseif {[string match "http://*" $remotearchiveurl]} {
     113                                        set platform [option os.platform]
     114                                        set arch [option os.arch]
     115                                        set remotefile "${remotearchiveurl}/${platform}/${arch}/${unarchive.file}"
     116                                        set fetch_options {}
     117                                        if {$portverbose == "yes"} {
     118                                                lappend fetch_options "-v"
     119                                        }
     120
     121                                        if {![catch {eval curl fetch $fetch_options {$remotefile} ${unarchive.srcpath}/${unarchive.file}.TMP} result] &&
     122                                                        ![catch {system "mv ${unarchive.srcpath}/${unarchive.file}.TMP ${unarchive.path}"}]} {
     123                                                set found 1
     124                                                break
     125                                        } else {
     126                                                ui_debug "Remote Archive fetching failed: $result"
     127                                                exec rm -f ${unarchiev.srcpath}/${unarchive.file}.TMP
     128                                        }
    111129                                } else {
    112130                                        ui_debug "No [string toupper ${unarchive.type}] archive: ${unarchive.path}"
    113131                                }