summaryrefslogtreecommitdiffstats
path: root/pym/portage/util
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2012-10-14 15:36:37 -0700
committerZac Medico <zmedico@gentoo.org>2012-10-14 15:36:37 -0700
commitef591ebe40a027a0a54f455b92c1c78578d1d736 (patch)
tree3387224e68df55265e872683a1c3c73690698796 /pym/portage/util
parent8a8eda21d80099e74f38f5456f542611238f44a1 (diff)
downloadportage-ef591ebe40a027a0a54f455b92c1c78578d1d736.tar.gz
portage-ef591ebe40a027a0a54f455b92c1c78578d1d736.tar.bz2
portage-ef591ebe40a027a0a54f455b92c1c78578d1d736.zip
display_preserved_libs: move to separate file
Diffstat (limited to 'pym/portage/util')
-rw-r--r--pym/portage/util/_dyn_libs/display_preserved_libs.py79
1 files changed, 79 insertions, 0 deletions
diff --git a/pym/portage/util/_dyn_libs/display_preserved_libs.py b/pym/portage/util/_dyn_libs/display_preserved_libs.py
new file mode 100644
index 000000000..bcb7827d1
--- /dev/null
+++ b/pym/portage/util/_dyn_libs/display_preserved_libs.py
@@ -0,0 +1,79 @@
+# Copyright 2007-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+from __future__ import print_function
+
+import logging
+
+import portage
+from portage.output import colorize
+
+def display_preserved_libs(vardb):
+
+ MAX_DISPLAY = 3
+
+ plibdata = vardb._plib_registry.getPreservedLibs()
+ linkmap = vardb._linkmap
+ consumer_map = {}
+ owners = {}
+
+ try:
+ linkmap.rebuild()
+ except portage.exception.CommandNotFound as e:
+ portage.util.writemsg_level("!!! Command Not Found: %s\n" % (e,),
+ level=logging.ERROR, noiselevel=-1)
+ else:
+ search_for_owners = set()
+ for cpv in plibdata:
+ internal_plib_keys = set(linkmap._obj_key(f) \
+ for f in plibdata[cpv])
+ for f in plibdata[cpv]:
+ if f in consumer_map:
+ continue
+ consumers = []
+ for c in linkmap.findConsumers(f):
+ # Filter out any consumers that are also preserved libs
+ # belonging to the same package as the provider.
+ if linkmap._obj_key(c) not in internal_plib_keys:
+ consumers.append(c)
+ consumers.sort()
+ consumer_map[f] = consumers
+ search_for_owners.update(consumers[:MAX_DISPLAY+1])
+
+ owners = {}
+ for f in search_for_owners:
+ owner_set = set()
+ for owner in linkmap.getOwners(f):
+ owner_dblink = vardb._dblink(owner)
+ if owner_dblink.exists():
+ owner_set.add(owner_dblink)
+ if owner_set:
+ owners[f] = owner_set
+
+ for cpv in plibdata:
+ print(colorize("WARN", ">>>") + " package: %s" % cpv)
+ samefile_map = {}
+ for f in plibdata[cpv]:
+ obj_key = linkmap._obj_key(f)
+ alt_paths = samefile_map.get(obj_key)
+ if alt_paths is None:
+ alt_paths = set()
+ samefile_map[obj_key] = alt_paths
+ alt_paths.add(f)
+
+ for alt_paths in samefile_map.values():
+ alt_paths = sorted(alt_paths)
+ for p in alt_paths:
+ print(colorize("WARN", " * ") + " - %s" % (p,))
+ f = alt_paths[0]
+ consumers = consumer_map.get(f, [])
+ for c in consumers[:MAX_DISPLAY]:
+ print(colorize("WARN", " * ") + " used by %s (%s)" % \
+ (c, ", ".join(x.mycpv for x in owners.get(c, []))))
+ if len(consumers) == MAX_DISPLAY + 1:
+ print(colorize("WARN", " * ") + " used by %s (%s)" % \
+ (consumers[MAX_DISPLAY], ", ".join(x.mycpv \
+ for x in owners.get(consumers[MAX_DISPLAY], []))))
+ elif len(consumers) > MAX_DISPLAY:
+ print(colorize("WARN", " * ") + " used by %d other files" %
+ (len(consumers) - MAX_DISPLAY))