From 01346e323a11149e8596efd8dad7a09fbcc2b347 Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Wed, 16 Jul 2008 13:10:43 +0000 Subject: [PATCH] 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. svn path=/main/branches/prefix/; revision=11082 --- pym/_emerge/__init__.py | 8 ++++---- pym/portage/__init__.py | 6 +++--- pym/portage/const.py | 21 +++++++++++++++++---- pym/portage/output.py | 4 ++-- pym/portage/update.py | 11 +++-------- 5 files changed, 29 insertions(+), 21 deletions(-) diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index c1c481597..b72f3a8a0 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -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 diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 6da2e7ffd..06629add0 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -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 diff --git a/pym/portage/const.py b/pym/portage/const.py index 94996dc6b..8a80ffdbf 100644 --- a/pym/portage/const.py +++ b/pym/portage/const.py @@ -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" diff --git a/pym/portage/output.py b/pym/portage/output.py index 35dba7f0d..72ef34a25 100644 --- a/pym/portage/output.py +++ b/pym/portage/output.py @@ -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]: diff --git a/pym/portage/update.py b/pym/portage/update.py index 87f6057fd..36108dd22 100644 --- a/pym/portage/update.py +++ b/pym/portage/update.py @@ -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) -- 2.26.2