summaryrefslogtreecommitdiff
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-10-18 04:04:45 +0000
committerZac Medico <zmedico@gentoo.org>2009-10-18 04:04:45 +0000
commit0816e0db36fbc5898278a34bf2249975bc99da30 (patch)
tree531ffef78d1d2d35d246fa9df132b39cb9c1f70b /pym
parentBug #227225 - Add *DEPEND.badtilde warning for ~ operator used with non-zero (diff)
downloadportage-multirepo-0816e0db36fbc5898278a34bf2249975bc99da30.tar.gz
portage-multirepo-0816e0db36fbc5898278a34bf2249975bc99da30.tar.bz2
portage-multirepo-0816e0db36fbc5898278a34bf2249975bc99da30.zip
Automatically create a fallback setconfig, so emerge isn't crippled due to
misssing/corrupt/outdated sets.conf. This is especially important since WorldSet has been renamed to WorldSelectedSet, and thus new and old sets.conf files are incompatible. (trunk r14630) svn path=/main/branches/2.1.7/; revision=14658
Diffstat (limited to 'pym')
-rw-r--r--pym/_emerge/main.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index 10e605e5..5007ecfe 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -778,6 +778,55 @@ def ionice(settings):
out.eerror("PORTAGE_IONICE_COMMAND returned %d" % (rval,))
out.eerror("See the make.conf(5) man page for PORTAGE_IONICE_COMMAND usage instructions.")
+def setconfig_fallback(root_config):
+ from portage._sets.base import DummyPackageSet
+ from portage._sets.files import WorldSelectedSet
+ from portage._sets.profiles import PackagesSystemSet
+ setconfig = root_config.setconfig
+ setconfig.psets['world'] = DummyPackageSet(atoms=['@selected', '@system'])
+ setconfig.psets['selected'] = WorldSelectedSet(root_config.root)
+ setconfig.psets['system'] = \
+ PackagesSystemSet(root_config.settings.profiles)
+ root_config.sets = setconfig.getSets()
+
+def get_missing_sets(root_config):
+ # emerge requires existence of "world", "selected", and "system"
+ missing_sets = []
+
+ for s in ("selected", "system", "world",):
+ if s not in root_config.sets:
+ missing_sets.append(s)
+
+ return missing_sets
+
+def missing_sets_warning(root_config, missing_sets):
+ if len(missing_sets) > 2:
+ missing_sets_str = ", ".join('"%s"' % s for s in missing_sets[:-1])
+ missing_sets_str += ', and "%s"' % missing_sets[-1]
+ elif len(missing_sets) == 2:
+ missing_sets_str = '"%s" and "%s"' % tuple(missing_sets)
+ else:
+ missing_sets_str = '"%s"' % missing_sets[-1]
+ msg = ["emerge: incomplete set configuration, " + \
+ "missing set(s): %s" % missing_sets_str]
+ if root_config.sets:
+ msg.append(" sets defined: %s" % ", ".join(root_config.sets))
+ msg.append(" This usually means that '%s'" % \
+ (os.path.join(portage.const.GLOBAL_CONFIG_PATH, "sets.conf"),))
+ msg.append(" is missing or corrupt.")
+ for line in msg:
+ writemsg_level(line + "\n", level=logging.ERROR, noiselevel=-1)
+
+def ensure_required_sets(trees):
+ warning_shown = False
+ for root_trees in trees.values():
+ missing_sets = get_missing_sets(root_trees["root_config"])
+ if missing_sets and not warning_shown:
+ warning_shown = True
+ missing_sets_warning(root_trees["root_config"], missing_sets)
+ if missing_sets:
+ setconfig_fallback(root_trees["root_config"])
+
def expand_set_arguments(myfiles, myaction, root_config):
if myaction != "search":
@@ -996,6 +1045,8 @@ def emerge_main():
root_config = trees[settings["ROOT"]]["root_config"]
+ ensure_required_sets(trees)
+
# only expand sets for actions taking package arguments
oldargs = myfiles[:]
if myaction in ("clean", "config", "depclean", "info", "prune", "unmerge", None):