Add FEATURES=config-protect-if-modified support.
authorZac Medico <zmedico@gentoo.org>
Sat, 24 Dec 2011 11:17:26 +0000 (03:17 -0800)
committerZac Medico <zmedico@gentoo.org>
Sat, 24 Dec 2011 11:17:26 +0000 (03:17 -0800)
This causes the CONFIG_PROTECT behavior to be skipped for files
that have not been modified since they were installed.

man/make.conf.5
pym/portage/const.py
pym/portage/dbapi/vartree.py

index 8a66c211164a1121936e034a8f8d74c385992596..33f4e455ccb6c24f7d6b4e37f5418d2958b4836b 100644 (file)
@@ -260,6 +260,10 @@ Log file names have an extension that is appropriate for the compression
 type. Currently, only \fBgzip\fR(1) compression is supported, so build
 logs will have a '.gz' extension when this feature is enabled.
 .TP
+.B config\-protect\-if\-modified
+This causes the \fBCONFIG_PROTECT\fR behavior to be skipped for files
+that have not been modified since they were installed.
+.TP
 .B digest
 Autogenerate digests for packages when running the
 \fBemerge\fR(1), \fBebuild\fR(1), or \fBrepoman\fR(1) commands. If
index 77c68eb0dbe65496e348118ed0b80cebae94a836..5fcb24f7379d52406706ba73ded42535d6ce8eea 100644 (file)
@@ -89,6 +89,7 @@ SUPPORTED_FEATURES       = frozenset([
                            "assume-digests", "binpkg-logs", "buildpkg", "buildsyspkg", "candy",
                            "ccache", "chflags", "clean-logs",
                            "collision-protect", "compress-build-logs",
+                           "config-protect-if-modified",
                            "digest", "distcc", "distcc-pump", "distlocks", "ebuild-locks", "fakeroot",
                            "fail-clean", "force-mirror", "force-prefix", "getbinpkg",
                            "installsources", "keeptemp", "keepwork", "fixlafiles", "lmirror",
index b9ef58341487264f37314a467f8abcd21f20ae25..a66316ba1ef956875e5633e1193828fc4b085ce1 100644 (file)
@@ -4056,6 +4056,10 @@ class dblink(object):
                destroot = normalize_path(destroot).rstrip(sep) + sep
                calc_prelink = "prelink-checksums" in self.settings.features
 
+               protect_if_modified = \
+                       "config-protect-if-modified" in self.settings.features and \
+                       self._installed_instance is not None
+
                # this is supposed to merge a list of files.  There will be 2 forms of argument passing.
                if isinstance(stufftomerge, basestring):
                        #A directory is specified.  Figure out protection paths, listdir() it and process it.
@@ -4296,10 +4300,19 @@ class dblink(object):
                                                # or by a symlink to an existing regular file;
                                                # now, config file management may come into play.
                                                # we only need to tweak mydest if cfg file management is in play.
+                                               if protected:
+                                                       destmd5 = perform_md5(mydest, calc_prelink=calc_prelink)
+                                                       if protect_if_modified:
+                                                               contents_key = \
+                                                                       self._installed_instance._match_contents(myrealdest)
+                                                               if contents_key:
+                                                                       inst_info = self._installed_instance.getcontents()[contents_key]
+                                                                       if inst_info[0] == "obj" and inst_info[2] == destmd5:
+                                                                               protected = False
+
                                                if protected:
                                                        # we have a protection path; enable config file management.
                                                        cfgprot = 0
-                                                       destmd5 = perform_md5(mydest, calc_prelink=calc_prelink)
                                                        if mymd5 == destmd5:
                                                                #file already in place; simply update mtimes of destination
                                                                moveme = 1