From: Fabian Groffen Date: Sat, 5 Sep 2009 10:54:56 +0000 (-0000) Subject: (reproduced commit r14192 from trunk) X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=e3340c21198aa0c21c82ff75b82270853d6686d5;p=portage.git (reproduced commit r14192 from trunk) reorganise const.py to have logical grouping based on usage grouped into use with config_root, target_root or nothing, made all variables that are used with config_root or target_root not start with a leading slash, such that they can be directly used with os.path.join (which they should because of xxxx_root). svn path=/main/branches/prefix/; revision=14193 --- diff --git a/pym/portage/const.py b/pym/portage/const.py index 7fd48af1c..a7519c691 100644 --- a/pym/portage/const.py +++ b/pym/portage/const.py @@ -2,13 +2,14 @@ # Copyright 1998-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Id$ -import os # =========================================================================== # autotool supplied constants. # =========================================================================== from portage.const_autotool import * +import os + # save the original prefix BPREFIX = EPREFIX # pick up EPREFIX from the environment if set @@ -21,59 +22,68 @@ 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 +# There are two types of variables here which can easily be confused, +# resulting in arbitrary bugs, mainly exposed with an offset +# installation (Prefix). The two types relate to the usage of +# config_root or target_root. +# The first, config_root (PORTAGE_CONFIGROOT), can be a path somewhere, +# from which all derived paths need to be relative (e.g. +# USER_CONFIG_PATH) without EPREFIX prepended in Prefix. This means +# config_root can for instance be set to "$HOME/my/config". Obviously, +# in such case it is not appropriate to prepend EPREFIX to derived +# constants. The default value of config_root is EPREFIX (in non-Prefix +# the empty string) -- overriding the value loses the EPREFIX as one +# would expect. +# Second there is target_root (ROOT) which is used 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 = "var/lib/portage" -CACHE_PATH = EPREFIX+"/var/cache/edb" -DEPCACHE_PATH = CACHE_PATH+"/dep" +# constants (like VDB_PATH) are always absolute and hence DO have +# EPREFIX prepended in Prefix. +# The variables in this file are grouped by config_root, target_root. +# variables used with config_root (these need to be relative) +MAKE_CONF_FILE = "etc/make.conf" 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" - -PORTAGE_BASE_PATH = PORTAGE_BASE -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" +MODULES_FILE_PATH = USER_CONFIG_PATH + "/modules" +CUSTOM_PROFILE_PATH = USER_CONFIG_PATH + "/profile" +USER_VIRTUALS_FILE = USER_CONFIG_PATH + "/virtuals" +EBUILD_SH_ENV_FILE = USER_CONFIG_PATH + "/bashrc" +CUSTOM_MIRRORS_FILE = USER_CONFIG_PATH + "/mirrors" +COLOR_MAP_FILE = USER_CONFIG_PATH + "/color.map" PROFILE_PATH = "etc/make.profile" -LOCALE_DATA_PATH = PORTAGE_BASE_PATH+"/locale" +MAKE_DEFAULTS_FILE = PROFILE_PATH + "/make.defaults" # FIXME: not used +DEPRECATED_PROFILE_FILE = PROFILE_PATH + "/deprecated" + +# variables used with target_root (these need to be absolute, but not +# have a leading '/' since they are used directly with os.path.join) +VDB_PATH = EPREFIX_LSTRIP + "/" + "var/db/pkg" +CACHE_PATH = EPREFIX_LSTRIP + "/" + "var/cache/edb" +DEPCACHE_PATH = CACHE_PATH + "/dep" # FIXME: does not seem to use ROOT when used +PRIVATE_PATH = "var/lib/portage" +WORLD_FILE = PRIVATE_PATH + "/world" +CONFIG_MEMORY_FILE = PRIVATE_PATH + "/config" +NEWS_LIB_PATH = EPREFIX_LSTRIP + "/" + "var/lib/gentoo" -EBUILD_SH_BINARY = PORTAGE_BIN_PATH+"/ebuild.sh" +# these variables are not used with target_root or config_root +GLOBAL_CONFIG_PATH = DATADIR + "/portage/config" +PORTAGE_BASE_PATH = PORTAGE_BASE +PORTAGE_BIN_PATH = PORTAGE_BASE_PATH + "/bin" +PORTAGE_PYM_PATH = PORTAGE_BASE_PATH + "/pym" +LOCALE_DATA_PATH = PORTAGE_BASE_PATH + "/locale" # FIXME: not used +EBUILD_SH_BINARY = PORTAGE_BIN_PATH + "/ebuild.sh" MISC_SH_BINARY = PORTAGE_BIN_PATH + "/misc-functions.sh" -SANDBOX_BINARY = BPREFIX+"/usr/bin/sandbox" -FAKEROOT_BINARY = BPREFIX+"/usr/bin/fakeroot" +SANDBOX_BINARY = BPREFIX + "/usr/bin/sandbox" +FAKEROOT_BINARY = BPREFIX + "/usr/bin/fakeroot" BASH_BINARY = PORTAGE_BASH MOVE_BINARY = PORTAGE_MV -PRELINK_BINARY = EPREFIX+"/usr/sbin/prelink" +PRELINK_BINARY = EPREFIX + "/usr/sbin/prelink" -WORLD_FILE = PRIVATE_PATH + "/world" -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" -EBUILD_SH_ENV_FILE = USER_CONFIG_PATH+"/bashrc" INVALID_ENV_FILE = "/etc/spork/is/not/valid/profile.env" -CUSTOM_MIRRORS_FILE = USER_CONFIG_PATH+"/mirrors" -CONFIG_MEMORY_FILE = PRIVATE_PATH + "/config" -COLOR_MAP_FILE = USER_CONFIG_PATH + "/color.map" - REPO_NAME_FILE = "repo_name" REPO_NAME_LOC = "profiles" + "/" + REPO_NAME_FILE +PORTAGE_PACKAGE_ATOM = "sys-apps/portage" + INCREMENTALS = ["USE", "USE_EXPAND", "USE_EXPAND_HIDDEN", "FEATURES", "ACCEPT_KEYWORDS", "CONFIG_PROTECT_MASK", "CONFIG_PROTECT", @@ -87,13 +97,13 @@ EBUILD_PHASES = ["setup", "unpack", "prepare", "configure", EAPI = 2 HASHING_BLOCKSIZE = 32768 -MANIFEST1_HASH_FUNCTIONS = ["MD5","SHA256","RMD160"] -MANIFEST2_HASH_FUNCTIONS = ["SHA1","SHA256","RMD160"] +MANIFEST1_HASH_FUNCTIONS = ["MD5", "SHA256", "RMD160"] +MANIFEST2_HASH_FUNCTIONS = ["SHA1", "SHA256", "RMD160"] MANIFEST1_REQUIRED_HASH = "MD5" MANIFEST2_REQUIRED_HASH = "SHA1" -MANIFEST2_IDENTIFIERS = ["AUX","MISC","DIST","EBUILD"] +MANIFEST2_IDENTIFIERS = ["AUX", "MISC", "DIST", "EBUILD"] # =========================================================================== # END OF CONSTANTS -- END OF CONSTANTS -- END OF CONSTANTS -- END OF CONSTANT # ===========================================================================