From: Marius Mauch Date: Fri, 5 Oct 2007 19:29:17 +0000 (-0000) Subject: first version of set integration in emerge X-Git-Tag: v2.2_pre1~716 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=bb687e9ae0748118c6040bcdae8d1343a7d7c877;p=portage.git first version of set integration in emerge svn path=/main/trunk/; revision=7956 --- diff --git a/pym/emerge/__init__.py b/pym/emerge/__init__.py index efe456d3f..eb47084a1 100644 --- a/pym/emerge/__init__.py +++ b/pym/emerge/__init__.py @@ -31,7 +31,7 @@ except ImportError: import portage del os.environ["PORTAGE_LEGACY_GLOBALS"] from portage import digraph, portdbapi -from portage.const import NEWS_LIB_PATH, CACHE_PATH, PRIVATE_PATH +from portage.const import NEWS_LIB_PATH, CACHE_PATH, PRIVATE_PATH, USER_CONFIG_PATH import emerge.help import portage.xpak, commands, errno, re, socket, time, types @@ -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 InternalPackageSet +from portage.sets import InternalPackageSet, SetConfig, make_default_config from portage.sets.profiles import PackagesSystemSet as SystemSet from portage.sets.files import WorldSet @@ -6381,6 +6381,22 @@ def emerge_main(): print colorize("BAD", "\n*** emerging by path is broken and may not always work!!!\n") break + if myaction not in ["search", "metadata", "sync"]: + setconfigpaths = ["/usr/share/portage/config/sets.conf", os.path.join(settings["PORTDIR"], "sets.conf"), \ + os.path.join(os.sep, settings["PORTAGE_CONFIGROOT"], USER_CONFIG_PATH, "sets.conf")] + #setconfig = SetConfig(setconfigpaths, settings, trees[settings["ROOT"]]) + setconfig = make_default_config(settings, trees[settings["ROOT"]]) + del setconfigpaths + packagesets, setconfig_errors = setconfig.getSetsWithAliases() + for s in packagesets: + if s in myfiles: + # TODO: check if the current setname also resolves to a package name + if myaction in ["unmerge", "prune", "clean", "depclean"] and not packagesets[s].supportsOperation("unmerge"): + print "emerge: the given set %s does not support unmerge operations" % s + sys.exit(1) + myfiles.extend(packagesets[s].getAtoms()) + myfiles.remove(s) + if ("--tree" in myopts) and ("--columns" in myopts): print "emerge: can't specify both of \"--tree\" and \"--columns\"." sys.exit(1) diff --git a/pym/portage/sets/__init__.py b/pym/portage/sets/__init__.py index 746a7e7a9..c65cd8f89 100644 --- a/pym/portage/sets/__init__.py +++ b/pym/portage/sets/__init__.py @@ -174,8 +174,10 @@ class SetConfig(SafeConfigParser): self.psets = {} self.trees = trees self.settings = settings - + self._parsed = False def _parse(self): + if self._parsed: + return for sname in self.sections(): # find classname for current section, default to file based sets if not self.has_option(sname, "class"): @@ -219,11 +221,25 @@ class SetConfig(SafeConfigParser): else: self.errors.append("'%s' does not support individual set creation, section '%s' must be configured as multiset" % (classname, sname)) continue + self._parsed = True def getSets(self): self._parse() return (self.psets, self.errors) + def getSetsWithAliases(self): + self._parse() + shortnames = {} + for name in self.psets: + mysplit = name.split("/") + if len(mysplit) > 1 and mysplit[-1] != "": + if mysplit[-1] in shortnames: + del shortnames[mysplit[-1]] + else: + shortnames[mysplit[-1]] = self.psets[name] + shortnames.update(self.psets) + return (shortnames, self.errors) + def make_default_config(settings, trees): sc = SetConfig([], settings, trees) sc.add_section("security")