New Ticket     Tickets     Wiki     Browse Source     Timeline     Roadmap     Ticket Reports     Search

Changeset 79445


Ignore:
Timestamp:
06/13/11 08:53:43 (4 years ago)
Author:
jmr@…
Message:

images_to_archives.tcl: don't modify registry until all archives have been successfully created, and don't delete old image dirs until registry has been successfully changed. This should allow users to at least go back to 1.9 if conversion fails.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/base/src/images_to_archives.tcl

    r79444 r79445  
    99package require macports 1.0 
    1010package require registry 1.0 
     11package require registry2 2.0 
     12package require Pextlib 1.0 
     13 
     14umask 022 
    1115 
    1216mportinit 
     
    2428 
    2529puts "This could take a while..." 
     30 
     31# list of ports we successfully create an archive of, to be used to update 
     32# the registry only after we know all creation attempts were successful. 
     33set archived_list {} 
    2634 
    2735foreach installed $ilist { 
     
    102110        } 
    103111 
     112        lappend archived_list [list $installtype $iref $location $newlocation] 
     113    } 
     114} 
     115 
     116registry::write { 
     117    foreach archived $archived_list { 
     118        set installtype [lindex $archived 0] 
     119        set iref [lindex $archived 1] 
     120        set newlocation [lindex $archived 3] 
     121     
    104122        if {$installtype == "direct"} { 
    105123            # change receipt to image 
     
    109127            $iref state installed 
    110128        } 
     129     
     130        # set the new location in the registry and delete the old dir 
     131        $iref location $newlocation 
     132    } 
     133} 
    111134 
    112         # set the new location in the registry and delete the old dir 
    113         registry::property_store $iref location $newlocation 
    114         if {$location != "" && [file isdirectory $location]} { 
    115             file delete -force $location 
     135foreach archived $archived_list { 
     136    set location [lindex $archived 2] 
     137    if {$location != "" && [file isdirectory $location]} { 
     138        if {[catch {file delete -force $location} result]} { 
     139            ui_warn "Failed to delete ${location}: $result" 
    116140        } 
    117141    } 
Note: See TracChangeset for help on using the changeset viewer.