Ticket #29592: image_to_archive.diff

File image_to_archive.diff, 2.8 KB (added by yaseppochi (Stephen J. Turnbull), 13 years ago)
  • src/images_to_archives.tcl

     
    3333set archived_list {}
    3434
    3535foreach installed $ilist {
     36    puts $installed
    3637    set iname [lindex $installed 0]
    3738    set iversion [lindex $installed 1]
    3839    set irevision [lindex $installed 2]
     
    4950        set location ""
    5051    }
    5152
     53    puts $location
     54
    5255    if {$location == "" || ![file isfile $location]} {
    5356        # no image archive present, so make one
    5457        set archs [registry::property_retrieve $iref archs]
     
    5659            set archs ${macports::os_arch}
    5760        }
    5861        # look for any existing archive in the old location
    59         set oldarchiverootname "${iname}-${iversion}_${irevision}${ivariants}.[join $archs -]"
     62        set oldarchiverootname "${iname}-${iversion}_${irevision}${ivariants}.${macports::os_platform}_${macports::os_major}.[join $archs -]"
    6063        set archivetype tbz2
    6164        set oldarchivedir [file join ${macports::portdbpath} packages ${macports::os_platform}_${macports::os_major}]
    6265        set olderarchivedir [file join ${macports::portdbpath} packages ${macports::os_platform}]
     
    6871            set olderarchivedir [file join $olderarchivedir universal]
    6972        }
    7073        set found 0
    71         foreach adir [list $oldarchivedir $olderarchivedir] {
     74        foreach adir [list [file dirname $location] $oldarchivedir $olderarchivedir] {
     75            puts $adir
    7276            foreach type {tbz2 tbz tgz tar txz tlz xar xpkg zip cpgz cpio} {
    7377                set oldarchivefullpath "[file join $adir $oldarchiverootname].${type}"
    7478                if {[file isfile $oldarchivefullpath]} {
     
    9296        set newlocation [file join $targetdir $archivename]
    9397
    9498        if {$found} {
    95             file rename $oldarchivefullpath $newlocation
     99            if {[catch {file rename $oldarchivefullpath $newlocation}]} {
     100                puts "Found $archivename (renaming failed)."
     101            }
    96102        } elseif {$installtype == "image"} {
    97             # create archive from image dir
    98             system "cd $location && $tarcmd -cjf $newlocation * > ${targetdir}/error.log 2>&1"
    99             file delete -force ${targetdir}/error.log
     103            if {! [file isfile $newlocation]} {
     104                # create archive from image dir
     105                system "cd $location && $tarcmd -cjf $newlocation * > ${targetdir}/error.log 2>&1"
     106                file delete -force ${targetdir}/error.log
     107            }
    100108        } else {
    101109            # direct mode, create archive from installed files
    102110            # we tell tar to read filenames from a file so as not to run afoul of command line length limits