Add support for repos.conf 'aliases' attribute which allows alias
authorZac Medico <zmedico@gentoo.org>
Thu, 16 Apr 2009 22:12:39 +0000 (22:12 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 16 Apr 2009 22:12:39 +0000 (22:12 -0000)
substitution in metadata/layout.conf repository references.

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

man/portage.5
pym/portage/__init__.py
pym/portage/dbapi/porttree.py

index 3a548c0f560c48f4555a983a82a6c92df3333ad6..0ac8be92f9ce2fa2efb28cc67eb75eca146e2e50 100644 (file)
@@ -559,18 +559,21 @@ performance issues under some circumstances (see \fBbug #124041\fR).
 
 .I Example:
 .nf
+[DEFAULT]
 # make all repositories inherit eclasses from the java\-overlay and
 # java\-experimental repositories, with eclasses from java\-experimental
 # taking precedence over those from java\-overlay
-[DEFAULT]
 eclass\-overrides = java\-overlay java\-experimental
 
-# disable all eclass overrides for ebuilds from the gentoo repository
 [gentoo]
+# disable all eclass overrides for ebuilds from the gentoo repository
 eclass\-overrides =
+# when processing metadata/layout.conf from other repositories, substitute
+# 'gentoo' in place of references to repositories named 'foo' and 'bar'
+aliases = foo bar
 
-# override the metadata/layout.conf masters setting from the kde-testing repo
 [kde-testing]
+# override the metadata/layout.conf masters setting from the kde-testing repo
 masters = gentoo kde
 .fi
 .RE
index 6fea2b82bd1a72a25a4dab398c1d5972a1c96d6a..d92330613f768a833f69332e3ecec788abddb931 100644 (file)
@@ -1001,10 +1001,15 @@ def _lazy_iuse_regex(iuse_implicit):
        return regex
 
 class _local_repo_config(object):
-       __slots__ = ('eclass_overrides', 'masters', 'name',)
+       __slots__ = ('aliases', 'eclass_overrides', 'masters', 'name',)
        def __init__(self, name, repo_opts):
                self.name = name
 
+               aliases = repo_opts.get('aliases')
+               if aliases is not None:
+                       aliases = tuple(aliases.split())
+               self.aliases = aliases
+
                eclass_overrides = repo_opts.get('eclass-overrides')
                if eclass_overrides is not None:
                        eclass_overrides = tuple(eclass_overrides.split())
index 246a0d6f1ddbfe3654e08b100c73f91446e47b5f..c07cf4ff264b2617a4531c51c2aeaf3d560c6545 100644 (file)
@@ -200,8 +200,23 @@ class portdbapi(dbapi):
                eclass_dbs = {porttree_root : self.eclassdb}
                local_repo_configs = self.mysettings._local_repo_configs
                default_loc_repo_config = None
+               repo_aliases = {}
                if local_repo_configs is not None:
                        default_loc_repo_config = local_repo_configs.get('DEFAULT')
+                       for repo_name, loc_repo_conf in local_repo_configs.iteritems():
+                               if loc_repo_conf.aliases is not None:
+                                       for alias in loc_repo_conf.aliases:
+                                               overridden_alias = repo_aliases.get(alias)
+                                               if overridden_alias is not None:
+                                                       writemsg_level(("!!! Alias '%s' " + \
+                                                               "created for '%s' overrides " + \
+                                                               "'%s' alias in " + \
+                                                               "'%s'\n") % (alias, repo_name,
+                                                               overridden_alias,
+                                                               self.mysettings._local_repo_conf_path),
+                                                               level=logging.WARNING, noiselevel=-1)
+                                               repo_aliases[alias] = repo_name
+
                for path in self.porttrees:
                        if path in self._repo_info:
                                continue
@@ -228,6 +243,7 @@ class portdbapi(dbapi):
                                masters = layout_data.get('masters', '').split()
 
                        for master_name in masters:
+                               master_name = repo_aliases.get(master_name, master_name)
                                master_path = self.treemap.get(master_name)
                                if master_path is None:
                                        writemsg_level(("Unavailable repository '%s' " + \