From d63fc90d72cae46824239af0f1e5158f0d029ee0 Mon Sep 17 00:00:00 2001 From: Marius Mauch Date: Mon, 3 Dec 2007 19:09:20 +0000 Subject: [PATCH] implement the final part of FEATURES=preserved-libs and remove previously preserved libs that don't have any consumers left. Also fix the notice if preserved libs are found to use the preserved-rebuild package set instead of revdep-rebuild. svn path=/main/trunk/; revision=8821 --- bin/repoman | 1 + cnf/sets.conf | 5 +++++ pym/_emerge/__init__.py | 2 +- pym/portage/dbapi/vartree.py | 40 ++++++++++++++++++++++++++++++++++-- pym/portage/sets/__init__.py | 2 +- 5 files changed, 46 insertions(+), 4 deletions(-) diff --git a/bin/repoman b/bin/repoman index f6ab04dc9..e404a9159 100755 --- a/bin/repoman +++ b/bin/repoman @@ -313,6 +313,7 @@ qawarnings=[ "IUSE.invalid", "KEYWORDS.stupid", "KEYWORDS.missing", +"LICENSE.missing", "RESTRICT.invalid", "ebuild.minorsyn", "ebuild.badheader", diff --git a/cnf/sets.conf b/cnf/sets.conf index 8f7852b85..7b3f4e9b1 100644 --- a/cnf/sets.conf +++ b/cnf/sets.conf @@ -32,3 +32,8 @@ class = portage.sets.dbapi.EverythingSet class = portage.sets.files.StaticFileSet multiset = true directory = /etc/portage/sets + +# Set to rebuild all packages that need a preserved lib that only remains due +# to FEATURES=preserved-libs +[preserved-rebuild] +class = portage.sets.dbapi.PreservedConsumerSet diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index 559a0c685..4af56b273 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -5068,7 +5068,7 @@ def post_emerge(trees, mtimedb, retval): print colorize("WARN", ">>>") + " package: %s" % cpv for f in plibdata[cpv]: print colorize("WARN", " * ") + " - %s" % f - print "Use " + colorize("GOOD", "revdep-rebuild") + " to rebuild packages using these libraries" + print "Use " + colorize("GOOD", "emerge @preserved-rebuild") + " to rebuild packages using these libraries" print "and then remerge the packages listed above." sys.exit(retval) diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index cc34a133a..d75029dc6 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -1125,7 +1125,8 @@ class dblink(object): self._unmerge_pkgfiles(pkgfiles, others_in_slot) # Remove the registration of preserved libs for this pkg instance - self.vartree.dbapi.plib_registry.unregister(self.mycpv, self.settings["SLOT"], self.settings["COUNTER"]) + plib_registry = self.vartree.dbapi.plib_registry + plib_registry.unregister(self.mycpv, self.settings["SLOT"], self.settings["COUNTER"]) if myebuildpath: ebuild_phase = "postrm" @@ -1140,7 +1141,42 @@ class dblink(object): # regenerate reverse NEEDED map self.vartree.dbapi.libmap.update() - + + # remove preserved libraries that don't have any consumers left + # FIXME: this code is quite ugly and can likely be optimized in several ways + plib_dict = plib_registry.getPreservedLibs() + for cpv in plib_dict: + keeplist = [] + plib_dict[cpv].sort() + for f in plib_dict[cpv]: + if not os.path.exists(f) or os.path.realpath(f) in keeplist: + continue + unlink_list = [] + while os.path.islink(f): + if os.path.basename(f) in self.vartree.dbapi.libmap.get(): + unlink_list = [] + keeplist.append(os.path.realpath(f)) + break + else: + unlink_list.append(f) + f = os.readlink(f) + if not os.path.islink(f) and not os.path.basename(f) in self.vartree.dbapi.libmap.get(): + unlink_list.append(f) + for obj in unlink_list: + try: + if os.path.islink(f): + obj_type = "sym" + else: + obj_type = "obj" + writemsg_stdout("<<< !needed %s %s\n" % (obj_type, obj)) + os.unlink(obj) + except OSError, e: + if e.errno == errno.ENOENT: + pass + else: + raise e + plib_registry.pruneNonExisting() + finally: if builddir_lock: try: diff --git a/pym/portage/sets/__init__.py b/pym/portage/sets/__init__.py index 940aa1020..30c2bff49 100644 --- a/pym/portage/sets/__init__.py +++ b/pym/portage/sets/__init__.py @@ -130,7 +130,7 @@ def make_default_config(settings, trees): sc.set("user-sets", "multiset", "true") sc.add_section("rebuild-needed") - sc.set("rebuild-needed", "class", "portage.sets.dbapi.MissingLibraryConsumerSet") + sc.set("rebuild-needed", "class", "portage.sets.dbapi.PreservedLibraryConsumerSet") return sc -- 2.26.2