[70518] branches/gsoc10-configfiles/base/src/registry2.0/portimage.tcl

and.damore at macports.org and.damore at macports.org
Thu Aug 12 02:39:43 PDT 2010


Revision: 70518
          http://trac.macports.org/changeset/70518
Author:   and.damore at macports.org
Date:     2010-08-12 02:39:38 -0700 (Thu, 12 Aug 2010)
Log Message:
-----------
tentaively working code, deactivate skips modified config files - using imagefiles_with_md5 as Tcl dict, removed comments, edited calls to _deactivate_contents, fixed is_config_file

Modified Paths:
--------------
    branches/gsoc10-configfiles/base/src/registry2.0/portimage.tcl

Modified: branches/gsoc10-configfiles/base/src/registry2.0/portimage.tcl
===================================================================
--- branches/gsoc10-configfiles/base/src/registry2.0/portimage.tcl	2010-08-12 09:07:37 UTC (rev 70517)
+++ branches/gsoc10-configfiles/base/src/registry2.0/portimage.tcl	2010-08-12 09:39:38 UTC (rev 70518)
@@ -270,7 +270,8 @@
             registry::check_dependents $requested $force
         }
 
-        _deactivate_contents $requested [$requested files] $force
+        _deactivate_contents $requested [$requested files] [$requested files_with_md5] $force
+
         $requested state imaged
     } else {
         set ref [registry::open_entry $name $version $revision $variants]
@@ -549,7 +550,7 @@
         } catch {*} {
             # roll back activation of this port
             if {[info exists deactivate_this]} {
-                _deactivate_contents $port $rollback_filelist yes 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
@@ -651,7 +652,7 @@
                         }
                     }} result]} {
             ui_debug "Activation failed, rolling back."
-            _deactivate_contents $name $rollback_filelist yes yes
+            _deactivate_contents $name $rollback_filelist {} yes yes
             # return backed up files to their old locations
             foreach f $backups {
                 set bakfile "${f}${baksuffix}"
@@ -693,11 +694,15 @@
     }
 }
 
-proc _deactivate_contents {port imagefiles {force 0} {rollback 0}} {
+proc _deactivate_contents {port imagefiles {imagefiles_with_md5 {}} {force 0} {rollback 0}} {
     variable use_reg2
     set files [list]
 
+    puts "GSOCDBG: \tdeactivate_contents"
     foreach file $imagefiles {
+        puts "GSOCDBG:\tfile:$file:\tmd5sum:[dict get $imagefiles_with_md5 $file]:"
+    }
+    foreach file $imagefiles {
         if { [file exists $file] || (![catch {file type $file}] && [file type $file] == "link") } {
             # Normalize the file path to avoid removing the intermediate
             # symlinks (remove the empty directories instead)
@@ -729,14 +734,27 @@
     set files [lsort -decreasing -unique $files]
 
     # Remove all elements.
+    puts "GSOCDBG:\tremoving all elements"
     if {$use_reg2 && !$rollback} {
         registry::write {
             $port deactivate $imagefiles
             foreach file $files {
-                  if {[is_config_file $file]} {
-                          puts "GSOC: $file is config file"
-                          #continue
-                      }                  
+                if { [file isfile $file] && [is_config_file $file]} {
+                        puts "GSOCDBG:\t$file is config file"
+                        if {[catch {md5 file "$file"} actual_md5] == 0} {
+                            set stored_md5 [dict get $imagefiles_with_md5 $file]
+                            puts "GSOCDBG:\t\tactual_md5:$actual_md5\tstored_md5:$stored_md5"
+                            if {![string compare -nocase \
+                                    $actual_md5 $stored_md5]} {
+                                puts "GSOCDBG:\t\tnot modified file:$file"
+                            } else {
+                                puts "GSOCDBG:\t\tmodified file:$file - PLEASE RUN port upgrade config-upgrade"
+                            }
+                            continue
+                        } else {
+                            puts "could'nt catch md5"
+                        }
+                }
                 _deactivate_file $file
             }
         }
@@ -749,7 +767,7 @@
 
 proc is_config_file {filename} {
     #replace hardcoded path with $config_path from portmain.tcl, what namespace does "option" add options to?
-    if {[string match ${::macports::prefix}/etc "$filename"]} {return 1} {return 0}
+    if {[string match ${::macports::prefix}/etc* "$filename"]} {return 1} {return 0}
 }
 
 # End of portimage namespace
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20100812/4daced2d/attachment.html>


More information about the macports-changes mailing list