From a6d9d67e3ff100bc07cc77d5e7702983fa6122e0 Mon Sep 17 00:00:00 2001 From: Sebastian Luther Date: Wed, 22 Sep 2010 11:50:28 +0200 Subject: reposyntax: Handle missing profiles/repo_name by setting repo_name to x-$(basename $path) --- pym/_emerge/main.py | 16 ++++++++-------- pym/portage/dbapi/porttree.py | 37 ++++++++++++++++++++++++------------- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py index 17f83672c..48b0955d0 100644 --- a/pym/_emerge/main.py +++ b/pym/_emerge/main.py @@ -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) diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py index 44dfa2503..065c57b42 100644 --- a/pym/portage/dbapi/porttree.py +++ b/pym/portage/dbapi/porttree.py @@ -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. -- cgit v1.2.3-1-g7c22