summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-11-24 00:24:27 +0000
committerZac Medico <zmedico@gentoo.org>2008-11-24 00:24:27 +0000
commit108cdcc017647ca4f09f7b597bb5bc2c63b02615 (patch)
tree3e2e4ecf4b388b6bb6bc9fe51835d753b8839cef /pym
parent0c1a95a6daea18b7d3ff6f31de9e9f300e8faf0b (diff)
downloadportage-108cdcc017647ca4f09f7b597bb5bc2c63b02615.tar.gz
portage-108cdcc017647ca4f09f7b597bb5bc2c63b02615.tar.bz2
portage-108cdcc017647ca4f09f7b597bb5bc2c63b02615.zip
Make emerge detect an invalid profile an bail out for anything except
--help, --info, --sync, and --version actions. When bailing out, suggest to revert back to the previous profile configuration advise the user which actions are allowed with an invalid profile. svn path=/main/trunk/; revision=12065
Diffstat (limited to 'pym')
-rw-r--r--pym/_emerge/__init__.py20
-rw-r--r--pym/portage/__init__.py2
2 files changed, 21 insertions, 1 deletions
diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py
index ceae0395b..ef2e534f4 100644
--- a/pym/_emerge/__init__.py
+++ b/pym/_emerge/__init__.py
@@ -13925,6 +13925,23 @@ def ambiguous_package_name(arg, atoms, root_config, spinner, myopts):
print "!!! The short ebuild name \"%s\" is ambiguous. Please specify" % arg
print "!!! one of the above fully-qualified ebuild names instead.\n"
+def profile_check(trees, myaction, myopts):
+ if myaction in ("info", "sync"):
+ return os.EX_OK
+ elif "--version" in myopts or "--help" in myopts:
+ return os.EX_OK
+ for root, root_trees in trees.iteritems():
+ if root_trees["root_config"].settings.profiles:
+ continue
+ msg = "If you have just changed your profile configuration, you " + \
+ "should revert back to the previous configuration. Due to " + \
+ "your current profile being invalid, allowed actions are " + \
+ "limited to --help, --info, --sync, and --version."
+ writemsg_level("".join("!!! %s\n" % l for l in textwrap.wrap(msg, 70)),
+ level=logging.ERROR, noiselevel=-1)
+ return 1
+ return os.EX_OK
+
def emerge_main():
global portage # NFC why this is necessary now - genone
portage._disable_legacy_globals()
@@ -13945,6 +13962,9 @@ def emerge_main():
os.umask(022)
settings, trees, mtimedb = load_emerge_config()
portdb = trees[settings["ROOT"]]["porttree"].dbapi
+ rval = profile_check(trees, myaction, myopts)
+ if rval != os.EX_OK:
+ return rval
if portage._global_updates(trees, mtimedb["updates"]):
mtimedb.commit()
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index e711c6b26..c12f58056 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -1220,7 +1220,7 @@ class config(object):
writemsg("!!! ParseError: %s\n" % str(e), noiselevel=-1)
del e
self.profiles = []
- if local_config:
+ if local_config and self.profiles:
custom_prof = os.path.join(
config_root, CUSTOM_PROFILE_PATH.lstrip(os.path.sep))
if os.path.exists(custom_prof):