From 0196510c44b892d55b00668b3b311f4dff2a2f62 Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Fri, 12 Oct 2007 09:02:45 +0000 Subject: [PATCH] Merged from trunk 8043:8051 | 8044 | implement new set to group all consumers of preserved | | genone | libraries | | 8045 | Make depgraph.select_dep() reject installed packages in the | | zmedico | same cases that it used to so that a warning message is | | | properly generated in depgraph.xcreate() when a package is | | | unavailable but installed. | | 8046 | Add a set to group all consumers of missing libraries as a | | genone | simple revdep-rebuild replacement | | 8047 | Update todo list | | genone | | | 8048 | Do not use aux_get to parse the NEEDED file as we need to | | genone | distinguish spaces and newlines | | 8049 | typo fix | | genone | | | 8050 | In depgraph.select_dep(), check for existing nodes in | | zmedico | installed packages when necessary. | | 8051 | Strip the leading path separator from USER_CONFIG_PATH so | | zmedico | that os.path.join works correctly. | svn path=/main/branches/prefix/; revision=8076 --- TODO | 5 ++- pym/emerge/__init__.py | 10 ++++-- pym/portage/dbapi/vartree.py | 4 +-- pym/portage/sets/__init__.py | 9 +++-- pym/portage/sets/dbapi.py | 67 +++++++++++++++++++++++++++++++++++- 5 files changed, 86 insertions(+), 9 deletions(-) diff --git a/TODO b/TODO index ab35be793..b3123f1fe 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,7 @@ TODO for portage-2.2 release: ============================= - package set integration in emerge (genone) -- user interface for preserve-libs FEATURE (genone, fuzzyray?) +x user interface for preserve-libs FEATURE (genone, fuzzyray?) +- resolve the eselect-news situation (genone) + +(- denotes open/incomplete tasks, x denotes completed tasks) diff --git a/pym/emerge/__init__.py b/pym/emerge/__init__.py index 68490394e..ce5600794 100644 --- a/pym/emerge/__init__.py +++ b/pym/emerge/__init__.py @@ -1937,13 +1937,16 @@ class depgraph(object): existing_node = None myeb = None usepkgonly = "--usepkgonly" in self.myopts + empty = "empty" in self.myparams + selective = "selective" in self.myparams for find_existing_node in True, False: if existing_node: break for db, pkg_type, built, installed, db_keys in dbs: if existing_node: break - if installed and matched_packages: + if installed and not find_existing_node and \ + (matched_packages or empty): # We only need to select an installed package here # if there is no other choice. continue @@ -2062,6 +2065,8 @@ class depgraph(object): "empty" not in self.myparams and \ vardb.cpv_exists(cpv): break + if installed and not (selective or not myarg): + break # Metadata accessed above is cached internally by # each db in order to optimize visibility checks. # Now that all possible checks visibility checks @@ -6640,7 +6645,8 @@ def emerge_main(): setconfigpaths = [os.path.join(GLOBAL_CONFIG_PATH, "sets.conf")] setconfigpaths.append(os.path.join(settings["PORTDIR"], "sets.conf")) setconfigpaths += [os.path.join(x, "sets.conf") for x in settings["PORDIR_OVERLAY"].split()] - setconfigpaths.append(os.path.join(os.sep, settings["PORTAGE_CONFIGROOT"], USER_CONFIG_PATH, "sets.conf")) + setconfigpaths.append(os.path.join(settings["PORTAGE_CONFIGROOT"], + USER_CONFIG_PATH.lstrip(os.path.sep), "sets.conf")) #setconfig = SetConfig(setconfigpaths, settings, trees[settings["ROOT"]]) setconfig = make_default_config(settings, trees[settings["ROOT"]]) del setconfigpaths diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index 7aae8fe3c..207cca8bf 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -147,8 +147,8 @@ class LibraryPackageMap(object): """ Update the global library->consumer map for the given vdb instance. """ obj_dict = {} for cpv in self._dbapi.cpv_all(): - needed_list = self._dbapi.aux_get(cpv, ["NEEDED"])[0] - for l in needed_list.split("\n"): + needed_list = grabfile(self._dbapi.getpath(cpv, "NEEDED")) + for l in needed_list: mysplit = l.split() if len(mysplit) < 2: continue diff --git a/pym/portage/sets/__init__.py b/pym/portage/sets/__init__.py index c13c37252..dc281dea3 100644 --- a/pym/portage/sets/__init__.py +++ b/pym/portage/sets/__init__.py @@ -263,9 +263,12 @@ def make_default_config(settings, trees): sc.set("config", "class", "portage.sets.files.ConfigFileSet") sc.set("config", "multiset", "true") - sc.add_section("user_sets") - sc.set("user_sets", "class", "portage.sets.files.StaticFileSet") - sc.set("user_sets", "multiset", "true") + sc.add_section("user-sets") + sc.set("user-sets", "class", "portage.sets.files.StaticFileSet") + sc.set("user-sets", "multiset", "true") + + sc.add_section("rebuild-needed") + sc.set("rebuild-needed", "class", "portage.sets.dbapi.MissingLibraryConsumerSet") return sc diff --git a/pym/portage/sets/dbapi.py b/pym/portage/sets/dbapi.py index 164027943..fbff27054 100644 --- a/pym/portage/sets/dbapi.py +++ b/pym/portage/sets/dbapi.py @@ -2,8 +2,12 @@ # Distributed under the terms of the GNU General Public License v2 # $Id$ -from portage.versions import catsplit +from portage.versions import catsplit, catpkgsplit from portage.sets import PackageSet, SetConfigError +from portage.dbapi.vartree import dblink +from portage.util import grabfile + +import os __all__ = ["CategorySet", "EverythingSet"] @@ -105,3 +109,64 @@ class CategorySet(PackageSet): rValue[myname] = myset return rValue multiBuilder = classmethod(multiBuilder) + +class LibraryConsumerSet(PackageSet): + _operations = ["merge", "unmerge"] + + def __init__(self, vardbapi): + super(LibraryConsumerSet, self).__init__() + self.dbapi = vardbapi + + def mapPathsToAtoms(self, paths): + rValue = set() + for cpv in self.dbapi.cpv_all(): + mysplit = catsplit(cpv) + link = dblink(mysplit[0], mysplit[1], myroot=self.dbapi.root, \ + mysettings=self.dbapi.settings, treetype='vartree', \ + vartree=self.dbapi.vartree) + if paths.intersection(link.getcontents().keys()): + rValue.add("/".join(catpkgsplit(cpv)[:2])) + return rValue + + +class PreservedLibraryConsumerSet(LibraryConsumerSet): + def load(self): + reg = self.dbapi.plib_registry + libmap = self.dbapi.libmap.get() + consumers = set() + if reg: + for libs in reg.getPreservedLibs().values(): + for lib in libs: + paths = libmap.get(os.path.basename(lib), []) + consumers.update(paths) + else: + return + if not consumers: + return + self._setAtoms(self.mapPathsToAtoms(consumers)) + + def singleBuilder(cls, options, settings, trees): + return PreservedLibraryConsumerSet(trees["vartree"].dbapi) + singleBuilder = classmethod(singleBuilder) + +class MissingLibraryConsumerSet(LibraryConsumerSet): + _operations = ["merge", "unmerge"] + + def load(self): + atoms = set() + consumers = set() + for lib in self.dbapi.libmap.get(): + found=False + for searchdir in grabfile(os.path.join(os.sep, self.dbapi.root, "etc/ld.so.conf")): + if os.path.exists(os.path.join(searchdir, lib)): + found=True + break + if not found: + consumers.update(self.dbapi.libmap.get()[lib]) + if not consumers: + return + self._setAtoms(self.mapPathsToAtoms(consumers)) + + def singleBuilder(cls, options, settings, trees): + return MissingLibraryConsumerSet(trees["vartree"].dbapi) + singleBuilder = classmethod(singleBuilder) -- 2.26.2