Ticket #11971: multi-init.diff

File multi-init.diff, 8.6 KB (added by jmroot (Joshua Root), 16 years ago)

proposed fix

  • src/port1.0/portfetch.tcl

     
    510510# Perform a standard fetch, assembling fetch urls from
    511511# the listed url varable and associated distfile
    512512proc fetchfiles {args} {
    513         global distpath all_dist_files UI_PREFIX fetch_urls
     513        global fulldistpath all_dist_files UI_PREFIX fetch_urls
    514514        global fetch.user fetch.password fetch.use_epsv fetch.ignore_sslcert
    515515        global distfile site
    516516        global portverbose
    517517
    518         if {![file isdirectory $distpath]} {
    519                 if {[catch {file mkdir $distpath} result]} {
     518        if {![file isdirectory $fulldistpath]} {
     519                if {[catch {file mkdir $fulldistpath} result]} {
    520520                        return -code error [format [msgcat::mc "Unable to create distribution files path: %s"] $result]
    521521                }
    522522        }
     
    538538        set sorted no
    539539       
    540540        foreach {url_var distfile} $fetch_urls {
    541                 if {![file isfile $distpath/$distfile]} {
    542                         ui_info "$UI_PREFIX [format [msgcat::mc "%s doesn't seem to exist in %s"] $distfile $distpath]"
    543                         if {![file writable $distpath]} {
    544                                 return -code error [format [msgcat::mc "%s must be writable"] $distpath]
     541                if {![file isfile [file join $fulldistpath $distfile]]} {
     542                        ui_info "$UI_PREFIX [format [msgcat::mc "%s doesn't seem to exist in %s"] $distfile $fulldistpath]"
     543                        if {![file writable $fulldistpath]} {
     544                                return -code error [format [msgcat::mc "%s must be writable"] $fulldistpath]
    545545                        }
    546546                        if {!$sorted} {
    547547                            sortsites
     
    558558                                ui_msg "$UI_PREFIX [format [msgcat::mc "Attempting to fetch %s from %s"] $distfile $site]"
    559559                                set file_url [portfetch::assemble_url $site $distfile]
    560560                                set effectiveURL ""
    561                                 if {![catch {eval curl fetch --effective-url effectiveURL $fetch_options {$file_url} ${distpath}/${distfile}.TMP} result] &&
    562                                         ![catch {system "mv ${distpath}/${distfile}.TMP ${distpath}/${distfile}"}]} {
     561                                if {![catch {eval curl fetch --effective-url effectiveURL $fetch_options {$file_url} ${fulldistpath}/${distfile}.TMP} result] &&
     562                                        ![catch {system "mv ${fulldistpath}/${distfile}.TMP ${fulldistpath}/${distfile}"}]} {
    563563
    564564                                        # Special hack to check for sourceforge mirrors, which don't return a proper error code on failure
    565565                                        if {![string equal $effectiveURL $file_url] &&
     
    569569                                                # *SourceForge hackage in effect*
    570570                                                # The url seen by curl seems to have been a redirect to the sourceforge mirror page
    571571                                                ui_debug "[msgcat::mc "Fetching from sourceforge mirror failed"]"
    572                                                 exec rm -f ${distpath}/${distfile}.TMP
     572                                                exec rm -f [file join $fulldistpath ${distfile}.TMP]
    573573                                               
    574574                                                # Continue on to try the next mirror, if any
    575575                                        } else {
     
    582582
    583583                                } else {
    584584                                        ui_debug "[msgcat::mc "Fetching failed:"]: $result"
    585                                         exec rm -f ${distpath}/${distfile}.TMP
     585                                        exec rm -f [file join $fulldistpath ${distfile}.TMP]
    586586                                }
    587587                        }
    588588                        if {![info exists fetched]} {
     
    595595
    596596# Utility function to delete fetched files.
    597597proc fetch_deletefiles {args} {
    598         global distpath fetch_urls
     598        global fulldistpath fetch_urls
    599599        foreach {url_var distfile} $fetch_urls {
    600                 if {[file isfile $distpath/$distfile]} {
    601                         exec rm -f ${distpath}/${distfile}
     600                if {[file isfile [file join $fulldistpath $distfile]]} {
     601                        exec rm -f [file join $fulldistpath $distfile]
    602602                }
    603603        }
    604604}
    605605
    606606# Utility function to add files to a list of fetched files.
    607607proc fetch_addfilestomap {filemapname} {
    608         global distpath fetch_urls $filemapname
     608        global fulldistpath fetch_urls $filemapname
    609609        foreach {url_var distfile} $fetch_urls {
    610                 if {[file isfile $distpath/$distfile]} {
    611                         filemap set $filemapname $distpath/$distfile 1
     610                if {[file isfile [file join $fulldistpath $distfile]]} {
     611                        filemap set $filemapname [file join $fulldistpath $distfile] 1
    612612                }
    613613        }
    614614}
    615615
    616616# Initialize fetch target
    617617proc fetch_init {args} {
    618     global distfiles distname distpath all_dist_files dist_subdir fetch.type
     618    global distfiles distname distpath fulldistpath all_dist_files dist_subdir fetch.type
    619619   
    620     if {[info exist distpath] && [info exists dist_subdir]} {
    621         set distpath ${distpath}/${dist_subdir}
     620    if {[info exist distpath]} {
     621        if {[info exists dist_subdir]} {
     622            set fulldistpath [file join $distpath $dist_subdir]
     623        } else {
     624            set fulldistpath $distpath
     625        }
    622626    }
    623627}
    624628
  • src/package1.0/portarchive.tcl

     
    6161        global variations package.destpath workpath
    6262        global ports_force ports_source_only ports_binary_only
    6363        global portname portversion portrevision portvariants
    64         global archive.destpath archive.type archive.file archive.path
     64        global archive.destpath archive.type archive.file archive.path archive.fulldestpath
    6565
    6666        # Check mode in case archive called directly by user
    6767        if {[option portarchivemode] != "yes"} {
     
    8282
    8383        # Define archive destination directory and target filename
    8484        if {![string equal ${archive.destpath} ${workpath}] && ![string equal ${archive.destpath} ""]} {
    85                 set archive.destpath [file join ${archive.destpath} [option os.platform] [option os.arch]]
     85                set archive.fulldestpath [file join ${archive.destpath} [option os.platform] [option os.arch]]
     86        } else {
     87            set archive.fulldestpath ${archive.destpath}
    8688        }
    8789
    8890        # Determine if archive should be skipped
     
    100102                foreach archive.type [option portarchivetype] {
    101103                        if {[catch {archiveTypeIsSupported ${archive.type}} errmsg] == 0} {
    102104                                set archive.file "${portname}-${portversion}_${portrevision}${portvariants}.[option os.arch].${archive.type}"
    103                                 set archive.path "[file join ${archive.destpath} ${archive.file}]"
     105                                set archive.path "[file join ${archive.fulldestpath} ${archive.file}]"
    104106                        } else {
    105107                                ui_debug "Skipping [string toupper ${archive.type}] archive: $errmsg"
    106108                                set unsupported [expr $unsupported + 1]
     
    238240        global UI_PREFIX variations
    239241        global workpath destpath portpath ports_force
    240242        global portname portversion portrevision portvariants
    241         global archive.destpath archive.type archive.file archive.path
     243        global archive.fulldestpath archive.type archive.file archive.path
    242244
    243245        # Create archive destination path (if needed)
    244         if {![file isdirectory ${archive.destpath}]} {
    245                 system "mkdir -p ${archive.destpath}"
     246        if {![file isdirectory ${archive.fulldestpath}]} {
     247                system "mkdir -p ${archive.fulldestpath}"
    246248        }
    247249
    248250        # Copy state file into destroot for archiving
     
    317319                if {[catch {archiveTypeIsSupported ${archive.type}} errmsg] == 0} {
    318320                        # Define archive file/path
    319321                        set archive.file "${portname}-${portversion}_${portrevision}${portvariants}.[option os.arch].${archive.type}"
    320                         set archive.path "[file join ${archive.destpath} ${archive.file}]"
     322                        set archive.path "[file join ${archive.fulldestpath} ${archive.file}]"
    321323
    322324                        # Setup archive command
    323325                        archive_command_setup
  • src/package1.0/portunarchive.tcl

     
    6161        global UI_PREFIX target_state_fd variations workpath
    6262        global ports_force ports_source_only ports_binary_only
    6363        global portname portversion portrevision portvariants portpath
    64         global unarchive.srcpath unarchive.type unarchive.file unarchive.path
     64        global unarchive.srcpath unarchive.type unarchive.file unarchive.path unarchive.fullsrcpath
    6565
    6666        # Check mode in case archive called directly by user
    6767        if {[option portarchivemode] != "yes"} {
     
    8282
    8383        # Define archive directory, file, and path
    8484        if {![string equal ${unarchive.srcpath} ${workpath}] && ![string equal ${unarchive.srcpath} ""]} {
    85                 set unarchive.srcpath [file join ${unarchive.srcpath} [option os.platform] [option os.arch]]
     85                set unarchive.fullsrcpath [file join ${unarchive.srcpath} [option os.platform] [option os.arch]]
     86        } else {
     87            set unarchive.fullsrcpath ${unarchive.srcpath}
    8688        }
    8789
    8890        # Determine if unarchive should be skipped
     
    104106                foreach unarchive.type [option portarchivetype] {
    105107                        if {[catch {archiveTypeIsSupported ${unarchive.type}} errmsg] == 0} {
    106108                                set unarchive.file "${portname}-${portversion}_${portrevision}${portvariants}.[option os.arch].${unarchive.type}"
    107                                 set unarchive.path "[file join ${unarchive.srcpath} ${unarchive.file}]"
     109                                set unarchive.path "[file join ${unarchive.fullsrcpath} ${unarchive.file}]"
    108110                                if {[file exist ${unarchive.path}]} {
    109111                                        set found 1
    110112                                        break