Remove leading slash from appropriate paths inside portage.const, so that
authorZac Medico <zmedico@gentoo.org>
Sun, 12 Jul 2009 20:45:53 +0000 (20:45 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 12 Jul 2009 20:45:53 +0000 (20:45 -0000)
lstrip(os.sep) is not needed for os.path.join() calls. Thanks to Fabian
Groffen <grobian@g.o> for this patch.

svn path=/main/trunk/; revision=13821

pym/_emerge/actions.py
pym/portage/__init__.py
pym/portage/const.py
pym/portage/output.py
pym/portage/sets/__init__.py
pym/portage/sets/files.py
pym/portage/update.py

index f7ec0a15bd9ae4d74c6ae4fc7f2be73b0a164e8f..0a48271c5941a758031ccdf3b7a90dcb672eeb15 100644 (file)
@@ -2203,12 +2203,13 @@ def action_sync(settings, trees, mtimedb, myopts, myaction):
        chk_updated_cfg_files("/", settings.get("CONFIG_PROTECT","").split())
 
        if myaction != "metadata":
-               if os.access(portage.USER_CONFIG_PATH + "/bin/post_sync", os.X_OK):
+               postsync = os.path.join(settings["PORTAGE_CONFIGROOT"],
+                       portage.USER_CONFIG_PATH, "bin", "post_sync")
+               if os.access(postsync, os.X_OK):
                        retval = portage.process.spawn(
-                               [os.path.join(portage.USER_CONFIG_PATH, "bin", "post_sync"),
-                               dosyncuri], env=settings.environ())
+                               [postsync, dosyncuri], env=settings.environ())
                        if retval != os.EX_OK:
-                               print red(" * ")+bold("spawn failed of "+ portage.USER_CONFIG_PATH + "/bin/post_sync")
+                               print red(" * ") + bold("spawn failed of " + postsync)
 
        if(mybestpv != mypvs) and not "--quiet" in myopts:
                print
index 5b74e1797c3cb6fb495d446bc49444ea3a527963..4dc62fa5a4f7bb973e16770ee1a161c09da597b0 100644 (file)
@@ -1309,7 +1309,7 @@ class config(object):
 
                        if not config_profile_path:
                                config_profile_path = \
-                                       os.path.join(config_root, PROFILE_PATH.lstrip(os.path.sep))
+                                       os.path.join(config_root, PROFILE_PATH)
                                if os.path.isdir(config_profile_path):
                                        self.profile_path = config_profile_path
                                else:
@@ -1325,7 +1325,7 @@ class config(object):
                        self.module_priority    = ["user","default"]
                        self.modules            = {}
                        self.modules["user"] = getconfig(
-                               os.path.join(config_root, MODULES_FILE_PATH.lstrip(os.path.sep)))
+                               os.path.join(config_root, MODULES_FILE_PATH))
                        if self.modules["user"] is None:
                                self.modules["user"] = {}
                        self.modules["default"] = {
@@ -1389,7 +1389,7 @@ class config(object):
                                        self.profiles = []
                        if local_config and self.profiles:
                                custom_prof = os.path.join(
-                                       config_root, CUSTOM_PROFILE_PATH.lstrip(os.path.sep))
+                                       config_root, CUSTOM_PROFILE_PATH)
                                if os.path.exists(custom_prof):
                                        self.user_profile_dir = custom_prof
                                        self.profiles.append(custom_prof)
@@ -1465,7 +1465,7 @@ class config(object):
                        del rawpuseforce
 
                        make_conf = getconfig(
-                               os.path.join(config_root, MAKE_CONF_FILE.lstrip(os.path.sep)),
+                               os.path.join(config_root, MAKE_CONF_FILE),
                                tolerant=tolerant, allow_sourcing=True)
                        if make_conf is None:
                                make_conf = {}
@@ -1561,7 +1561,7 @@ class config(object):
                        self.configdict["defaults"]=self.configlist[-1]
 
                        self.mygcfg = getconfig(
-                               os.path.join(config_root, MAKE_CONF_FILE.lstrip(os.path.sep)),
+                               os.path.join(config_root, MAKE_CONF_FILE),
                                tolerant=tolerant, allow_sourcing=True, expand=expand_map)
                        if self.mygcfg is None:
                                self.mygcfg = {}
@@ -1610,8 +1610,7 @@ class config(object):
                        self.pkeywordsdict = {}
                        self._plicensedict = {}
                        self.punmaskdict = {}
-                       abs_user_config = os.path.join(config_root,
-                               USER_CONFIG_PATH.lstrip(os.path.sep))
+                       abs_user_config = os.path.join(config_root, USER_CONFIG_PATH)
 
                        # locations for "categories" and "arch.list" files
                        locations = [os.path.join(self["PORTDIR"], "profiles")]
@@ -1838,7 +1837,7 @@ class config(object):
                                ("sandbox" in self.features or "usersandbox" in self.features):
                                if self.profile_path is not None and \
                                        os.path.realpath(self.profile_path) == \
-                                       os.path.realpath(PROFILE_PATH):
+                                       os.path.realpath(os.path.join(config_root, PROFILE_PATH)):
                                        """ Don't show this warning when running repoman and the
                                        sandbox feature came from a profile that doesn't belong to
                                        the user."""
@@ -1960,7 +1959,7 @@ class config(object):
                                                noiselevel=-1)
 
                abs_profile_path = os.path.join(self["PORTAGE_CONFIGROOT"],
-                       PROFILE_PATH.lstrip(os.path.sep))
+                       PROFILE_PATH)
                if not self.profile_path or (not os.path.islink(abs_profile_path) and \
                        not os.path.exists(os.path.join(abs_profile_path, "parent")) and \
                        os.path.exists(os.path.join(self["PORTDIR"], "profiles"))):
@@ -1970,7 +1969,7 @@ class config(object):
                        writemsg("!!! (You can safely ignore this message when syncing. It's harmless.)\n\n\n")
 
                abs_user_virtuals = os.path.join(self["PORTAGE_CONFIGROOT"],
-                       USER_VIRTUALS_FILE.lstrip(os.path.sep))
+                       USER_VIRTUALS_FILE)
                if os.path.exists(abs_user_virtuals):
                        writemsg("\n!!! /etc/portage/virtuals is deprecated in favor of\n")
                        writemsg("!!! /etc/portage/profile/virtuals. Please move it to\n")
@@ -3781,7 +3780,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
        check_config_instance(mysettings)
 
        custommirrors = grabdict(os.path.join(mysettings["PORTAGE_CONFIGROOT"],
-               CUSTOM_MIRRORS_FILE.lstrip(os.path.sep)), recursive=1)
+               CUSTOM_MIRRORS_FILE), recursive=1)
 
        mymirrors=[]
 
@@ -5430,7 +5429,7 @@ def doebuild_environment(myebuild, mydo, myroot, mysettings, debug, use_cache, m
        mysettings["T"] = os.path.join(mysettings["PORTAGE_BUILDDIR"], "temp")
 
        mysettings["PORTAGE_BASHRC"] = os.path.join(
-               mysettings["PORTAGE_CONFIGROOT"], EBUILD_SH_ENV_FILE.lstrip(os.path.sep))
+               mysettings["PORTAGE_CONFIGROOT"], EBUILD_SH_ENV_FILE)
        mysettings["EBUILD_EXIT_STATUS_FILE"] = os.path.join(
                mysettings["PORTAGE_BUILDDIR"], ".exit_status")
 
@@ -7527,7 +7526,7 @@ def getmaskingreason(mycpv, metadata=None, settings=None, portdb=None, return_lo
                if os.path.isdir(profdir):
                        locations.append(profdir)
        locations.append(os.path.join(settings["PORTAGE_CONFIGROOT"],
-               USER_CONFIG_PATH.lstrip(os.path.sep)))
+               USER_CONFIG_PATH))
        locations.reverse()
        pmasklists = [(x, grablines(os.path.join(x, "package.mask"), recursive=1)) for x in locations]
 
@@ -8404,9 +8403,9 @@ def init_legacy_globals():
        selinux_enabled   = settings.selinux_enabled()
        thirdpartymirrors = settings.thirdpartymirrors()
        usedefaults       = settings.use_defs
-       profiledir  = None
-       if os.path.isdir(PROFILE_PATH):
-               profiledir = PROFILE_PATH
+       profiledir  = os.path.join(settings["PORTAGE_CONFIGROOT"], PROFILE_PATH)
+       if not os.path.isdir(profiledir):
+               profiledir = None
        def flushmtimedb(record):
                writemsg("portage.flushmtimedb() is DEPRECATED\n")
        # ========================================================================
index 155279c057c921c063398cab0aeab66cc3293c3d..1b838e62f7f7553ff2d518fdb52355bb366b9715 100644 (file)
@@ -15,7 +15,7 @@ PRIVATE_PATH            = "var/lib/portage"
 CACHE_PATH              = "/var/cache/edb"
 DEPCACHE_PATH           = CACHE_PATH+"/dep"
 
-USER_CONFIG_PATH        = "/etc/portage"
+USER_CONFIG_PATH        = "etc/portage"
 MODULES_FILE_PATH       = USER_CONFIG_PATH+"/modules"
 CUSTOM_PROFILE_PATH     = USER_CONFIG_PATH+"/profile"
 GLOBAL_CONFIG_PATH      = "/usr/share/portage/config"
@@ -26,7 +26,7 @@ PORTAGE_BIN_PATH        = PORTAGE_BASE_PATH+"/bin"
 PORTAGE_PYM_PATH        = PORTAGE_BASE_PATH+"/pym"
 PORTAGE_PACKAGE_ATOM    = "sys-apps/portage"
 NEWS_LIB_PATH           = "/var/lib/gentoo"
-PROFILE_PATH            = "/etc/make.profile"
+PROFILE_PATH            = "etc/make.profile"
 LOCALE_DATA_PATH        = PORTAGE_BASE_PATH+"/locale"
 
 EBUILD_SH_BINARY        = PORTAGE_BIN_PATH+"/ebuild.sh"
@@ -38,7 +38,7 @@ MOVE_BINARY             = "/bin/mv"
 PRELINK_BINARY          = "/usr/sbin/prelink"
 
 WORLD_FILE              = PRIVATE_PATH + "/world"
-MAKE_CONF_FILE          = "/etc/make.conf"
+MAKE_CONF_FILE          = "etc/make.conf"
 MAKE_DEFAULTS_FILE      = PROFILE_PATH + "/make.defaults"
 DEPRECATED_PROFILE_FILE = PROFILE_PATH+"/deprecated"
 USER_VIRTUALS_FILE      = USER_CONFIG_PATH+"/virtuals"
index ee792280a679b7cfc3a97e7855b46a4539885d98..4c533c427a462178d163f306fa08d4b57342ec80 100644 (file)
@@ -150,7 +150,13 @@ def _parse_color_map(onerror=None):
        @rtype: dict
        @return: a dictionary mapping color classes to color codes
        """
-       myfile = COLOR_MAP_FILE
+       # FIXME: use config_root iso / (breaks Prefix)
+       # We can use ObjectProxy to implement lazy initialization of
+       # codes and _styles, and add an init(config_root="/") function
+       # that can be called in order adjust the location that color.map
+       # is read from.
+       global codes, _styles
+       myfile = os.path.join('/', COLOR_MAP_FILE)
        ansi_code_pattern = re.compile("^[0-9;]*m$") 
        quotes = '\'"'
        def strip_quotes(token):
index 80aa608f68153a7557da9e9333060b378547b0f1..2d85007ec03a8c084b9813daa766fcf99f073429 100644 (file)
@@ -192,7 +192,7 @@ def load_default_config(settings, trees):
        setconfigpaths.append(os.path.join(settings["PORTDIR"], "sets.conf"))
        setconfigpaths += [os.path.join(x, "sets.conf") for x in settings["PORTDIR_OVERLAY"].split()]
        setconfigpaths.append(os.path.join(settings["PORTAGE_CONFIGROOT"],
-               USER_CONFIG_PATH.lstrip(os.path.sep), "sets.conf"))
+               USER_CONFIG_PATH, "sets.conf"))
        return SetConfig(setconfigpaths, settings, trees)
 
 # adhoc test code
index 9ebff10f25b7127a0016f19d0e7190cd6ffb76a9..aa4d6aac90ed386ca15e2ab923990f99c314f78b 100644 (file)
@@ -111,7 +111,9 @@ class StaticFileSet(EditablePackageSet):
        
        def multiBuilder(self, options, settings, trees):
                rValue = {}
-               directory = options.get("directory", os.path.join(settings["PORTAGE_CONFIGROOT"], USER_CONFIG_PATH.lstrip(os.sep), "sets"))
+               directory = options.get("directory",
+                       os.path.join(settings["PORTAGE_CONFIGROOT"],
+                       USER_CONFIG_PATH, "sets"))
                name_pattern = options.get("name_pattern", "${name}")
                if not "$name" in name_pattern and not "${name}" in name_pattern:
                        raise SetConfigError(_("name_pattern doesn't include ${name} placeholder"))
@@ -163,7 +165,8 @@ class ConfigFileSet(PackageSet):
        
        def multiBuilder(self, options, settings, trees):
                rValue = {}
-               directory = options.get("directory", os.path.join(settings["PORTAGE_CONFIGROOT"], USER_CONFIG_PATH.lstrip(os.sep)))
+               directory = options.get("directory",
+                       os.path.join(settings["PORTAGE_CONFIGROOT"], USER_CONFIG_PATH))
                name_pattern = options.get("name_pattern", "sets/package_$suffix")
                if not "$suffix" in name_pattern and not "${suffix}" in name_pattern:
                        raise SetConfigError(_("name_pattern doesn't include $suffix placeholder"))
index 70ff686643f57404e64bb39a3c765d483e86b28e..c7001803ac7995d35f4fdfb67c476d94963975a3 100644 (file)
@@ -152,8 +152,7 @@ def update_config_files(config_root, protect, protect_mask, update_iter):
        myxfiles = ["package.mask", "package.unmask", \
                "package.keywords", "package.use"]
        myxfiles += [os.path.join("profile", x) for x in myxfiles]
-       abs_user_config = os.path.join(config_root,
-               USER_CONFIG_PATH.lstrip(os.path.sep))
+       abs_user_config = os.path.join(config_root, USER_CONFIG_PATH)
        recursivefiles = []
        for x in myxfiles:
                config_file = os.path.join(abs_user_config, x)