Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 395633 | Differences between
and this patch

Collapse All | Expand All

(-)a/bin/dispatch-conf (-1 / +1 lines)
Lines 79-85 class dispatch: Link Here
79
        confs = []
79
        confs = []
80
        count = 0
80
        count = 0
81
81
82
        config_root = portage.const.EPREFIX or os.sep
82
        config_root = portage.settings["EPREFIX"] or os.sep
83
        self.options = portage.dispatch_conf.read_config(MANDATORY_OPTS)
83
        self.options = portage.dispatch_conf.read_config(MANDATORY_OPTS)
84
84
85
        if "log-file" in self.options:
85
        if "log-file" in self.options:
(-)a/bin/portageq (-1 / +1 lines)
Lines 1232-1238 def main(argv): Link Here
1232
			sys.stderr.write("Run portageq with --help for info\n")
1232
			sys.stderr.write("Run portageq with --help for info\n")
1233
			sys.stderr.flush()
1233
			sys.stderr.flush()
1234
			sys.exit(os.EX_USAGE)
1234
			sys.exit(os.EX_USAGE)
1235
		eprefix = portage.const.EPREFIX
1235
		eprefix = portage.settings["EPREFIX"]
1236
		eroot = portage.util.normalize_path(argv[2])
1236
		eroot = portage.util.normalize_path(argv[2])
1237
1237
1238
		if eprefix:
1238
		if eprefix:
(-)a/pym/_emerge/actions.py (-7 / +2 lines)
Lines 2019-2027 def action_sync(settings, trees, mtimedb, myopts, myaction): Link Here
2019
			myportdir = None
2019
			myportdir = None
2020
	out = portage.output.EOutput()
2020
	out = portage.output.EOutput()
2021
	global_config_path = GLOBAL_CONFIG_PATH
2021
	global_config_path = GLOBAL_CONFIG_PATH
2022
	if settings['EPREFIX']:
2023
		global_config_path = os.path.join(settings['EPREFIX'],
2024
				GLOBAL_CONFIG_PATH.lstrip(os.sep))
2025
	if not myportdir:
2022
	if not myportdir:
2026
		sys.stderr.write("!!! PORTDIR is undefined.  " + \
2023
		sys.stderr.write("!!! PORTDIR is undefined.  " + \
2027
			"Is %s/make.globals missing?\n" % global_config_path)
2024
			"Is %s/make.globals missing?\n" % global_config_path)
Lines 3151-3157 def load_emerge_config(emerge_config=None, **kargs): Link Here
3151
		emerge_config = _emerge_config(**kargs)
3148
		emerge_config = _emerge_config(**kargs)
3152
3149
3153
	kwargs = {}
3150
	kwargs = {}
3154
	for k, envvar in (("config_root", "PORTAGE_CONFIGROOT"), ("target_root", "ROOT")):
3151
	for k, envvar in (("config_root", "PORTAGE_CONFIGROOT"), ("target_root", "ROOT"),
3152
			("eprefix", "EPREFIX")):
3155
		v = os.environ.get(envvar, None)
3153
		v = os.environ.get(envvar, None)
3156
		if v and v.strip():
3154
		if v and v.strip():
3157
			kwargs[k] = v
3155
			kwargs[k] = v
Lines 3332-3340 def missing_sets_warning(root_config, missing_sets): Link Here
3332
	if root_config.sets:
3330
	if root_config.sets:
3333
		msg.append("        sets defined: %s" % ", ".join(root_config.sets))
3331
		msg.append("        sets defined: %s" % ", ".join(root_config.sets))
3334
	global_config_path = portage.const.GLOBAL_CONFIG_PATH
3332
	global_config_path = portage.const.GLOBAL_CONFIG_PATH
3335
	if root_config.settings['EPREFIX']:
3336
		global_config_path = os.path.join(root_config.settings['EPREFIX'],
3337
				portage.const.GLOBAL_CONFIG_PATH.lstrip(os.sep))
3338
	msg.append("        This usually means that '%s'" % \
3333
	msg.append("        This usually means that '%s'" % \
3339
		(os.path.join(global_config_path, "sets/portage.conf"),))
3334
		(os.path.join(global_config_path, "sets/portage.conf"),))
3340
	msg.append("        is missing or corrupt.")
3335
	msg.append("        is missing or corrupt.")
(-)a/pym/_emerge/main.py (+7 lines)
Lines 541-546 def parse_opts(tmpcmdline, silent=False): Link Here
541
			"choices"  : true_y_or_n
541
			"choices"  : true_y_or_n
542
		},
542
		},
543
543
544
		"--prefix": {
545
			"help"     : "specify the installation prefix",
546
			"action"   : "store"
547
		},
548
544
		"--quiet": {
549
		"--quiet": {
545
			"shortopt" : "-q",
550
			"shortopt" : "-q",
546
			"help"     : "reduced or condensed output",
551
			"help"     : "reduced or condensed output",
Lines 1024-1029 def emerge_main(args=None): Link Here
1024
		os.environ["PORTAGE_CONFIGROOT"] = myopts["--config-root"]
1029
		os.environ["PORTAGE_CONFIGROOT"] = myopts["--config-root"]
1025
	if "--root" in myopts:
1030
	if "--root" in myopts:
1026
		os.environ["ROOT"] = myopts["--root"]
1031
		os.environ["ROOT"] = myopts["--root"]
1032
	if "--prefix" in myopts:
1033
		os.environ["EPREFIX"] = myopts["--prefix"]
1027
	if "--accept-properties" in myopts:
1034
	if "--accept-properties" in myopts:
1028
		os.environ["ACCEPT_PROPERTIES"] = myopts["--accept-properties"]
1035
		os.environ["ACCEPT_PROPERTIES"] = myopts["--accept-properties"]
1029
	if "--accept-restrict" in myopts:
1036
	if "--accept-restrict" in myopts:
(-)a/pym/portage/_legacy_globals.py (-1 / +2 lines)
Lines 27-33 def _get_legacy_global(name): Link Here
27
	os.umask(0o22)
27
	os.umask(0o22)
28
28
29
	kwargs = {}
29
	kwargs = {}
30
	for k, envvar in (("config_root", "PORTAGE_CONFIGROOT"), ("target_root", "ROOT")):
30
	for k, envvar in (("config_root", "PORTAGE_CONFIGROOT"),
31
			("target_root", "ROOT"), ("eprefix", "EPREFIX")):
31
		kwargs[k] = os.environ.get(envvar)
32
		kwargs[k] = os.environ.get(envvar)
32
33
33
	portage._initializing_globals = True
34
	portage._initializing_globals = True
(-)a/pym/portage/_sets/__init__.py (-3 lines)
Lines 295-303 def load_default_config(settings, trees): Link Here
295
		return SetConfig(None, settings, trees)
295
		return SetConfig(None, settings, trees)
296
296
297
	global_config_path = GLOBAL_CONFIG_PATH
297
	global_config_path = GLOBAL_CONFIG_PATH
298
	if settings['EPREFIX']:
299
		global_config_path = os.path.join(settings['EPREFIX'],
300
			GLOBAL_CONFIG_PATH.lstrip(os.sep))
301
	def _getfiles():
298
	def _getfiles():
302
		for path, dirs, files in os.walk(os.path.join(global_config_path, "sets")):
299
		for path, dirs, files in os.walk(os.path.join(global_config_path, "sets")):
303
			for f in files:
300
			for f in files:
(-)a/pym/portage/const.py (-17 / +17 lines)
Lines 52-61 WORLD_SETS_FILE = PRIVATE_PATH + "/world_sets" Link Here
52
CONFIG_MEMORY_FILE       = PRIVATE_PATH + "/config"
52
CONFIG_MEMORY_FILE       = PRIVATE_PATH + "/config"
53
NEWS_LIB_PATH            = "var/lib/gentoo"
53
NEWS_LIB_PATH            = "var/lib/gentoo"
54
54
55
# these variables get EPREFIX prepended automagically when they are
55
# The EPREFIX for the current install is hardcoded here, but access to this
56
# translated into their lowercase variants
56
# constant should be minimal, in favor of access via the EPREFIX setting of
57
DEPCACHE_PATH            = "/var/cache/edb/dep"
57
# a config instance (since it's possible to contruct a config instance with
58
GLOBAL_CONFIG_PATH       = "/usr/share/portage/config"
58
# a different EPREFIX).
59
EPREFIX=""
60
61
# pick up EPREFIX from the environment if set
62
if "PORTAGE_OVERRIDE_EPREFIX" in os.environ:
63
	EPREFIX = os.environ["PORTAGE_OVERRIDE_EPREFIX"]
64
	if EPREFIX:
65
		EPREFIX = os.path.normpath(EPREFIX)
66
67
# these variables are based on the prefix of the portage installation, not
68
# the prefix of the installed packages, and as such use the builtin EPREFIX
69
# rather than the EPREFIX setting in a config instance.
70
DEPCACHE_PATH            = EPREFIX + "/var/cache/edb/dep"
71
GLOBAL_CONFIG_PATH       = EPREFIX + "/usr/share/portage/config"
59
72
60
# these variables are not used with target_root or config_root
73
# these variables are not used with target_root or config_root
61
# NOTE: Use realpath(__file__) so that python module symlinks in site-packages
74
# NOTE: Use realpath(__file__) so that python module symlinks in site-packages
Lines 152-170 MANIFEST2_REQUIRED_HASH = "SHA256" Link Here
152
165
153
MANIFEST2_IDENTIFIERS    = ("AUX", "MISC", "DIST", "EBUILD")
166
MANIFEST2_IDENTIFIERS    = ("AUX", "MISC", "DIST", "EBUILD")
154
167
155
# The EPREFIX for the current install is hardcoded here, but access to this
156
# constant should be minimal, in favor of access via the EPREFIX setting of
157
# a config instance (since it's possible to contruct a config instance with
158
# a different EPREFIX). Therefore, the EPREFIX constant should *NOT* be used
159
# in the definition of any other constants within this file.
160
EPREFIX=""
161
162
# pick up EPREFIX from the environment if set
163
if "PORTAGE_OVERRIDE_EPREFIX" in os.environ:
164
	EPREFIX = os.environ["PORTAGE_OVERRIDE_EPREFIX"]
165
	if EPREFIX:
166
		EPREFIX = os.path.normpath(EPREFIX)
167
168
VCS_DIRS = ("CVS", "RCS", "SCCS", ".bzr", ".git", ".hg", ".svn")
168
VCS_DIRS = ("CVS", "RCS", "SCCS", ".bzr", ".git", ".hg", ".svn")
169
169
170
# ===========================================================================
170
# ===========================================================================
(-)a/pym/portage/dispatch_conf.py (-1 / +1 lines)
Lines 43-49 def diffstatusoutput(cmd, file1, file2): Link Here
43
    return (proc.wait(), output)
43
    return (proc.wait(), output)
44
44
45
def read_config(mandatory_opts):
45
def read_config(mandatory_opts):
46
    eprefix = portage.const.EPREFIX
46
    eprefix = portage.settings["EPREFIX"]
47
    config_path = os.path.join(eprefix or os.sep, "etc/dispatch-conf.conf")
47
    config_path = os.path.join(eprefix or os.sep, "etc/dispatch-conf.conf")
48
    loader = KeyValuePairFileLoader(config_path, None)
48
    loader = KeyValuePairFileLoader(config_path, None)
49
    opts, errors = loader.load()
49
    opts, errors = loader.load()
(-)a/pym/portage/package/ebuild/_config/LocationsManager.py (-22 lines)
Lines 275-303 class LocationsManager(object): Link Here
275
275
276
		self.eroot = self.target_root.rstrip(os.sep) + self.eprefix + os.sep
276
		self.eroot = self.target_root.rstrip(os.sep) + self.eprefix + os.sep
277
277
278
		# make.globals should not be relative to config_root
279
		# because it only contains constants. However, if EPREFIX
280
		# is set then there are two possible scenarios:
281
		# 1) If $ROOT == "/" then make.globals should be
282
		#    relative to EPREFIX.
283
		# 2) If $ROOT != "/" then the correct location of
284
		#    make.globals needs to be specified in the constructor
285
		#    parameters, since it's a property of the host system
286
		#    (and the current config represents the target system).
287
		self.global_config_path = GLOBAL_CONFIG_PATH
278
		self.global_config_path = GLOBAL_CONFIG_PATH
288
		if self.eprefix:
289
			if self.target_root == "/":
290
				# case (1) above
291
				self.global_config_path = os.path.join(self.eprefix,
292
					GLOBAL_CONFIG_PATH.lstrip(os.sep))
293
			else:
294
				# case (2) above
295
				# For now, just assume make.globals is relative
296
				# to EPREFIX.
297
				# TODO: Pass in more info to the constructor,
298
				# so we know the host system configuration.
299
				self.global_config_path = os.path.join(self.eprefix,
300
					GLOBAL_CONFIG_PATH.lstrip(os.sep))
301
279
302
	def set_port_dirs(self, portdir, portdir_overlay):
280
	def set_port_dirs(self, portdir, portdir_overlay):
303
		self.portdir = portdir
281
		self.portdir = portdir
(-)a/pym/portage/package/ebuild/config.py (-21 lines)
Lines 594-607 class config(object): Link Here
594
			self.backup_changes("PORTAGE_CONFIGROOT")
594
			self.backup_changes("PORTAGE_CONFIGROOT")
595
			self["ROOT"] = target_root
595
			self["ROOT"] = target_root
596
			self.backup_changes("ROOT")
596
			self.backup_changes("ROOT")
597
598
			# The PORTAGE_OVERRIDE_EPREFIX variable propagates the EPREFIX
599
			# of this config instance to any portage commands or API
600
			# consumers running in subprocesses.
601
			self["EPREFIX"] = eprefix
597
			self["EPREFIX"] = eprefix
602
			self.backup_changes("EPREFIX")
598
			self.backup_changes("EPREFIX")
603
			self["PORTAGE_OVERRIDE_EPREFIX"] = eprefix
604
			self.backup_changes("PORTAGE_OVERRIDE_EPREFIX")
605
			self["EROOT"] = eroot
599
			self["EROOT"] = eroot
606
			self.backup_changes("EROOT")
600
			self.backup_changes("EROOT")
607
601
Lines 781-801 class config(object): Link Here
781
				self.backupenv["USE_ORDER"] = "env:pkg:conf:defaults:pkginternal:repo:env.d"
775
				self.backupenv["USE_ORDER"] = "env:pkg:conf:defaults:pkginternal:repo:env.d"
782
776
783
			self.depcachedir = DEPCACHE_PATH
777
			self.depcachedir = DEPCACHE_PATH
784
			if eprefix:
785
				# See comments about make.globals and EPREFIX
786
				# above. DEPCACHE_PATH is similar.
787
				if target_root == "/":
788
					# case (1) above
789
					self.depcachedir = os.path.join(eprefix,
790
						DEPCACHE_PATH.lstrip(os.sep))
791
				else:
792
					# case (2) above
793
					# For now, just assume DEPCACHE_PATH is relative
794
					# to EPREFIX.
795
					# TODO: Pass in more info to the constructor,
796
					# so we know the host system configuration.
797
					self.depcachedir = os.path.join(eprefix,
798
						DEPCACHE_PATH.lstrip(os.sep))
799
778
800
			if self.get("PORTAGE_DEPCACHEDIR", None):
779
			if self.get("PORTAGE_DEPCACHEDIR", None):
801
				self.depcachedir = self["PORTAGE_DEPCACHEDIR"]
780
				self.depcachedir = self["PORTAGE_DEPCACHEDIR"]
(-)a/pym/portage/package/ebuild/doebuild.py (-1 / +1 lines)
Lines 159-165 def _doebuild_path(settings, eapi=None): Link Here
159
	# Note: PORTAGE_BIN_PATH may differ from the global constant
159
	# Note: PORTAGE_BIN_PATH may differ from the global constant
160
	# when portage is reinstalling itself.
160
	# when portage is reinstalling itself.
161
	portage_bin_path = settings["PORTAGE_BIN_PATH"]
161
	portage_bin_path = settings["PORTAGE_BIN_PATH"]
162
	eprefix = settings["EPREFIX"]
162
	eprefix = portage.const.EPREFIX
163
	prerootpath = [x for x in settings.get("PREROOTPATH", "").split(":") if x]
163
	prerootpath = [x for x in settings.get("PREROOTPATH", "").split(":") if x]
164
	rootpath = [x for x in settings.get("ROOTPATH", "").split(":") if x]
164
	rootpath = [x for x in settings.get("ROOTPATH", "").split(":") if x]
165
	overrides = [x for x in settings.get(
165
	overrides = [x for x in settings.get(
(-)a/pym/portage/package/ebuild/fetch.py (-4 lines)
Lines 865-874 def fetch(myuris, mysettings, listonly=0, fetchonly=0, Link Here
865
				protocol = loc[0:loc.find("://")]
865
				protocol = loc[0:loc.find("://")]
866
866
867
				global_config_path = GLOBAL_CONFIG_PATH
867
				global_config_path = GLOBAL_CONFIG_PATH
868
				if mysettings['EPREFIX']:
869
					global_config_path = os.path.join(mysettings['EPREFIX'],
870
							GLOBAL_CONFIG_PATH.lstrip(os.sep))
871
872
				missing_file_param = False
868
				missing_file_param = False
873
				fetchcommand_var = "FETCHCOMMAND_" + protocol.upper()
869
				fetchcommand_var = "FETCHCOMMAND_" + protocol.upper()
874
				fetchcommand = mysettings.get(fetchcommand_var)
870
				fetchcommand = mysettings.get(fetchcommand_var)
(-)a/pym/portage/tests/resolver/ResolverPlayground.py (-2 / +1 lines)
Lines 426-433 class ResolverPlayground(object): Link Here
426
			f.close()
426
			f.close()
427
427
428
		#Create /usr/share/portage/config/make.globals
428
		#Create /usr/share/portage/config/make.globals
429
		make_globals_path = os.path.join(self.eroot,
429
		make_globals_path = os.path.join(GLOBAL_CONFIG_PATH, "make.globals")
430
			GLOBAL_CONFIG_PATH.lstrip(os.sep), "make.globals")
431
		ensure_dirs(os.path.dirname(make_globals_path))
430
		ensure_dirs(os.path.dirname(make_globals_path))
432
		os.symlink(os.path.join(PORTAGE_BASE_PATH, "cnf", "make.globals"),
431
		os.symlink(os.path.join(PORTAGE_BASE_PATH, "cnf", "make.globals"),
433
			make_globals_path)
432
			make_globals_path)
(-)a/pym/portage/util/env_update.py (-2 / +1 lines)
Lines 46-57 def env_update(makelinks=1, target_root=None, prev_mtimes=None, contents=None, Link Here
46
		if isinstance(env, config):
46
		if isinstance(env, config):
47
			vardbapi = vartree(settings=env).dbapi
47
			vardbapi = vartree(settings=env).dbapi
48
		else:
48
		else:
49
			eprefix = portage.settings["EPREFIX"]
49
			if target_root is None:
50
			if target_root is None:
50
				eprefix = portage.settings["EPREFIX"]
51
				target_root = portage.settings["ROOT"]
51
				target_root = portage.settings["ROOT"]
52
				target_eroot = portage.settings['EROOT']
52
				target_eroot = portage.settings['EROOT']
53
			else:
53
			else:
54
				eprefix = portage.const.EPREFIX
55
				target_eroot = os.path.join(target_root,
54
				target_eroot = os.path.join(target_root,
56
					eprefix.lstrip(os.sep))
55
					eprefix.lstrip(os.sep))
57
				target_eroot = target_eroot.rstrip(os.sep) + os.sep
56
				target_eroot = target_eroot.rstrip(os.sep) + os.sep

Return to bug 395633