Projects
New Ticket     Wiki     Browse Source     Timeline     Roadmap     Bug Reports     Search

Changeset 36679

Show
Ignore:
Timestamp:
2008-05-11 01:18:24 (6 months ago)
Author:
jmr@…
Message:

fetch_init, archive_init, unarchive_init:
Avoid creating too many subdirectory levels when these procedures are called
more than once. Fix for #11971.

Location:
trunk/base/src
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/base/src/package1.0/portarchive.tcl

    r30320 r36679  
    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 
     
    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 
     
    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" 
     
    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 
     
    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 
  • trunk/base/src/package1.0/portunarchive.tcl

    r30307 r36679  
    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 
     
    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 
     
    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 
  • trunk/base/src/port1.0/portfetch.tcl

    r35808 r36679  
    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                } 
     
    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} { 
     
    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 
     
    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 
     
    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                        } 
     
    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        } 
     
    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        } 
     
    616616# Initialize fetch target 
    617617proc fetch_init {args} { 
    618     global distfiles distname distpath all_dist_files dist_subdir fetch.type 
    619      
    620     if {[info exist distpath] && [info exists dist_subdir]} { 
    621         set distpath ${distpath}/${dist_subdir} 
     618    global distfiles distname distpath fulldistpath all_dist_files dist_subdir fetch.type 
     619     
     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}