Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r12065 - in main/trunk/pym: _emerge portage
Date: Mon, 24 Nov 2008 00:24:30
Message-Id: E1L4PFc-0003cs-US@stork.gentoo.org
1 Author: zmedico
2 Date: 2008-11-24 00:24:27 +0000 (Mon, 24 Nov 2008)
3 New Revision: 12065
4
5 Modified:
6 main/trunk/pym/_emerge/__init__.py
7 main/trunk/pym/portage/__init__.py
8 Log:
9 Make emerge detect an invalid profile an bail out for anything except
10 --help, --info, --sync, and --version actions. When bailing out, suggest
11 to revert back to the previous profile configuration advise the user which
12 actions are allowed with an invalid profile.
13
14
15 Modified: main/trunk/pym/_emerge/__init__.py
16 ===================================================================
17 --- main/trunk/pym/_emerge/__init__.py 2008-11-23 23:34:33 UTC (rev 12064)
18 +++ main/trunk/pym/_emerge/__init__.py 2008-11-24 00:24:27 UTC (rev 12065)
19 @@ -13925,6 +13925,23 @@
20 print "!!! The short ebuild name \"%s\" is ambiguous. Please specify" % arg
21 print "!!! one of the above fully-qualified ebuild names instead.\n"
22
23 +def profile_check(trees, myaction, myopts):
24 + if myaction in ("info", "sync"):
25 + return os.EX_OK
26 + elif "--version" in myopts or "--help" in myopts:
27 + return os.EX_OK
28 + for root, root_trees in trees.iteritems():
29 + if root_trees["root_config"].settings.profiles:
30 + continue
31 + msg = "If you have just changed your profile configuration, you " + \
32 + "should revert back to the previous configuration. Due to " + \
33 + "your current profile being invalid, allowed actions are " + \
34 + "limited to --help, --info, --sync, and --version."
35 + writemsg_level("".join("!!! %s\n" % l for l in textwrap.wrap(msg, 70)),
36 + level=logging.ERROR, noiselevel=-1)
37 + return 1
38 + return os.EX_OK
39 +
40 def emerge_main():
41 global portage # NFC why this is necessary now - genone
42 portage._disable_legacy_globals()
43 @@ -13945,6 +13962,9 @@
44 os.umask(022)
45 settings, trees, mtimedb = load_emerge_config()
46 portdb = trees[settings["ROOT"]]["porttree"].dbapi
47 + rval = profile_check(trees, myaction, myopts)
48 + if rval != os.EX_OK:
49 + return rval
50
51 if portage._global_updates(trees, mtimedb["updates"]):
52 mtimedb.commit()
53
54 Modified: main/trunk/pym/portage/__init__.py
55 ===================================================================
56 --- main/trunk/pym/portage/__init__.py 2008-11-23 23:34:33 UTC (rev 12064)
57 +++ main/trunk/pym/portage/__init__.py 2008-11-24 00:24:27 UTC (rev 12065)
58 @@ -1220,7 +1220,7 @@
59 writemsg("!!! ParseError: %s\n" % str(e), noiselevel=-1)
60 del e
61 self.profiles = []
62 - if local_config:
63 + if local_config and self.profiles:
64 custom_prof = os.path.join(
65 config_root, CUSTOM_PROFILE_PATH.lstrip(os.path.sep))
66 if os.path.exists(custom_prof):