From defd46c4a16f9df0ad1e6e03c261f09d102c2a6d Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Wed, 25 Jul 2007 21:35:50 +0000 Subject: [PATCH] Prepend EPREFIX to relative paths, but keep them relative by stripping the leading '/'. Cleaned up path construction from root + EPREFIX to avoid double path separators. svn path=/main/branches/prefix/; revision=7399 --- pym/portage/__init__.py | 44 ++++++++++++++++++++--------------------- pym/portage/const.py | 6 ++++-- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 4a3c66100..e8bbdbcf1 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -70,7 +70,7 @@ try: DEPRECATED_PROFILE_FILE, USER_VIRTUALS_FILE, EBUILD_SH_ENV_FILE, \ INVALID_ENV_FILE, CUSTOM_MIRRORS_FILE, CONFIG_MEMORY_FILE,\ INCREMENTALS, EAPI, MISC_SH_BINARY, REPO_NAME_LOC, REPO_NAME_FILE, \ - EPREFIX + EPREFIX, EPREFIX_LSTRIP from portage.data import ostype, lchown, userland, secpass, uid, wheelgid, \ portage_uid, portage_gid, userpriv_groups @@ -482,7 +482,7 @@ def env_update(makelinks=1, target_root=None, prev_mtimes=None, contents=None, prev_mtimes = mtimedb["ldpath"] if env is None: env = os.environ - envd_dir = os.path.join(target_root + EPREFIX, "etc", "env.d") + envd_dir = os.path.join(target_root, EPREFIX_LSTRIP, "etc", "env.d") portage.util.ensure_dirs(envd_dir, mode=0755) fns = listdir(envd_dir, EmptyOnError=1) fns.sort() @@ -557,7 +557,7 @@ 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 + EPREFIX, "etc", "ld.so.conf") + ldsoconf_path = os.path.join(target_root, EPREFIX_LSTRIP, "etc", "ld.so.conf") try: myld = open(ldsoconf_path) myldlines=myld.readlines() @@ -589,7 +589,7 @@ 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 + EPREFIX, "etc", "prelink.conf")) + 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 "+EPREFIX+"/etc/env.d directory\n") @@ -624,7 +624,7 @@ def env_update(makelinks=1, target_root=None, prev_mtimes=None, contents=None, mtime_changed = False lib_dirs = set() for lib_dir in portage.util.unique_array(specials["LDPATH"]+['usr/lib','usr/lib64','usr/lib32','lib','lib64','lib32']): - x = os.path.join(target_root + EPREFIX, lib_dir.lstrip(os.sep)) + x = os.path.join(target_root, EPREFIX_LSTRIP, lib_dir.lstrip(os.sep)) try: newldpathtime = long(os.stat(x).st_mtime) lib_dirs.add(normalize_path(x)) @@ -680,17 +680,17 @@ def env_update(makelinks=1, target_root=None, prev_mtimes=None, contents=None, # an older package installed ON TOP of a newer version will cause ldconfig # to overwrite the symlinks we just made. -X means no links. After 'clean' # we can safely create links. - writemsg(">>> Regenerating %s/etc/ld.so.cache...\n" % (target_root+EPREFIX)) + writemsg(">>> Regenerating %s/etc/ld.so.cache...\n" % (target_root + EPREFIX_LSTRIP)) if makelinks: os.system("cd / ; %s -r '%s'" % (ldconfig, target_root)) else: os.system("cd / ; %s -X -r '%s'" % (ldconfig, target_root)) elif ostype in ("FreeBSD","DragonFly"): writemsg(">>> Regenerating %svar/run/ld-elf.so.hints...\n" % \ - target_root+EPREFIX) + target_root + EPREFIX_LSTRIP) os.system(("cd / ; %s -elf -i " + \ "-f '%svar/run/ld-elf.so.hints' '%setc/ld.so.conf'") % \ - (ldconfig, target_root+EPREFIX, target_root+EPREFIX)) + (ldconfig, target_root + EPREFIX_LSTRIP, target_root + EPREFIX_LSTRIP)) del specials["LDPATH"] @@ -701,7 +701,7 @@ def env_update(makelinks=1, target_root=None, prev_mtimes=None, contents=None, cenvnotice += "# GO INTO "+EPREFIX+"/etc/csh.cshrc NOT "+EPREFIX+"/etc/csh.env\n\n" #create /etc/profile.env for bash support - outfile = atomic_ofstream(os.path.join(target_root + EPREFIX, "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" ] @@ -715,7 +715,7 @@ 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 + EPREFIX, "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])) @@ -958,7 +958,7 @@ class config(object): config_root = normalize_path(os.path.abspath( config_root)).rstrip(os.path.sep) + os.path.sep - check_var_directory("PORTAGE_CONFIGROOT", config_root + EPREFIX) + check_var_directory("PORTAGE_CONFIGROOT", config_root + EPREFIX_LSTRIP) self.depcachedir = DEPCACHE_PATH @@ -1101,7 +1101,7 @@ class config(object): del rawpuseforce try: - self.mygcfg = getconfig(os.path.join(config_root + EPREFIX, "etc", "make.globals")) + self.mygcfg = getconfig(os.path.join(config_root, EPREFIX_LSTRIP, "etc", "make.globals")) if self.mygcfg is None: self.mygcfg = {} @@ -1211,10 +1211,10 @@ class config(object): target_root = normalize_path(os.path.abspath( target_root)).rstrip(os.path.sep) + os.path.sep - check_var_directory("ROOT", target_root + EPREFIX) + check_var_directory("ROOT", target_root + EPREFIX_LSTRIP) env_d = getconfig( - os.path.join(target_root + EPREFIX, "etc", "profile.env"), expand=False) + os.path.join(target_root, EPREFIX_LSTRIP, "etc", "profile.env"), expand=False) # env_d will be None if profile.env doesn't exist. if env_d: self.configdict["env.d"].update(env_d) @@ -1237,7 +1237,7 @@ class config(object): self.backup_changes("ROOT") self["EPREFIX"] = EPREFIX self.backup_changes("EPREFIX") - self["EROOT"] = normalize_path(target_root + EPREFIX) + os.sep + self["EROOT"] = target_root + EPREFIX_LSTRIP + os.path.sep self.backup_changes("EROOT") self.pusedict = {} @@ -1502,7 +1502,7 @@ class config(object): """ Create a few directories that are critical to portage operation """ - if not os.access(self["ROOT"] + EPREFIX, os.W_OK): + if not os.access(self["ROOT"] + EPREFIX_LSTRIP, os.W_OK): return dir_mode_map = { @@ -1928,7 +1928,7 @@ class config(object): # We grab the latest profile.env here since it changes frequently. self.configdict["env.d"].clear() env_d = getconfig( - os.path.join(self["ROOT"] + EPREFIX, "etc", "profile.env"), expand=False) + os.path.join(self["ROOT"], EPREFIX_LSTRIP, "etc", "profile.env"), expand=False) if env_d: # env_d will be None if profile.env doesn't exist. self.configdict["env.d"].update(env_d) @@ -3304,9 +3304,9 @@ def doebuild_environment(myebuild, mydo, myroot, mysettings, debug, use_cache, m # due to how it's coded... Don't overwrite this so we can use it. mysettings["PORTAGE_DEBUG"] = "1" - mysettings["EPREFIX"] = EPREFIX.rstrip(os.sep) + mysettings["EPREFIX"] = EPREFIX.rstrip(os.path.sep) mysettings["ROOT"] = myroot - mysettings["EROOT"] = normalize_path(myroot + mysettings["EPREFIX"]) + os.sep + mysettings["EROOT"] = myroot + mysettings["EPREFIX"].lstrip(os.path.sep) + os.path.sep mysettings["STARTDIR"] = getcwd() mysettings["PORTAGE_REPO_NAME"] = "" @@ -3393,7 +3393,7 @@ def doebuild_environment(myebuild, mydo, myroot, mysettings, debug, use_cache, m #set up KV variable -- DEP SPEEDUP :: Don't waste time. Keep var persistent. if (mydo!="depend") or not mysettings.has_key("KV"): - mykv,err1=ExtractKernelVersion(os.path.join(myroot + EPREFIX, "usr/src/linux")) + mykv,err1=ExtractKernelVersion(os.path.join(myroot, EPREFIX_LSTRIP, "usr/src/linux")) if mykv: # Regular source tree mysettings["KV"]=mykv @@ -4256,9 +4256,9 @@ def movefile(src,dest,newmtime=None,sstat=None,mysettings=None): def merge(mycat, mypkg, pkgloc, infloc, myroot, mysettings, myebuild=None, mytree=None, mydbapi=None, vartree=None, prev_mtimes=None): - if not os.access(myroot+EPREFIX.lstrip("/"), os.W_OK): + if not os.access(myroot + EPREFIX_LSTRIP, os.W_OK): writemsg("Permission denied: access('%s', W_OK)\n" % - (myroot+EPREFIX.lstrip("/")), noiselevel=-1) + (myroot + EPREFIX_LSTRIP), noiselevel=-1) return errno.EACCES mylink = dblink(mycat, mypkg, myroot, mysettings, treetype=mytree, vartree=vartree) diff --git a/pym/portage/const.py b/pym/portage/const.py index e620f72b2..6e24c49f3 100644 --- a/pym/portage/const.py +++ b/pym/portage/const.py @@ -14,8 +14,10 @@ from portage.const_autotool import * # START OF CONSTANTS -- START OF CONSTANTS -- START OF CONSTANTS -- START OF # =========================================================================== -VDB_PATH = "var/db/pkg" -PRIVATE_PATH = "var/lib/portage" +EPREFIX_LSTRIP = EPREFIX.lstrip(os.path.sep) + +VDB_PATH = EPREFIX_LSTRIP+os.path.sep+"var/db/pkg" +PRIVATE_PATH = EPREFIX_LSTRIP+os.path.sep+"var/lib/portage" CACHE_PATH = EPREFIX+"/var/cache/edb" DEPCACHE_PATH = CACHE_PATH+"/dep" -- 2.26.2