We have a most confusing situation here, which is most of all pretty
authorFabian Groffen <grobian@gentoo.org>
Wed, 16 Jul 2008 13:10:43 +0000 (13:10 -0000)
committerFabian Groffen <grobian@gentoo.org>
Wed, 16 Jul 2008 13:10:43 +0000 (13:10 -0000)
weak for protecting us from making mistakes.
First there is a config_root (PORTAGE_CONFIGROOT) which can be a path
somewhere, from which all paths need to be relative (e.g.
etc/portage), hence those constants do NOT have EPREFIX, because
config_root contains EPREFIX by default -- overriding it loses the
EPREFIX as one would expect.
Second there is target_root (ROOT) which is to install somewhere
completely else, in Prefix of limited use.  Because this is an offset
always given, the EPREFIX should always be applied in it.  Those
constants (like VDB_PATH) DO have EPREFIX.

svn path=/main/branches/prefix/; revision=11082

pym/_emerge/__init__.py
pym/portage/__init__.py
pym/portage/const.py
pym/portage/output.py
pym/portage/update.py

index c1c481597b6dfb851c1e4831f887eeb39a4be0a8..b72f3a8a0c68ba16c251205517a4825e677848d1 100644 (file)
@@ -75,7 +75,7 @@ portage.dep._dep_check_strict = True
 import portage.util
 import portage.locks
 import portage.exception
-from portage.const import EPREFIX, BPREFIX
+from portage.const import EPREFIX, BPREFIX, EPREFIX_LSTRIP
 from portage.data import secpass
 from portage.elog.messages import eerror
 from portage.util import normalize_path as normpath
@@ -10801,12 +10801,12 @@ def action_sync(settings, trees, mtimedb, myopts, myaction):
        chk_updated_cfg_files(EPREFIX, settings.get("CONFIG_PROTECT","").split())
 
        if myaction != "metadata":
-               if os.access(portage.USER_CONFIG_PATH + "/bin/post_sync", os.X_OK):
+               if os.access(portage.USER_CONFIG_PATH + EPREFIX + "/bin/post_sync", os.X_OK):
                        retval = portage.process.spawn(
-                               [os.path.join(portage.USER_CONFIG_PATH, "bin", "post_sync"),
+                               [os.path.join(portage.USER_CONFIG_PATH, EPREFIX_LSTRIP, "bin", "post_sync"),
                                dosyncuri], env=settings.environ())
                        if retval != os.EX_OK:
-                               print red(" * ")+bold("spawn failed of "+ portage.USER_CONFIG_PATH + "/bin/post_sync")
+                               print red(" * ")+bold("spawn failed of "+ portage.USER_CONFIG_PATH + EPREFIX + "/bin/post_sync")
 
        if(mybestpv != mypvs) and not "--quiet" in myopts:
                print
index 6da2e7ffd0909769a815974a73a9d78819646880..06629add02a37b2fe9f87102724c4c0d609423f7 100644 (file)
@@ -1133,7 +1133,7 @@ class config(object):
                                        raise portage.exception.DirectoryNotFound(var)
 
                        if config_root is None:
-                               config_root = "/"
+                               config_root = EPREFIX
 
                        config_root = normalize_path(os.path.abspath(
                                config_root)).rstrip(os.path.sep) + os.path.sep
@@ -7249,8 +7249,8 @@ def init_legacy_globals():
        os.umask(022)
 
        kwargs = {}
-       for k, envvar in (("config_root", "PORTAGE_CONFIGROOT"), ("target_root", "ROOT")):
-               kwargs[k] = os.environ.get(envvar, "/")
+       kwargs["config_root"] = os.environ.get("PORTAGE_CONFIGROOT", EPREFIX + "/")
+       kwargs["target_root"] = os.environ.get("ROOT", "/")
 
        global _initializing_globals
        _initializing_globals = True
index 94996dc6b7fc12a3d48d8371eb3fbaf4918477ae..8a80ffdbf48b1a4d66a3e4aa66df16423cf7ebf0 100644 (file)
@@ -21,12 +21,25 @@ if "EPREFIX" in os.environ:
 
 EPREFIX_LSTRIP          = EPREFIX.lstrip(os.path.sep)
 
+# We have a most confusing situation here, which is most of all pretty
+# weak for protecting us from making mistakes.
+# First there is a config_root (PORTAGE_CONFIGROOT) which can be a path
+# somewhere, from which all paths need to be relative (e.g.
+# etc/portage), hence those constants do NOT have EPREFIX, because
+# config_root contains EPREFIX by default -- overriding it loses the
+# EPREFIX as one would expect.
+# Second there is target_root (ROOT) which is to install somewhere
+# completely else, in Prefix of limited use.  Because this is an offset
+# always given, the EPREFIX should always be applied in it.  Those
+# constants (like VDB_PATH) DO have EPREFIX.
+# Unfortunately this file is ordered quite horrible in this respect.
+
 VDB_PATH                = EPREFIX_LSTRIP+os.path.sep+"var/db/pkg"
-PRIVATE_PATH            = EPREFIX_LSTRIP+os.path.sep+"var/lib/portage"
+PRIVATE_PATH            = "var/lib/portage"
 CACHE_PATH              = EPREFIX+"/var/cache/edb"
 DEPCACHE_PATH           = CACHE_PATH+"/dep"
 
-USER_CONFIG_PATH        = EPREFIX+"/etc/portage"
+USER_CONFIG_PATH        = "/etc/portage"
 MODULES_FILE_PATH       = USER_CONFIG_PATH+"/modules"
 CUSTOM_PROFILE_PATH     = USER_CONFIG_PATH+"/profile"
 GLOBAL_CONFIG_PATH      = DATADIR+"/portage/config"
@@ -37,7 +50,7 @@ PORTAGE_BIN_PATH        = PORTAGE_BASE_PATH+"/bin"
 PORTAGE_PYM_PATH        = PORTAGE_BASE_PATH+"/pym"
 PORTAGE_PACKAGE_ATOM    = "sys-apps/portage"
 NEWS_LIB_PATH           = EPREFIX+"/var/lib/gentoo"
-PROFILE_PATH            = EPREFIX+"/etc/make.profile"
+PROFILE_PATH            = "/etc/make.profile"
 LOCALE_DATA_PATH        = PORTAGE_BASE_PATH+"/locale"
 
 EBUILD_SH_BINARY        = PORTAGE_BIN_PATH+"/ebuild.sh"
@@ -49,7 +62,7 @@ MOVE_BINARY             = "mv"
 PRELINK_BINARY          = "prelink"
 
 WORLD_FILE              = PRIVATE_PATH + "/world"
-MAKE_CONF_FILE          = EPREFIX+"/etc/make.conf"
+MAKE_CONF_FILE          = "/etc/make.conf"
 MAKE_DEFAULTS_FILE      = PROFILE_PATH + "/make.defaults"
 DEPRECATED_PROFILE_FILE = PROFILE_PATH+"/deprecated"
 USER_VIRTUALS_FILE      = USER_CONFIG_PATH+"/virtuals"
index 35dba7f0d8cb08ce16a1b2daeeb58df6e8e86af7..72ef34a250b8680867e7ec3d119ba79f6756f6e3 100644 (file)
@@ -11,7 +11,7 @@ import os
 import re
 import shlex
 import sys
-from portage.const import COLOR_MAP_FILE
+from portage.const import COLOR_MAP_FILE, EPREFIX
 from portage.util import writemsg
 from portage.exception import CommandNotFound, FileNotFound, \
        ParseError, PermissionDenied, PortageException
@@ -171,7 +171,7 @@ def parse_color_map(onerror=None):
        @rtype: dict
        @return: a dictionary mapping color classes to color codes
        """
-       myfile = COLOR_MAP_FILE
+       myfile = EPREFIX + COLOR_MAP_FILE
        ansi_code_pattern = re.compile("^[0-9;]*m$")
        def strip_quotes(token, quotes):
                if token[0] in quotes and token[0] == token[-1]:
index 87f6057fdb5a09dbaf612b81d7196ce9dc276dc1..36108dd22b5392ad5a36cb9bb13cf8d71f4ddba9 100644 (file)
@@ -10,7 +10,7 @@ from portage.exception import DirectoryNotFound, PortageException
 from portage.versions import ververify
 from portage.dep import dep_getkey, get_operator, isvalidatom, isjustname, \
        remove_slot
-from portage.const import USER_CONFIG_PATH, WORLD_FILE, EPREFIX
+from portage.const import USER_CONFIG_PATH, WORLD_FILE
 
 ignored_dbentries = ("CONTENTS", "environment.bz2")
 
@@ -149,13 +149,8 @@ def update_config_files(config_root, protect, protect_mask, update_iter):
        myxfiles = ["package.mask", "package.unmask", \
                "package.keywords", "package.use"]
        myxfiles += [os.path.join("profile", x) for x in myxfiles]
-       # if the user gives a path, respect it, otherwise use our prefix
-       if USER_CONFIG_PATH != "":
-               abs_user_config = os.path.join(config_root,
-                       USER_CONFIG_PATH.lstrip(os.path.sep))
-       else:
-               abs_user_config = os.path.join(config_root,
-                       EPREFIX.lstrip(os.path.sep))
+       abs_user_config = os.path.join(config_root,
+               USER_CONFIG_PATH.lstrip(os.path.sep))
        recursivefiles = []
        for x in myxfiles:
                config_file = os.path.join(abs_user_config, x)