From 13a40f3fc26f86a935139111be40380514d8f301 Mon Sep 17 00:00:00 2001 From: Marius Mauch Date: Tue, 4 Dec 2007 09:58:22 +0000 Subject: [PATCH] Fix setconfig loader to use config files instead of hardcoded fallbacks svn path=/main/trunk/; revision=8839 --- bin/emaint | 4 +-- pym/_emerge/__init__.py | 12 ++++++-- pym/portage/sets/__init__.py | 59 +++++++----------------------------- 3 files changed, 22 insertions(+), 53 deletions(-) diff --git a/bin/emaint b/bin/emaint index d9f74a225..a5d7566f2 100755 --- a/bin/emaint +++ b/bin/emaint @@ -23,8 +23,8 @@ class WorldHandler(object): self.not_installed = [] self.invalid_category = [] self.okay = [] - from portage.sets import make_default_config - setconfig = make_default_config(portage.settings, + from portage.sets import load_default_config + setconfig = load_default_config(portage.settings, portage.db[portage.settings["ROOT"]]) self._sets = setconfig.getSetsWithAliases() diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index 4af56b273..0d97e6190 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -52,7 +52,7 @@ import portage.exception from portage.data import secpass from portage.util import normalize_path as normpath from portage.util import writemsg -from portage.sets import make_default_config, SETPREFIX +from portage.sets import load_default_config, SETPREFIX from portage.sets.base import InternalPackageSet from itertools import chain, izip @@ -586,7 +586,7 @@ class RootConfig(object): self.settings = trees["vartree"].settings self.root = self.settings["ROOT"] self.setconfig = setconfig - self.sets = self.setconfig.getSetsWithAliases() + self.sets = self.setconfig.getSets() def create_world_atom(pkg_key, metadata, args_set, root_config): """Create a new atom for the world file if one does not exist. If the @@ -6687,7 +6687,7 @@ def load_emerge_config(trees=None): for root, root_trees in trees.iteritems(): settings = root_trees["vartree"].settings - setconfig = make_default_config(settings, root_trees) + setconfig = load_default_config(settings, root_trees) root_trees["root_config"] = RootConfig(root_trees, setconfig) settings = trees["/"]["vartree"].settings @@ -6913,6 +6913,12 @@ def emerge_main(): root_config = trees[settings["ROOT"]]["root_config"] setconfig = root_config.setconfig sets = root_config.sets + # emerge relies on the existance of sets with names "world" and "system" + for s in ("world", "system"): + if s not in sets: + print "emerge: incomplete set configuration, no set defined for \"%s\"" % s + print " sets defined: %s" % ", ".join(sets) + return 1 newargs = [] for a in myfiles: if a in ("system", "world"): diff --git a/pym/portage/sets/__init__.py b/pym/portage/sets/__init__.py index 30c2bff49..d92eb3130 100644 --- a/pym/portage/sets/__init__.py +++ b/pym/portage/sets/__init__.py @@ -5,10 +5,7 @@ import os from ConfigParser import SafeConfigParser, NoOptionError from portage import load_mod - -DEFAULT_SETS = ["world", "system", "everything", "security"] \ - +["package_"+x for x in ["mask", "unmask", "use", "keywords"]] -del x +from portage.const import USER_CONFIG_PATH, GLOBAL_CONFIG_PATH SETPREFIX = "@" @@ -79,65 +76,31 @@ class SetConfig(SafeConfigParser): self._parse() return self.psets - def getSetsWithAliases(self): - self._parse() - if not self.aliases: - shortnames = {} - for name in self.psets: - mysplit = name.split("/") - if len(mysplit) > 1 and mysplit[0] == "sets" and mysplit[-1] != "": - if mysplit[-1] in shortnames: - del shortnames[mysplit[-1]] - else: - shortnames[mysplit[-1]] = self.psets[name] - shortnames.update(self.psets) - self.aliases = shortnames - return self.aliases - def getSetAtoms(self, setname, ignorelist=None): - myset = self.getSetsWithAliases()[setname] + myset = self.getSets()[setname] myatoms = myset.getAtoms() if ignorelist is None: ignorelist = set() ignorelist.add(setname) for n in myset.getNonAtoms(): - if n[0] == SETPREFIX and n[1:] in self.aliases: + if n[0] == SETPREFIX and n[1:] in self.psets if n[1:] not in ignorelist: myatoms.update(self.getSetAtoms(n[1:], ignorelist=ignorelist)) return myatoms -def make_default_config(settings, trees): - sc = SetConfig([], settings, trees) - sc.add_section("security") - sc.set("security", "class", "portage.sets.security.NewAffectedSet") - - sc.add_section("system") - sc.set("system", "class", "portage.sets.profiles.PackagesSystemSet") - - sc.add_section("world") - sc.set("world", "class", "portage.sets.files.WorldSet") - - sc.add_section("everything") - sc.set("everything", "class", "portage.sets.dbapi.EverythingSet") - - sc.add_section("config") - 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("rebuild-needed") - sc.set("rebuild-needed", "class", "portage.sets.dbapi.PreservedLibraryConsumerSet") - - return sc +def load_default_config(settings, trees): + 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(settings["PORTAGE_CONFIGROOT"], + USER_CONFIG_PATH.lstrip(os.path.sep), "sets.conf")) + return SetConfig(setconfigpaths, settings, trees) # adhoc test code if __name__ == "__main__": import portage - sc = make_default_config(portage.settings, portage.db["/"]) + sc = load_default_config(portage.settings, portage.db["/"]) l, e = sc.getSets() for x in l: print x+":" -- 2.26.2