From 0fb60699ebe51fa998a2d661ecda2c7e021f5d30 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sun, 28 Aug 2011 23:12:52 -0700 Subject: 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. --- pym/portage/util/env_update.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'pym/portage/util/env_update.py') 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])) -- cgit v1.2.3-1-g7c22