[79445] trunk/base/src/images_to_archives.tcl

jmr at macports.org jmr at macports.org
Mon Jun 13 08:53:44 PDT 2011


Revision: 79445
          http://trac.macports.org/changeset/79445
Author:   jmr at macports.org
Date:     2011-06-13 08:53:43 -0700 (Mon, 13 Jun 2011)
Log 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.

Modified Paths:
--------------
    trunk/base/src/images_to_archives.tcl

Modified: trunk/base/src/images_to_archives.tcl
===================================================================
--- trunk/base/src/images_to_archives.tcl	2011-06-13 15:18:38 UTC (rev 79444)
+++ trunk/base/src/images_to_archives.tcl	2011-06-13 15:53:43 UTC (rev 79445)
@@ -8,7 +8,11 @@
 source [file join [lindex $argv 0] macports1.0 macports_fastload.tcl]
 package require macports 1.0
 package require registry 1.0
+package require registry2 2.0
+package require Pextlib 1.0
 
+umask 022
+
 mportinit
 
 # always converting to tbz2 should be fine as both these programs are
@@ -24,6 +28,10 @@
 
 puts "This could take a while..."
 
+# list of ports we successfully create an archive of, to be used to update
+# the registry only after we know all creation attempts were successful.
+set archived_list {}
+
 foreach installed $ilist {
     set iname [lindex $installed 0]
     set iversion [lindex $installed 1]
@@ -101,6 +109,16 @@
             file delete -force ${targetdir}/tarlist ${targetdir}/error.log
         }
 
+        lappend archived_list [list $installtype $iref $location $newlocation]
+    }
+}
+
+registry::write {
+    foreach archived $archived_list {
+        set installtype [lindex $archived 0]
+        set iref [lindex $archived 1]
+        set newlocation [lindex $archived 3]
+    
         if {$installtype == "direct"} {
             # change receipt to image
             $iref installtype image
@@ -108,11 +126,17 @@
             $iref activate [$iref imagefiles]
             $iref state installed
         }
+    
+        # set the new location in the registry and delete the old dir
+        $iref location $newlocation
+    }
+}
 
-        # set the new location in the registry and delete the old dir
-        registry::property_store $iref location $newlocation
-        if {$location != "" && [file isdirectory $location]} {
-            file delete -force $location
+foreach archived $archived_list {
+    set location [lindex $archived 2]
+    if {$location != "" && [file isdirectory $location]} {
+        if {[catch {file delete -force $location} result]} {
+            ui_warn "Failed to delete ${location}: $result"
         }
     }
 }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20110613/c1d36d9c/attachment.html>


More information about the macports-changes mailing list