(Previous version left ROOT from .../etc/make.conf unnormalized)
If PORTAGE_CONFIGROOT is not /, this is likely to mean that we're not
intended to be working on the live system (and, in fact, are probably
making stuff that's incompatible with the live system). The user probably
wants to use ROOT, but we ought to let the make.conf in the
PORTAGE_CONFIGROOT set ROOT, so there's only one variable that the user
needs to keep straight.
Also normalize and check ROOT after reading the config file and getting
this option.
Still doesn't let environment variable (or, in general, callers of
create_trees) override the config file.
Signed-off-by: Daniel Barkalow [EMAIL PROTECTED]
Index: pym/portage.py
===
--- pym/portage.py (revision 5054)
+++ pym/portage.py (working copy)
@@ -833,6 +833,12 @@
if not test or (str(test.__class__) != 'portage.config'):
raise TypeError, Invalid type for config object: %s %
test.__class__
+def check_var_directory(varname, var):
+ if not os.path.isdir(var):
+ writemsg(!!! Error: %s='%s' is not a directory. Please correct
this.\n % (var, varname),
+ noiselevel=-1)
+ raise portage_exception.DirectoryNotFound(var)
+
class config:
def __init__(self, clone=None, mycpv=None, config_profile_path=None,
config_incrementals=None, config_root=/, target_root=/,
@@ -929,12 +935,7 @@
target_root = \
normalize_path(target_root).rstrip(os.path.sep)
+ os.path.sep
- for k, v in ((PORTAGE_CONFIGROOT, config_root),
- (ROOT, target_root)):
- if not os.path.isdir(v):
- writemsg(!!! Error: %s='%s' is not a
directory. Please correct this.\n % (k, v),
- noiselevel=-1)
- raise
portage_exception.DirectoryNotFound(v)
+ check_var_directory(PORTAGE_CONFIGROOT, config_root)
self.depcachedir = DEPCACHE_PATH
@@ -1128,7 +1129,9 @@
noiselevel=-1)
sys.exit(1)
-
+ if config_root != / and ROOT in self.mygcfg:
+ target_root = self.mygcfg[ROOT]
+
self.configlist.append(self.mygcfg)
self.configdict[conf]=self.configlist[-1]
@@ -1179,6 +1182,12 @@
self[PORTAGE_CONFIGROOT] = config_root
self.backup_changes(PORTAGE_CONFIGROOT)
+
+ target_root = \
+ normalize_path(target_root).rstrip(os.path.sep)
+ os.path.sep
+
+ check_var_directory(ROOT, target_root)
+
self[ROOT] = target_root
self.backup_changes(ROOT)
--
gentoo-portage-dev@gentoo.org mailing list