Revision: 67096 http://trac.macports.org/changeset/67096 Author: jmr@macports.org Date: 2010-04-28 19:54:14 -0700 (Wed, 28 Apr 2010) Log Message: ----------- roll back the right set of files when activation fails Modified Paths: -------------- trunk/base/src/registry2.0/portimage.tcl Modified: trunk/base/src/registry2.0/portimage.tcl =================================================================== --- trunk/base/src/registry2.0/portimage.tcl 2010-04-29 00:47:49 UTC (rev 67095) +++ trunk/base/src/registry2.0/portimage.tcl 2010-04-29 02:54:14 UTC (rev 67096) @@ -267,7 +267,7 @@ registry::check_dependents $requested $force } - _deactivate_contents $requested {} $force + _deactivate_contents $requested [$requested files] $force $requested state imaged } else { set ref [registry::open_entry $name $version $revision $variants] @@ -521,6 +521,7 @@ # We don't have to do this as mentioned above, but it makes the # debug output of activate make more sense. set theList [lsort -increasing -unique $files] + set rollback_filelist {} registry::write { # Activate it, and catch errors so we can roll-back @@ -528,6 +529,7 @@ $port activate $imagefiles foreach file $theList { _activate_file "${imagedir}${file}" $file + lappend rollback_filelist $file } } catch {*} { ui_debug "Activation failed, rolling back." @@ -539,7 +541,7 @@ } catch {*} { # roll back activation of this port if {[info exists deactivate_this]} { - _deactivate_contents $port {} yes + _deactivate_contents $port $rollback_filelist yes yes } # if any errors occurred, move backed-up files back to their original # locations, then rethrow the error. Transaction rollback will take care @@ -632,13 +634,15 @@ # We don't have to do this as mentioned above, but it makes the # debug output of activate make more sense. set theList [lsort -increasing -unique $files] + set rollback_filelist {} # Activate it, and catch errors so we can roll-back if { [catch { foreach file $theList { _activate_file "${imagedir}${file}" $file + lappend rollback_filelist $file }} result]} { ui_debug "Activation failed, rolling back." - _deactivate_contents $name $imagefiles + _deactivate_contents $name $rollback_filelist yes yes # return backed up files to their old locations foreach f $backups { set bakfile "${f}${baksuffix}" @@ -680,12 +684,9 @@ } } -proc _deactivate_contents {port imagefiles {force 0}} { +proc _deactivate_contents {port imagefiles {force 0} {rollback 0}} { variable use_reg2 set files [list] - if {$use_reg2} { - set imagefiles [$port files] - } foreach file $imagefiles { if { [file exists $file] || (![catch {file type $file}] && [file type $file] == "link") } { @@ -719,7 +720,7 @@ set theList [lsort -decreasing -unique $files] # Remove all elements. - if {$use_reg2} { + if {$use_reg2 && !$rollback} { registry::write { $port deactivate $imagefiles foreach file $theList {