Kind of funny, but it saves a lot of bytes, and makes the stuff easier
authorFabian Groffen <grobian@gentoo.org>
Sat, 4 Nov 2006 17:32:27 +0000 (17:32 -0000)
committerFabian Groffen <grobian@gentoo.org>
Sat, 4 Nov 2006 17:32:27 +0000 (17:32 -0000)
readable.  Looks like importing EPREFIX from portage_const makes it
available on global scope, like in Java it would be.  No real change,
just conceptual from portage_const.EPREFIX to EPREFIX, which seems to
work fine so far.

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

pym/portage.py

index 6a822ba3d2f5de4f7863be1a8823f2cfb9211891..48df18b5707cb6af9ed597cd291f74fb1a787d58 100644 (file)
@@ -70,7 +70,7 @@ try:
          MOVE_BINARY, PRELINK_BINARY, WORLD_FILE, MAKE_CONF_FILE, MAKE_DEFAULTS_FILE, \
          DEPRECATED_PROFILE_FILE, USER_VIRTUALS_FILE, EBUILD_SH_ENV_FILE, \
          INVALID_ENV_FILE, CUSTOM_MIRRORS_FILE, CONFIG_MEMORY_FILE,\
-         INCREMENTALS, EAPI, MISC_SH_BINARY
+         INCREMENTALS, EAPI, MISC_SH_BINARY, EPREFIX
 
        from portage_data import ostype, lchown, userland, secpass, uid, wheelgid, \
                                 portage_uid, portage_gid, userpriv_groups
@@ -534,7 +534,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 + EPREFIX, "etc", "env.d")
        portage_util.ensure_dirs(envd_dir, mode=0755)
        fns = listdir(envd_dir, EmptyOnError=1)
        fns.sort()
@@ -605,7 +605,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 + EPREFIX, "etc", "ld.so.conf")
        try:
                myld = open(ldsoconf_path)
                myldlines=myld.readlines()
@@ -628,7 +628,7 @@ def env_update(makelinks=1, target_root=None, prev_mtimes=None, contents=None):
                #ld.so.conf needs updating and ldconfig needs to be run
                myfd = atomic_ofstream(ldsoconf_path)
                myfd.write("# ld.so.conf autogenerated by env-update; make all changes to\n")
-               myfd.write("# contents of "+portage_const.EPREFIX+"/etc/env.d directory\n")
+               myfd.write("# contents of "+EPREFIX+"/etc/env.d directory\n")
                for x in specials["LDPATH"]:
                        myfd.write(x+"\n")
                myfd.close()
@@ -637,11 +637,11 @@ 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 + 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")
+               newprelink.write("# contents of "+EPREFIX+"/etc/env.d directory\n")
 
-               for x in map(lambda x: os.path.join(portage_const.EPREFIX,x), ["bin","sbin","usr/bin","usr/sbin","lib","usr/lib"]):
+               for x in map(lambda x: os.path.join(EPREFIX,x), ["bin","sbin","usr/bin","usr/sbin","lib","usr/lib"]):
                        newprelink.write("-l "+x+"\n");
                for x in specials["LDPATH"]+specials["PATH"]+specials["PRELINK_PATH"]:
                        if not x:
@@ -666,7 +666,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 + EPREFIX, lib_dir.lstrip(os.sep))
                try:
                        newldpathtime = os.stat(x)[stat.ST_MTIME]
                        lib_dirs.add(normalize_path(x))
@@ -714,27 +714,27 @@ 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+portage_const.EPREFIX))
+                       writemsg(">>> Regenerating %s/etc/ld.so.cache...\n" % (target_root+EPREFIX))
                        if makelinks:
-                               commands.getstatusoutput("cd / ; "+portage_const.EPREFIX+"/sbin/ldconfig -r '%s'" % target_root)
+                               commands.getstatusoutput("cd / ; "+EPREFIX+"/sbin/ldconfig -r '%s'" % target_root)
                        else:
-                               commands.getstatusoutput("cd / ; "+portage_const.EPREFIX+"/sbin/ldconfig -X -r '%s'" % target_root)
+                               commands.getstatusoutput("cd / ; "+EPREFIX+"/sbin/ldconfig -X -r '%s'" % target_root)
                elif ostype in ("FreeBSD","DragonFly"):
-                       writemsg(">>> Regenerating %svar/run/ld-elf.so.hints...\n" % target_root+portage_const.EPREFIX+os.sep)
+                       writemsg(">>> Regenerating %svar/run/ld-elf.so.hints...\n" % target_root+EPREFIX+os.sep)
                        commands.getstatusoutput(
-                               "cd / ; "+portage_const.EPREFIX+"/sbin/ldconfig -elf -i -f '%s/var/run/ld-elf.so.hints' '%s/etc/ld.so.conf'" % \
-                               (target_root+portage_const.EPREFIX, target_root+portage_const.EPREFIX))
+                               "cd / ; "+EPREFIX+"/sbin/ldconfig -elf -i -f '%s/var/run/ld-elf.so.hints' '%s/etc/ld.so.conf'" % \
+                               (target_root+EPREFIX, target_root+EPREFIX))
 
        del specials["LDPATH"]
 
        penvnotice  = "# THIS FILE IS AUTOMATICALLY GENERATED BY env-update.\n"
        penvnotice += "# DO NOT EDIT THIS FILE. CHANGES TO STARTUP PROFILES\n"
        cenvnotice  = penvnotice[:]
-       penvnotice += "# GO INTO "+portage_const.EPREFIX+"/etc/profile NOT "+portage_const.EPREFIX+"/etc/profile.env\n\n"
-       cenvnotice += "# GO INTO "+portage_const.EPREFIX+"/etc/csh.cshrc NOT "+portage_const.EPREFIX+"/etc/csh.env\n\n"
+       penvnotice += "# GO INTO "+EPREFIX+"/etc/profile NOT "+EPREFIX+"/etc/profile.env\n\n"
+       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 + portage_const.EPREFIX, "etc", "profile.env"))
+       outfile = atomic_ofstream(os.path.join(target_root + EPREFIX, "etc", "profile.env"))
        outfile.write(penvnotice)
 
        env_keys = [ x for x in env if x != "LDPATH" ]
@@ -744,7 +744,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 + EPREFIX, "etc", "csh.env"))
        outfile.write(cenvnotice)
        for x in env_keys:
                outfile.write("setenv %s '%s'\n" % (x, env[x]))
@@ -931,7 +931,7 @@ class config:
 
                        for k, v in (("PORTAGE_CONFIGROOT", config_root),
                                ("ROOT", target_root)):
-                               v = v + portage_const.EPREFIX
+                               v = v + EPREFIX
                                if not os.path.isdir(v):
                                        writemsg("!!! Error: %s='%s' is not a directory. Please correct this.\n" % (k, v),
                                                noiselevel=-1)
@@ -1072,7 +1072,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 + EPREFIX, "etc")]]
                                self.mygcfg   = stack_dicts(mygcfg_dlists, incrementals=portage_const.INCREMENTALS, ignore_none=1)
 
                                if self.mygcfg is None:
@@ -1105,7 +1105,7 @@ class config:
                                        raise
                                except Exception, e:
                                        writemsg("!!! %s\n" % (e), noiselevel=-1)
-                                       writemsg("!!! 'rm -Rf %s/usr/portage/profiles; emerge sync' may fix this. If it does\n" % portage_const.EPREFIX,
+                                       writemsg("!!! 'rm -Rf %s/usr/portage/profiles; emerge sync' may fix this. If it does\n" % EPREFIX,
                                                noiselevel=-1)
                                        writemsg("!!! not then please report this to bugs.gentoo.org and, if possible, a dev\n",
                                                noiselevel=-1)
@@ -1161,7 +1161,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 + 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)
@@ -1382,7 +1382,7 @@ class config:
        def _init_dirs(self):
                """Create tmp, var/tmp and var/lib/portage (relative to $ROOT)."""
 
-               if not os.access(self["ROOT"] + portage_const.EPREFIX, os.W_OK):
+               if not os.access(self["ROOT"] + EPREFIX, os.W_OK):
                        return
 
                dir_mode_map = {
@@ -1395,7 +1395,7 @@ class config:
                for mypath, (gid, mode, modemask) in dir_mode_map.iteritems():
                        try:
                                mydir = normalize_path(
-                                               os.path.join(self["ROOT"] + portage_const.EPREFIX, mypath))
+                                               os.path.join(self["ROOT"] + 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,
@@ -1646,7 +1646,7 @@ class config:
                # We grab the latest profile.env here since it changes frequently.
                self.configdict["env.d"].clear()
                env_d = getconfig(
-                       os.path.join(self["ROOT"] + portage_const.EPREFIX, "etc", "profile.env"), expand=False)
+                       os.path.join(self["ROOT"] + EPREFIX, "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)
@@ -2654,7 +2654,7 @@ 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"]  = portage_const.EPREFIX.rstrip(os.sep)
+       mysettings["EPREFIX"]  = EPREFIX.rstrip(os.sep)
        mysettings["ROOT"]     = myroot
        mysettings["EROOT"]    = normalize_path(myroot + mysettings["EPREFIX"]) + os.sep
        mysettings["STARTDIR"] = getcwd()
@@ -2727,7 +2727,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 + EPREFIX, "usr/src/linux"))
                if mykv:
                        # Regular source tree
                        mysettings["KV"]=mykv
@@ -4633,7 +4633,7 @@ class vardbapi(dbapi):
 
        def counter_tick_core(self,myroot,incrementing=1,mycpv=None):
                "This method will grab the next COUNTER value and record it back to the global file.  Returns new counter value."
-               cpath=os.path.join(myroot+portage_const.EPREFIX, "var/cache/edb/counter")
+               cpath=os.path.join(myroot+EPREFIX, "var/cache/edb/counter")
                changed=0
                min_counter = 0
                if mycpv:
@@ -5989,7 +5989,7 @@ class dblink:
                        raise ValueError
 
                self.myroot=myroot
-               protect_obj = portage_util.ConfigProtect(myroot + portage_const.EPREFIX,
+               protect_obj = portage_util.ConfigProtect(myroot + EPREFIX,
                        mysettings.get("CONFIG_PROTECT","").split(),
                        mysettings.get("CONFIG_PROTECT_MASK","").split())
                self.updateprotect = protect_obj.updateprotect
@@ -6535,7 +6535,7 @@ class dblink:
 
                # we do a first merge; this will recurse through all files in our srcroot but also build up a
                # "second hand" of symlinks to merge later
-               if self.mergeme(srcroot,destroot,outfile,secondhand,portage_const.EPREFIX.lstrip(os.path.sep),cfgfiledict,mymtime):
+               if self.mergeme(srcroot,destroot,outfile,secondhand,EPREFIX.lstrip(os.path.sep),cfgfiledict,mymtime):
                        return 1
 
                # now, it's time for dealing our second hand; we'll loop until we can't merge anymore.  The rest are