summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-10-18 01:21:52 +0000
committerZac Medico <zmedico@gentoo.org>2009-10-18 01:21:52 +0000
commitc0d9ff7b1749726f8575a0e15b84c04100ab6ddf (patch)
treee1ba79b1bc09043bec76fc9550bc6596c46f3653
parentBug #227225 - Add *DEPEND.badtilde warning for ~ operator used with non-zero (diff)
downloadportage-multirepo-c0d9ff7b1749726f8575a0e15b84c04100ab6ddf.tar.gz
portage-multirepo-c0d9ff7b1749726f8575a0e15b84c04100ab6ddf.tar.bz2
portage-multirepo-c0d9ff7b1749726f8575a0e15b84c04100ab6ddf.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. svn path=/main/trunk/; revision=14630
-rw-r--r--pym/_emerge/main.py76
1 files changed, 51 insertions, 25 deletions
diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index ac63419c..f8a8b6b4 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -856,6 +856,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):
retval = os.EX_OK
setconfig = root_config.setconfig
@@ -917,31 +966,6 @@ def expand_set_arguments(myfiles, myaction, root_config):
for e in setconfig.errors:
print(colorize("BAD", "Error during set creation: %s" % e))
- # emerge requires existence of "world", "selected", and "system"
- required_sets = ("selected", "system", "world",)
- missing_sets = []
-
- for s in required_sets:
- if s not in sets:
- missing_sets.append(s)
- if 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 sets:
- msg.append(" sets defined: %s" % ", ".join(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)
- return (None, 1)
unmerge_actions = ("unmerge", "prune", "clean", "depclean")
for a in myfiles:
@@ -1166,6 +1190,8 @@ def emerge_main():
writemsg_stdout("".join("%s\n" % s for s in sorted(root_config.sets)))
return os.EX_OK
+ ensure_required_sets(trees)
+
# only expand sets for actions taking package arguments
oldargs = myfiles[:]
if myaction in ("clean", "config", "depclean", "info", "prune", "unmerge", None):