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
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
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
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"):
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 = "@"
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+":"