LocationsManager._addProfile: realpath parents
authorZac Medico <zmedico@gentoo.org>
Thu, 27 Oct 2011 18:49:20 +0000 (11:49 -0700)
committerZac Medico <zmedico@gentoo.org>
Thu, 27 Oct 2011 18:49:20 +0000 (11:49 -0700)
If it seems that a parent may point outside of the current repo,
realpath it.

pym/portage/package/ebuild/_config/LocationsManager.py

index debabed2b2c7a9d715213b8f57bfb23e6b58acae..0ab0950efff14a3c3ad64ba2625040f9f37f291e 100644 (file)
@@ -108,6 +108,7 @@ class LocationsManager(object):
        def _addProfile(self, currentPath, known_repos):
                current_abs_path = os.path.abspath(currentPath)
                allow_directories = True
+               repo_loc = None
                compat_mode = False
                intersecting_repos = [x for x in known_repos if current_abs_path.startswith(x[0])]
                if intersecting_repos:
@@ -158,8 +159,16 @@ class LocationsManager(object):
                                raise ParseError(
                                        _("Empty parent file: '%s'") % parentsFile)
                        for parentPath in parents:
+                               abs_parent = parentPath[:1] == os.sep
                                parentPath = normalize_path(os.path.join(
                                        currentPath, parentPath))
+
+                               if abs_parent or repo_loc is None or \
+                                       not parentPath.startswith(repo_loc):
+                                       # It seems that this parent may point outside
+                                       # of the current repo, so realpath it.
+                                       parentPath = os.path.realpath(parentPath)
+
                                if os.path.exists(parentPath):
                                        self._addProfile(parentPath, known_repos)
                                else: