When warning about 'missing repo_name', also give the exact path where the
authorZac Medico <zmedico@gentoo.org>
Tue, 18 Nov 2008 21:25:11 +0000 (21:25 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 18 Nov 2008 21:25:11 +0000 (21:25 -0000)
entry should exist, and explain that it should be a plain text file containing
a unique name of the first line. This should give the users enough information
to correct the problem without needing to seek help. (trunk r11993:11995)

svn path=/main/branches/2.1.6/; revision=11996

pym/_emerge/__init__.py

index 1b9e1858914d3e7840d997ab46c3f4192ee3522d..64ebb9359b8c5f6a1d69614f4644e82df0faa356 100644 (file)
@@ -13381,6 +13381,32 @@ def expand_set_arguments(myfiles, myaction, root_config):
 
        return (myfiles, os.EX_OK)
 
+def repo_name_check(trees):
+       missing_repo_names = set()
+       for root, root_trees in trees.iteritems():
+               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))
+
+       if missing_repo_names:
+               msg = []
+               msg.append("WARNING: One or more repositories " + \
+                       "have missing repo_name entries:")
+               msg.append("")
+               for p in missing_repo_names:
+                       msg.append("\t%s/profiles/repo_name" % (p,))
+               msg.append("")
+               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))
+               writemsg_level("".join("%s\n" % l for l in msg),
+                       level=logging.WARNING, noiselevel=-1)
+
+       return bool(missing_repo_names)
+
 def emerge_main():
        global portage  # NFC why this is necessary now - genone
        portage._disable_legacy_globals()
@@ -13441,21 +13467,7 @@ def emerge_main():
 
        if "--quiet" not in myopts:
                portage.deprecated_profile_check()
-               for root in trees:
-                       if "porttree" in trees[root]:
-                               db = trees[root]["porttree"].dbapi
-                               paths = (db.mysettings["PORTDIR"]+" "+db.mysettings["PORTDIR_OVERLAY"]).split()
-                               paths = [os.path.realpath(p) for p in paths]
-                               repos = db.getRepositories()
-                               for r in repos:
-                                       p = db.getRepositoryPath(r)
-                                       try:
-                                               paths.remove(p)
-                                       except ValueError:
-                                               pass
-                               for p in paths:
-                                       writemsg("WARNING: repository at %s is missing a repo_name entry\n" % p)
-                                       
+               repo_name_check(trees)
 
        eclasses_overridden = {}
        for mytrees in trees.itervalues():