Unfortunately os.path.join is "intelligent":
authorFabian Groffen <grobian@gentoo.org>
Sun, 15 Oct 2006 09:14:15 +0000 (09:14 -0000)
committerFabian Groffen <grobian@gentoo.org>
Sun, 15 Oct 2006 09:14:15 +0000 (09:14 -0000)
If any component is an absolute path, all previous components (on
Windows, including the previous drive letter, if there was one) are
thrown away, and joining continues.
This means we cannot join EPREFIX, as it is an absolute path.

svn path=/main/branches/prefix/; revision=4707

pym/portage.py

index 9fa198658e3f69f9aadc7961139fc1d881ccb7db..bafb66a39bc58dfa9d3685b6ff867f55dc347ba5 100644 (file)
@@ -543,7 +543,7 @@ def env_update(makelinks=1, target_root=None, prev_mtimes=None, contents=None):
        if prev_mtimes is None:
                global mtimedb
                prev_mtimes = mtimedb["ldpath"]
-       envd_dir = os.path.join(target_root, portage_const.EPREFIX, "etc", "env.d")
+       envd_dir = os.path.join(target_root + portage_const.EPREFIX, "etc", "env.d")
        portage_util.ensure_dirs(envd_dir, mode=0755)
        fns = listdir(envd_dir, EmptyOnError=1)
        fns.sort()
@@ -614,7 +614,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, portage_const.EPREFIX, "etc", "ld.so.conf")
+       ldsoconf_path = os.path.join(target_root + portage_const.EPREFIX, "etc", "ld.so.conf")
        try:
                myld = open(ldsoconf_path)
                myldlines=myld.readlines()
@@ -646,7 +646,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, portage_const.EPREFIX, "etc", "prelink.conf"))
+                       os.path.join(target_root + portage_const.EPREFIX, "etc", "prelink.conf"))
                newprelink.write("# prelink.conf autogenerated by env-update; make all changes to\n")
                newprelink.write("# contents of "+portage_const.EPREFIX+"/etc/env.d directory\n")
 
@@ -675,7 +675,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, portage_const.EPREFIX, lib_dir.lstrip(os.sep))
+               x = os.path.join(target_root + portage_const.EPREFIX, lib_dir.lstrip(os.sep))
                try:
                        newldpathtime = os.stat(x)[stat.ST_MTIME]
                        lib_dirs.add(normalize_path(x))
@@ -745,7 +745,7 @@ def env_update(makelinks=1, target_root=None, prev_mtimes=None, contents=None):
        cenvnotice += "# GO INTO "+portage_const.EPREFIX+"/etc/csh.cshrc NOT "+portage_const.EPREFIX+"/etc/csh.env\n\n"
 
        #create /etc/profile.env for bash support
-       outfile = atomic_ofstream(os.path.join(target_root, portage_const.EPREFIX, "etc", "profile.env"))
+       outfile = atomic_ofstream(os.path.join(target_root + portage_const.EPREFIX, "etc", "profile.env"))
        outfile.write(penvnotice)
 
        env_keys = [ x for x in env if x != "LDPATH" ]
@@ -755,7 +755,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, portage_const.EPREFIX, "etc", "csh.env"))
+       outfile = atomic_ofstream(os.path.join(target_root + portage_const.EPREFIX, "etc", "csh.env"))
        outfile.write(cenvnotice)
        for x in env_keys:
                outfile.write("setenv %s '%s'\n" % (x, env[x]))
@@ -941,7 +941,7 @@ class config:
 
                        for k, v in (("PORTAGE_CONFIGROOT", config_root),
                                ("ROOT", target_root)):
-                               v = os.path.join(v, portage_const.EPREFIX)
+                               v = v + portage_const.EPREFIX
                                if not os.path.isdir(v):
                                        writemsg("!!! Error: %s='%s' is not a directory. Please correct this.\n" % (k, v),
                                                noiselevel=-1)
@@ -1080,7 +1080,7 @@ class config:
 
                        try:
                                mygcfg_dlists = [getconfig(os.path.join(x, "make.globals")) \
-                                       for x in self.profiles + [os.path.join(config_root, portage_const.EPREFIX, "etc")]]
+                                       for x in self.profiles + [os.path.join(config_root + portage_const.EPREFIX, "etc")]]
                                self.mygcfg   = stack_dicts(mygcfg_dlists, incrementals=portage_const.INCREMENTALS, ignore_none=1)
 
                                if self.mygcfg is None:
@@ -1166,7 +1166,7 @@ class config:
                        del blacklisted, cfg
 
                        env_d = getconfig(
-                               os.path.join(target_root, portage_const.EPREFIX, "etc", "profile.env"), expand=False)
+                               os.path.join(target_root + portage_const.EPREFIX, "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)
@@ -1370,7 +1370,7 @@ class config:
        def _init_dirs(self):
                """Create tmp, var/tmp and var/lib/portage (relative to $ROOT)."""
 
-               if not os.access(self["ROOT"] + os.sep + portage_const.EPREFIX, os.W_OK):
+               if not os.access(self["ROOT"] + portage_const.EPREFIX, os.W_OK):
                        return
 
                dir_mode_map = {
@@ -1382,7 +1382,7 @@ class config:
 
                for mypath, (gid, mode, modemask) in dir_mode_map.iteritems():
                        try:
-                               mydir = os.path.join(self["ROOT"], self["EPREFIX"], mypath)
+                               mydir = os.path.join(self["ROOT"] + self["EPREFIX"], mypath)
                                portage_util.ensure_dirs(mydir, gid=gid, mode=mode, mask=modemask)
                        except portage_exception.PortageException, e:
                                writemsg("!!! Directory initialization failed: '%s'\n" % mydir,
@@ -2651,7 +2651,7 @@ def doebuild_environment(myebuild, mydo, myroot, mysettings, debug, use_cache, m
        mysettings["HOME"] = os.path.join(mysettings["PORTAGE_BUILDDIR"], "homedir")
        mysettings["WORKDIR"] = os.path.join(mysettings["PORTAGE_BUILDDIR"], "work")
        mysettings["EDEST"] = os.path.join(mysettings["PORTAGE_BUILDDIR"], "image") + os.sep
-       mysettings["D"] = os.path.join(mysettings["PORTAGE_BUILDDIR"], "image", mysettings["EPREFIX"]) + os.sep
+       mysettings["D"] = os.path.join(mysettings["PORTAGE_BUILDDIR"], "image" + mysettings["EPREFIX"]) + os.sep
        mysettings["T"] = os.path.join(mysettings["PORTAGE_BUILDDIR"], "temp")
 
        mysettings["PORTAGE_BASHRC"] = os.path.join(
@@ -2659,7 +2659,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, portage_const.EPREFIX, "usr/src/linux"))
+               mykv,err1=ExtractKernelVersion(os.path.join(myroot + portage_const.EPREFIX, "usr/src/linux"))
                if mykv:
                        # Regular source tree
                        mysettings["KV"]=mykv
@@ -5723,7 +5723,7 @@ class dblink:
 
                self.myroot=myroot
                protect_obj = portage_util.ConfigProtect(myroot
-                               + os.path.sep + portage_const.EPREFIX,
+                               + portage_const.EPREFIX,
                        mysettings.get("CONFIG_PROTECT","").split(),
                        mysettings.get("CONFIG_PROTECT_MASK","").split())
                self.updateprotect = protect_obj.updateprotect