reposyntax: Handle missing profiles/repo_name by setting repo_name to x-$(basename...
authorSebastian Luther <SebastianLuther@gmx.de>
Wed, 22 Sep 2010 09:50:28 +0000 (11:50 +0200)
committerZac Medico <zmedico@gentoo.org>
Mon, 27 Sep 2010 06:50:14 +0000 (23:50 -0700)
pym/_emerge/main.py
pym/portage/dbapi/porttree.py

index 17f83672c12e2ba9dfc2859b6b970ef37b54875d..48b0955d051f76533c9bb85b93fe923e868684ff 100644 (file)
@@ -1172,13 +1172,11 @@ def expand_set_arguments(myfiles, myaction, root_config):
 
 def repo_name_check(trees):
        missing_repo_names = set()
-       for root, root_trees in trees.items():
-               if "porttree" in root_trees:
-                       portdb = root_trees["porttree"].dbapi
-                       missing_repo_names.update(portdb.porttrees)
-                       repos = portdb.getRepositories()
-                       for r in repos:
-                               missing_repo_names.discard(portdb.getRepositoryPath(r))
+       for root_trees in trees.values():
+               porttree = root_trees.get("porttree")
+               if porttree:
+                       portdb = porttree.dbapi
+                       missing_repo_names.update(portdb.getMissingRepoNames())
                        if portdb.porttree_root in missing_repo_names and \
                                not os.path.exists(os.path.join(
                                portdb.porttree_root, "profiles")):
@@ -1197,6 +1195,7 @@ def repo_name_check(trees):
                msg.extend(textwrap.wrap("NOTE: Each repo_name entry " + \
                        "should be a plain text file containing a unique " + \
                        "name for the repository on the first line.", 70))
+               msg.append("\n")
                writemsg_level("".join("%s\n" % l for l in msg),
                        level=logging.WARNING, noiselevel=-1)
 
@@ -1219,7 +1218,7 @@ def repo_name_duplicate_check(trees):
                msg.append('  profiles/repo_name entries:')
                msg.append('')
                for k in sorted(ignored_repos):
-                       msg.append('  %s overrides' % (k,))
+                       msg.append('  %s overrides' % ", ".join(k))
                        for path in ignored_repos[k]:
                                msg.append('    %s' % (path,))
                        msg.append('')
@@ -1228,6 +1227,7 @@ def repo_name_duplicate_check(trees):
                        "to avoid having duplicates ignored. " + \
                        "Set PORTAGE_REPO_DUPLICATE_WARN=\"0\" in " + \
                        "/etc/make.conf if you would like to disable this warning."))
+               msg.append("\n")
                writemsg_level(''.join('%s\n' % l for l in msg),
                        level=logging.WARNING, noiselevel=-1)
 
index 44dfa250390d5466bd570fb81255c867e9641b10..065c57b42f0a37d7c5a8f5f38c85479d17256c49 100644 (file)
@@ -114,6 +114,8 @@ class portdbapi(dbapi):
                repository_map = {}
                self.treemap = treemap
                self._repository_map = repository_map
+               #Keep track of repos that lack profiles/repo_name
+               self._missing_repo_names = set()
                identically_named_paths = {}
                for path in porttrees:
                        if path in repository_map:
@@ -129,19 +131,22 @@ class portdbapi(dbapi):
                                # warn about missing repo_name at some other time, since we
                                # don't want to see a warning every time the portage module is
                                # imported.
-                               pass
-                       else:
-                               identically_named_path = treemap.get(repo_name)
-                               if identically_named_path is not None:
-                                       # The earlier one is discarded.
-                                       del repository_map[identically_named_path]
-                                       identically_named_paths[identically_named_path] = repo_name
-                                       if identically_named_path == porttrees[0]:
-                                               # Found another repo with the same name as
-                                               # $PORTDIR, so update porttrees[0] to match.
-                                               porttrees[0] = path
-                               treemap[repo_name] = path
-                               repository_map[path] = repo_name
+                               self._missing_repo_names.add(path)
+                               repo_name = "x-" + os.path.basename(path)
+
+                       identically_named_path = treemap.get(repo_name)
+                       if identically_named_path is not None:
+                               # The earlier one is discarded.
+                               del repository_map[identically_named_path]
+                               identically_named_paths[identically_named_path] = repo_name
+                               if identically_named_path == porttrees[0]:
+                                       # Found another repo with the same name as
+                                       # $PORTDIR, so update porttrees[0] to match.
+                                       porttrees[0] = path
+                       treemap[repo_name] = path
+                       repository_map[path] = repo_name
+
+               self._missing_repo_names = frozenset(self._missing_repo_names)
 
                # Ensure that each repo_name is unique. Later paths override
                # earlier ones that correspond to the same name.
@@ -393,6 +398,12 @@ class portdbapi(dbapi):
                """
                return self._ordered_repo_name_list
 
+       def getMissingRepoNames(self):
+               """
+               Returns a list of repository paths that lack profiles/repo_name.
+               """
+               return self._missing_repo_names
+
        def findname2(self, mycpv, mytree=None, myrepo = None):
                """ 
                Returns the location of the CPV, and what overlay it was in.