summaryrefslogtreecommitdiffstats
path: root/pym/portage/util/env_update.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2011-08-28 23:12:52 -0700
committerZac Medico <zmedico@gentoo.org>2011-08-28 23:12:52 -0700
commit0fb60699ebe51fa998a2d661ecda2c7e021f5d30 (patch)
tree0ce407c382c5dd088ac69a985cb0a268299ce545 /pym/portage/util/env_update.py
parent276105a80d8fd1e6332a2dcb9733bf597fbcb0ed (diff)
downloadportage-0fb60699ebe51fa998a2d661ecda2c7e021f5d30.tar.gz
portage-0fb60699ebe51fa998a2d661ecda2c7e021f5d30.tar.bz2
portage-0fb60699ebe51fa998a2d661ecda2c7e021f5d30.zip
env_update: add minimal EPREFIX support
This takes EPREFIX from the env argument and uses it when joining all paths. Also, ldconfig calls are disabled when EPREFIX is non-empty, since it's inappropriate to update the global /etc/ld.so.cache in this case.
Diffstat (limited to 'pym/portage/util/env_update.py')
-rw-r--r--pym/portage/util/env_update.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/pym/portage/util/env_update.py b/pym/portage/util/env_update.py
index eb8a0d951..3dc84d4a1 100644
--- a/pym/portage/util/env_update.py
+++ b/pym/portage/util/env_update.py
@@ -47,7 +47,10 @@ def env_update(makelinks=1, target_root=None, prev_mtimes=None, contents=None,
prev_mtimes = portage.mtimedb["ldpath"]
if env is None:
env = os.environ
- envd_dir = os.path.join(target_root, "etc", "env.d")
+
+ eprefix = env.get("EPREFIX", "")
+ eprefix_lstrip = eprefix.lstrip(os.sep)
+ envd_dir = os.path.join(target_root, eprefix_lstrip, "etc", "env.d")
ensure_dirs(envd_dir, mode=0o755)
fns = listdir(envd_dir, EmptyOnError=1)
fns.sort()
@@ -123,7 +126,8 @@ def env_update(makelinks=1, target_root=None, prev_mtimes=None, contents=None,
they won't be overwritten by this dict.update call."""
env.update(myconfig)
- ldsoconf_path = os.path.join(target_root, "etc", "ld.so.conf")
+ ldsoconf_path = os.path.join(
+ target_root, eprefix_lstrip, "etc", "ld.so.conf")
try:
myld = io.open(_unicode_encode(ldsoconf_path,
encoding=_encodings['fs'], errors='strict'),
@@ -156,8 +160,8 @@ def env_update(makelinks=1, target_root=None, prev_mtimes=None, contents=None,
# Update prelink.conf if we are prelink-enabled
if prelink_capable:
- newprelink = atomic_ofstream(
- os.path.join(target_root, "etc", "prelink.conf"))
+ newprelink = atomic_ofstream(os.path.join(
+ target_root, eprefix_lstrip, "etc", "prelink.conf"))
newprelink.write("# prelink.conf autogenerated by env-update; make all changes to\n")
newprelink.write("# contents of /etc/env.d directory\n")
@@ -193,7 +197,7 @@ def env_update(makelinks=1, target_root=None, prev_mtimes=None, contents=None,
lib_dirs = set()
for lib_dir in set(specials["LDPATH"] + \
['usr/lib','usr/lib64','usr/lib32','lib','lib64','lib32']):
- x = os.path.join(target_root, lib_dir.lstrip(os.sep))
+ x = os.path.join(target_root, eprefix_lstrip, lib_dir.lstrip(os.sep))
try:
newldpathtime = os.stat(x)[stat.ST_MTIME]
lib_dirs.add(normalize_path(x))
@@ -246,7 +250,7 @@ def env_update(makelinks=1, target_root=None, prev_mtimes=None, contents=None,
ldconfig = find_binary("%s-ldconfig" % env["CHOST"])
# Only run ldconfig as needed
- if (ld_cache_update or makelinks) and ldconfig:
+ if (ld_cache_update or makelinks) and ldconfig and not eprefix:
# ldconfig has very different behaviour between FreeBSD and Linux
if ostype == "Linux" or ostype.lower().endswith("gnu"):
# We can't update links if we haven't cleaned other versions first, as
@@ -272,7 +276,8 @@ def env_update(makelinks=1, target_root=None, prev_mtimes=None, contents=None,
cenvnotice += "# GO INTO /etc/csh.cshrc NOT /etc/csh.env\n\n"
#create /etc/profile.env for bash support
- outfile = atomic_ofstream(os.path.join(target_root, "etc", "profile.env"))
+ outfile = atomic_ofstream(os.path.join(
+ target_root, eprefix_lstrip, "etc", "profile.env"))
outfile.write(penvnotice)
env_keys = [ x for x in env if x != "LDPATH" ]
@@ -286,7 +291,8 @@ def env_update(makelinks=1, target_root=None, prev_mtimes=None, contents=None,
outfile.close()
#create /etc/csh.env for (t)csh support
- outfile = atomic_ofstream(os.path.join(target_root, "etc", "csh.env"))
+ outfile = atomic_ofstream(os.path.join(
+ target_root, eprefix_lstrip, "etc", "csh.env"))
outfile.write(cenvnotice)
for x in env_keys:
outfile.write("setenv %s '%s'\n" % (x, env[x]))