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
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)
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"
# 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:
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