Add UNINSTALL_IGNORE variable for bug #421659.
authorZac Medico <zmedico@gentoo.org>
Fri, 22 Jun 2012 22:33:07 +0000 (15:33 -0700)
committerZac Medico <zmedico@gentoo.org>
Fri, 22 Jun 2012 22:33:07 +0000 (15:33 -0700)
UNINSTALL_IGNORE = [space delimited list of fnmatch patterns]

This variable prevents uninstallation of files that match
specific fnmatch(3) patterns. In order to ignore file collisions
with these files at install time, the same patterns can be
added to the COLLISION_IGNORE variable.

cnf/make.globals
man/make.conf.5
pym/portage/dbapi/vartree.py
pym/portage/package/ebuild/_config/special_env_vars.py

index b1569885b994aa8e3ca415f47f730d0984f7b1a8..c35429143ee097e68f569781f8e9ac22ccfc19f6 100644 (file)
@@ -64,6 +64,7 @@ FEATURES="assume-digests binpkg-logs
 # transition from compiling python modules in live file system to compiling
 # them in src_install() function.
 COLLISION_IGNORE="/lib/modules/* *.py[co]"
+UNINSTALL_IGNORE="/lib/modules/*"
 
 # Enable preserve-libs for testing with portage versions that support it.
 # This setting is commented out for portage versions that don't support it.
index 688263709d1fab625eadf21dea7bd1d563827c2e..7d07344bde0e734d501c3fb8c896de2d0f43d00f 100644 (file)
@@ -896,6 +896,14 @@ is used to sync the local portage tree when `emerge \-\-sync` is run.
 .br
 Defaults to rsync://rsync.gentoo.org/gentoo\-portage
 .TP
+\fBUNINSTALL_IGNORE\fR = \fI[space delimited list of fnmatch patterns]\fR
+This variable prevents uninstallation of files that match
+specific \fBfnmatch\fR(3) patterns. In order to ignore file
+collisions with these files at install time, the same patterns
+can be added to the \fBCOLLISION_IGNORE\fR variable.
+.br
+Defaults to "/lib/modules/*".
+.TP
 \fBUSE\fR = \fI[space delimited list of USE items]\fR
 This variable contains options that control the build behavior of several
 packages.  More information in \fBebuild\fR(5).  Possible USE values
index b8405d48337c661eba5ad5b5540cdd8c2fa9d0e9..60bab73bac7359635ac24742ecc22bed947f1109 100644 (file)
@@ -2064,7 +2064,9 @@ class dblink(object):
 
                        #process symlinks second-to-last, directories last.
                        mydirs = set()
-                       modprotect = os.path.join(self._eroot, "lib/modules/")
+
+                       uninstall_ignore = portage.util.shlex_split(
+                               self.settings.get("UNINSTALL_IGNORE", ""))
 
                        def unlink(file_name, lstatobj):
                                if bsd_chflags:
@@ -2171,6 +2173,18 @@ class dblink(object):
                                if lstatobj is None:
                                                show_unmerge("---", unmerge_desc["!found"], file_type, obj)
                                                continue
+
+                               f_match = obj[len(eroot)-1:]
+                               ignore = False
+                               for pattern in uninstall_ignore:
+                                       if fnmatch.fnmatch(f_match, pattern):
+                                               ignore = True
+                                               break
+
+                               if ignore:
+                                       show_unmerge("---", unmerge_desc["cfgpro"], file_type, obj)
+                                       continue
+
                                # don't use EROOT, CONTENTS entries already contain EPREFIX
                                if obj.startswith(real_root):
                                        relative_path = obj[real_root_len:]
@@ -2214,18 +2228,6 @@ class dblink(object):
                                                continue
                                        elif relative_path in cfgfiledict:
                                                stale_confmem.append(relative_path)
-                               # next line includes a tweak to protect modules from being unmerged,
-                               # but we don't protect modules from being overwritten if they are
-                               # upgraded. We effectively only want one half of the config protection
-                               # functionality for /lib/modules. For portage-ng both capabilities
-                               # should be able to be independently specified.
-                               # TODO: For rebuilds, re-parent previous modules to the new
-                               # installed instance (so they are not orphans). For normal
-                               # uninstall (not rebuild/reinstall), remove the modules along
-                               # with all other files (leave no orphans).
-                               if obj.startswith(modprotect):
-                                       show_unmerge("---", unmerge_desc["cfgpro"], file_type, obj)
-                                       continue
 
                                # Don't unlink symlinks to directories here since that can
                                # remove /lib and /usr/lib symlinks.
index 4795e88bc7d43ab4c92d1cafe9f5563a40a107a5..a01c17714d17fa83117052fd3ee5a07a9d751ed2 100644 (file)
@@ -164,7 +164,7 @@ environ_filter += [
        "RESUMECOMMAND", "RESUMECOMMAND_FTP",
        "RESUMECOMMAND_HTTP", "RESUMECOMMAND_HTTPS",
        "RESUMECOMMAND_RSYNC", "RESUMECOMMAND_SFTP",
-       "SYNC", "USE_EXPAND_HIDDEN", "USE_ORDER",
+       "SYNC", "UNINSTALL_IGNORE", "USE_EXPAND_HIDDEN", "USE_ORDER",
 ]
 
 environ_filter = frozenset(environ_filter)