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
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
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)
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"):
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")