repository/config: PORTDIR/overlay priority tweak
authorZac Medico <zmedico@gentoo.org>
Fri, 3 Jun 2011 00:36:33 +0000 (17:36 -0700)
committerZac Medico <zmedico@gentoo.org>
Fri, 3 Jun 2011 00:36:33 +0000 (17:36 -0700)
This ensures compatibility with previous portage versions for cases in
which the user has added PORTDIR to PORTDIR_OVERLAY as a means to modify its
priority relative to overlays when selecting ebuilds.

pym/portage/package/ebuild/config.py
pym/portage/repository/config.py

index d1842f134b3241d573101547d358f3b731bef26c..54ca8b33f6aae01b2aade406251659bddd90a570 100644 (file)
@@ -486,8 +486,8 @@ class config(object):
                        # repoman controls PORTDIR_OVERLAY via the environment, so no
                        # special cases are needed here.
                        portdir_overlay = list(self.repositories.repoUserLocationList())
-                       if self["PORTDIR"] in portdir_overlay:
-                               portdir_overlay.remove(self["PORTDIR"])
+                       if portdir_overlay and portdir_overlay[0] == self["PORTDIR"]:
+                               portdir_overlay = portdir_overlay[1:]
 
                        new_ov = []
                        if portdir_overlay:
index eb44b17f883b7156bd29917c7de3b04e046a5b09..c5b7790518392a0d0f59968cf5e00a7fabeb0416 100644 (file)
@@ -242,21 +242,25 @@ class RepoConfigLoader(object):
                                                        if old_location is not None and old_location != repo.location:
                                                                ignored_map.setdefault(repo.name, []).append(old_location)
                                                                ignored_location_map[old_location] = repo.name
+                                                               if old_location == portdir:
+                                                                       portdir = repo.user_location
                                                        prepos[repo.name].update(repo)
+                                                       repo = prepos[repo.name]
                                                else:
                                                        prepos[repo.name] = repo
 
-                                               repo = prepos[repo.name]
-                                               if repo.priority is None:
-                                                       if ov == portdir and portdir not in port_ov:
-                                                               repo.priority = -1000
-                                                       else:
-                                                               repo.priority = base_priority
-                                                               base_priority += 1
+                                               if ov == portdir and portdir not in port_ov:
+                                                       repo.priority = -1000
+                                               else:
+                                                       repo.priority = base_priority
+                                                       base_priority += 1
 
                                        else:
                                                writemsg(_("!!! Invalid PORTDIR_OVERLAY"
                                                        " (not a dir): '%s'\n") % ov, noiselevel=-1)
+
+                       return portdir
+
                def repo_priority(r):
                        """
                        Key funtion for comparing repositories by priority.
@@ -274,11 +278,15 @@ class RepoConfigLoader(object):
                ignored_location_map = {}
 
                portdir = settings.get('PORTDIR', '')
-               if portdir and portdir.strip():
-                       portdir = os.path.realpath(portdir)
                portdir_overlay = settings.get('PORTDIR_OVERLAY', '')
                parse(paths, prepos, ignored_map, ignored_location_map)
-               add_overlays(portdir, portdir_overlay, prepos, ignored_map, ignored_location_map)
+               # If PORTDIR_OVERLAY contains a repo with the same repo_name as
+               # PORTDIR, then PORTDIR is overridden.
+               portdir = add_overlays(portdir, portdir_overlay, prepos,
+                       ignored_map, ignored_location_map)
+               if portdir and portdir.strip():
+                       portdir = os.path.realpath(portdir)
+
                ignored_repos = tuple((repo_name, tuple(paths)) \
                        for repo_name, paths in ignored_map.items())