1 |
(Previous version left ROOT from .../etc/make.conf unnormalized) |
2 |
|
3 |
If PORTAGE_CONFIGROOT is not "/", this is likely to mean that we're not |
4 |
intended to be working on the live system (and, in fact, are probably |
5 |
making stuff that's incompatible with the live system). The user probably |
6 |
wants to use ROOT, but we ought to let the make.conf in the |
7 |
PORTAGE_CONFIGROOT set ROOT, so there's only one variable that the user |
8 |
needs to keep straight. |
9 |
|
10 |
Also normalize and check ROOT after reading the config file and getting |
11 |
this option. |
12 |
|
13 |
Still doesn't let environment variable (or, in general, callers of |
14 |
create_trees) override the config file. |
15 |
|
16 |
Signed-off-by: Daniel Barkalow <barkalow@××××××××.org> |
17 |
|
18 |
Index: pym/portage.py |
19 |
=================================================================== |
20 |
--- pym/portage.py (revision 5054) |
21 |
+++ pym/portage.py (working copy) |
22 |
@@ -833,6 +833,12 @@ |
23 |
if not test or (str(test.__class__) != 'portage.config'): |
24 |
raise TypeError, "Invalid type for config object: %s" % test.__class__ |
25 |
|
26 |
+def check_var_directory(varname, var): |
27 |
+ if not os.path.isdir(var): |
28 |
+ writemsg("!!! Error: %s='%s' is not a directory. Please correct this.\n" % (var, varname), |
29 |
+ noiselevel=-1) |
30 |
+ raise portage_exception.DirectoryNotFound(var) |
31 |
+ |
32 |
class config: |
33 |
def __init__(self, clone=None, mycpv=None, config_profile_path=None, |
34 |
config_incrementals=None, config_root="/", target_root="/", |
35 |
@@ -929,12 +935,7 @@ |
36 |
target_root = \ |
37 |
normalize_path(target_root).rstrip(os.path.sep) + os.path.sep |
38 |
|
39 |
- for k, v in (("PORTAGE_CONFIGROOT", config_root), |
40 |
- ("ROOT", target_root)): |
41 |
- if not os.path.isdir(v): |
42 |
- writemsg("!!! Error: %s='%s' is not a directory. Please correct this.\n" % (k, v), |
43 |
- noiselevel=-1) |
44 |
- raise portage_exception.DirectoryNotFound(v) |
45 |
+ check_var_directory("PORTAGE_CONFIGROOT", config_root) |
46 |
|
47 |
self.depcachedir = DEPCACHE_PATH |
48 |
|
49 |
@@ -1128,7 +1129,9 @@ |
50 |
noiselevel=-1) |
51 |
sys.exit(1) |
52 |
|
53 |
- |
54 |
+ if config_root != "/" and "ROOT" in self.mygcfg: |
55 |
+ target_root = self.mygcfg["ROOT"] |
56 |
+ |
57 |
self.configlist.append(self.mygcfg) |
58 |
self.configdict["conf"]=self.configlist[-1] |
59 |
|
60 |
@@ -1179,6 +1182,12 @@ |
61 |
|
62 |
self["PORTAGE_CONFIGROOT"] = config_root |
63 |
self.backup_changes("PORTAGE_CONFIGROOT") |
64 |
+ |
65 |
+ target_root = \ |
66 |
+ normalize_path(target_root).rstrip(os.path.sep) + os.path.sep |
67 |
+ |
68 |
+ check_var_directory("ROOT", target_root) |
69 |
+ |
70 |
self["ROOT"] = target_root |
71 |
self.backup_changes("ROOT") |
72 |
|
73 |
|
74 |
-- |
75 |
gentoo-portage-dev@g.o mailing list |