diff options
author | Zac Medico <zmedico@gentoo.org> | 2007-06-13 07:21:59 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2007-06-13 07:21:59 +0000 |
commit | a133cb89d5279df7febcd0c8ab3890e2ccfb897a (patch) | |
tree | 331ca7ff23baf26ad5e917977dca065875b7c0e9 /pym/portage/dbapi/vartree.py | |
parent | 7e3e4f155bfe04f91de9d02689bf0b6478df3c80 (diff) | |
download | portage-a133cb89d5279df7febcd0c8ab3890e2ccfb897a.tar.gz portage-a133cb89d5279df7febcd0c8ab3890e2ccfb897a.tar.bz2 portage-a133cb89d5279df7febcd0c8ab3890e2ccfb897a.zip |
For bug #134620, add a FEATURES=unmerge-orphans option that causes unmerge to remove files more aggressively. If a file is not claimed by another package in the same slot and it is not protected by CONFIG_PROTECT, unmerge it even if the modification time or checksum differs from the file that was originally installed. This is enabled in make.globals since the vast majority of users probably want this.
svn path=/main/trunk/; revision=6829
Diffstat (limited to 'pym/portage/dbapi/vartree.py')
-rw-r--r-- | pym/portage/dbapi/vartree.py | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index 5e91adebc..e234f00f1 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -1150,6 +1150,8 @@ class dblink(object): for dblnk in others_in_slot: claimed_paths.update(dblnk.getcontents()) + unmerge_orphans = "unmerge-orphans" in self.settings.features + if pkgfiles: mykeys = pkgfiles.keys() mykeys.sort() @@ -1157,9 +1159,11 @@ class dblink(object): #process symlinks second-to-last, directories last. mydirs = [] - modprotect = "/lib/modules/" + modprotect = os.path.join(self.vartree.root, "lib/modules/") for objkey in mykeys: obj = normalize_path(objkey) + file_data = pkgfiles[objkey] + file_type = file_data[0] if obj in claimed_paths: # A new instance of this package claims the file, so don't # unmerge it. @@ -1177,7 +1181,7 @@ class dblink(object): except (OSError, AttributeError): pass islink = lstatobj is not None and stat.S_ISLNK(lstatobj.st_mode) - if statobj is None: + if not unmerge_orphans and statobj is None: if not islink: #we skip this if we're dealing with a symlink #because os.stat() will operate on the @@ -1193,6 +1197,20 @@ class dblink(object): writemsg_stdout("--- cfgpro %s %s\n" % (pkgfiles[objkey][0], obj)) continue + if unmerge_orphans and \ + lstatobj and not stat.S_ISDIR(lstatobj.st_mode) and \ + not self.isprotected(obj): + try: + # Remove permissions to ensure that any hardlinks to + # suid/sgid files are rendered harmless. + if statobj: + os.chmod(obj, 0) + os.unlink(obj) + except EnvironmentError, e: + pass + writemsg_stdout("<<< %s %s\n" % (file_type, obj)) + continue + lmtime = str(lstatobj[stat.ST_MTIME]) if (pkgfiles[objkey][0] not in ("dir", "fif", "dev")) and (lmtime != pkgfiles[objkey][1]): writemsg_stdout("--- !mtime %s %s\n" % (pkgfiles[objkey][0], obj)) |