Add support for frozen config files for which updates are automatically zapped. ...
authorZac Medico <zmedico@gentoo.org>
Tue, 31 Oct 2006 13:45:19 +0000 (13:45 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 31 Oct 2006 13:45:19 +0000 (13:45 -0000)
svn path=/main/trunk/; revision=4887

bin/dispatch-conf
cnf/dispatch-conf.conf

index 2309b680fe18a6df751cf8b02996bdebc74b007f..c9f3655f01f289943ab2773a4d5aaac0912830ca 100755 (executable)
@@ -12,6 +12,9 @@
 #  dialog menus
 #
 
+if not hasattr(__builtins__, "set"):
+       from sets import Set as set
+
 from stat import *
 from random import *
 import atexit, commands, os, re, shutil, stat, string, sys
@@ -105,6 +108,10 @@ class dispatch:
                     return False
 
 
+        # config file freezing support
+        frozen_files = set(self.options.get("frozen-files", "").split())
+        auto_zapped = []
+
         #
         # Remove new configs identical to current
         #                  and
@@ -148,6 +155,18 @@ class dispatch:
                 if os.path.exists(mrgconf):
                     os.unlink(mrgconf)
                 return False
+            elif conf['current'] in frozen_files:
+                """Frozen files are automatically zapped. The new config has
+                already been archived with a .new suffix.  When zapped, it is
+                left with the .new suffix (post_process is skipped), since it
+                hasn't been merged into the current config."""
+                auto_zapped.append(conf['current'])
+                os.unlink(conf['new'])
+                try:
+                    os.unlink(mrgconf)
+                except OSError:
+                    pass
+                return False
             elif unmodified or same_cvs or same_wsc or conf ['dir'] in portage.settings ['CONFIG_PROTECT_MASK'].split ():
                 self.replace(newconf, conf['current'])
                 self.post_process(conf['current'])
@@ -238,6 +257,13 @@ class dispatch:
                 else:
                     continue
 
+        if auto_zapped:
+            print
+            print " One or more updates are frozen and have been automatically zapped:"
+            print
+            for frozen in auto_zapped:
+                print "  * '%s'" % frozen
+            print
 
     def replace (self, newconf, curconf):
         """Replace current config with the new/merged version.  Also logs
index 11123b2a8a299675996b10674867a5df35ee9ab2..b1ece73bb5f1eb13561fa19037c07705a71e5bb8 100644 (file)
@@ -34,3 +34,6 @@ replace-unmodified=no
 
 # Per-session log file of changes made to configuration files
 #log-file=/var/log/dispatch-conf.log
+
+# List of frozen files for which dispatch-conf will automatically zap updates
+#frozen-files=""