From a1e667700787d70c2b227db9db3c50d6fcaed5c1 Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Sat, 14 Jul 2007 09:32:14 +0000 Subject: [PATCH] Merged from trunk 7246:7251 +------------------------------------------------------------------------+ | 7247 | Save the repo name along with the other metadata inside | | zmedico | dyn_compile() so that it's saved inside binary packages for | | | when they are finally merged. | |---------+--------------------------------------------------------------| | 7249 | Misc fixes for verbose repo output: - Support binary | | zmedico | packages by using the 'repository' metadata that's stored in | | | the package. - Support PORTAGE_CONFIGROOT, showing repos | | | from both configs if necessary. - Dynamic allocation of repo | | | indexes so only relevant repos are shown. | |---------+--------------------------------------------------------------| | 7250 | Fix it so that the 'repository could not be determined' | | zmedico | message is shown when appropriate (issue with variable | | | scope). | |---------+--------------------------------------------------------------| | 7251 | PDEPEND is now installed as soon as possible so that it | | zmedico | behaves more like RDEPEND. | +------------------------------------------------------------------------+ svn path=/main/branches/prefix/; revision=7253 --- NEWS | 3 + bin/ebuild.sh | 1 + pym/emerge/__init__.py | 123 ++++++++++++++++++++++------------- pym/portage/__init__.py | 10 +++ pym/portage/dbapi/vartree.py | 15 ----- 5 files changed, 90 insertions(+), 62 deletions(-) diff --git a/NEWS b/NEWS index 113be1719..c79f69c63 100644 --- a/NEWS +++ b/NEWS @@ -26,6 +26,9 @@ portage-2.1.3 * The merge process preserves the modification timestamp of files that it installs. The unmerge process will not uninstall files that are claimed by another package in the same slot. +* PDEPEND is now installed as soon as possible so that it behaves more like + RDEPEND. This makes PDEPEND more useful for breaking the dependency cycles + that are sometimes triggered by RDEPEND and DEPEND. portage-2.1.2 ------------- diff --git a/bin/ebuild.sh b/bin/ebuild.sh index edf130f40..ec930e4a6 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -946,6 +946,7 @@ dyn_compile() { bzip2 -f9 environment cp "${EBUILD}" "${PF}.ebuild" + [ -n "${PORTAGE_REPO_NAME}" ] && echo "${PORTAGE_REPO_NAME}" > repository if hasq nostrip ${FEATURES} ${RESTRICT} || hasq strip ${RESTRICT} then touch DEBUGBUILD diff --git a/pym/emerge/__init__.py b/pym/emerge/__init__.py index ebf69e97b..65c31f936 100644 --- a/pym/emerge/__init__.py +++ b/pym/emerge/__init__.py @@ -2652,12 +2652,41 @@ class depgraph(object): ret = '%s="%s" ' % (name, ret) return ret - if verbosity == 3: - # FIXME: account for the possibility of different overlays in - # /etc/make.conf vs. ${PORTAGE_CONFIGROOT}/etc/make.conf - overlays = self.settings["PORTDIR_OVERLAY"].split() - overlays_real = [os.path.realpath(t) \ - for t in self.settings["PORTDIR_OVERLAY"].split()] + # Get repo data for verbose repo display. + repo_paths = set() + for root_config in self.roots.itervalues(): + portdir = root_config.settings.get("PORTDIR") + if portdir: + repo_paths.add(portdir) + overlays = root_config.settings.get("PORTDIR_OVERLAY") + if overlays: + repo_paths.update(overlays.split()) + repo_paths = list(repo_paths) + repo_paths.sort() + repo_paths_real = [ os.path.realpath(repo_path) \ + for repo_path in repo_paths ] + # Track which ones are show so the list can be pruned to save space. + shown_repos = {} + def repo_str(portdb, repo_name): + repo_path_real = portdb.getRepositoryPath(repo_name) + real_index = -1 + if repo_path_real: + try: + real_index = repo_paths_real.index(repo_path_real) + except ValueError: + pass + if real_index == -1: + s = "?" + repo_str.unknown_repo = True + else: + repo_path = repo_paths[real_index] + index = shown_repos.get(repo_path) + if index is None: + index = len(shown_repos) + shown_repos[repo_path] = index + s = str(index) + return s + repo_str.unknown_repo = False tree_nodes = [] display_list = [] @@ -2746,7 +2775,6 @@ class depgraph(object): from portage import flatten from portage.dep import use_reduce, paren_reduce - display_overlays=False # files to fetch list - avoids counting a same file twice # in size display (verbose mode) myfetchlist=[] @@ -2797,6 +2825,20 @@ class depgraph(object): mydbapi = self.mydbapi[myroot] # contains cached metadata metadata = dict(izip(self._mydbapi_keys, mydbapi.aux_get(pkg_key, self._mydbapi_keys))) + ebuild_path = None + repo_name = metadata["repository"] + if pkg_type == "ebuild": + ebuild_path = portdb.findname(pkg_key) + if not ebuild_path: # shouldn't happen + raise portage.exception.PackageNotFound(pkg_key) + repo_path = os.path.sep.join( + ebuild_path.split(os.path.sep)[:-3]) + for repo_name in portdb.getRepositories(): + if portdb.getRepositoryPath(repo_name) == repo_path: + repo_name = repo_name + break + else: + repo_name = None if pkg_key not in self.useFlags[myroot]: """If this is a --resume then the USE flags need to be fetched from the appropriate locations here.""" @@ -2997,41 +3039,26 @@ class depgraph(object): verboseadd+=format_size(mysize)+" " # overlay verbose - # XXX: Invalid binaries have caused tracebacks here. 'if file_name' - # x = ['binary', '/', 'sys-apps/pcmcia-cs-3.2.7.2.6', 'merge'] - file_name = portdb.findname(pkg_key) - if file_name: # It might not exist in the tree - newrepo = pkgsettings["PORTDIR"] - newrepoindex = "0" - if self.trees[x[1]]["vartree"].dbapi.cpv_exists(pkg): - oldrepo = self.trees[x[1]]["vartree"].dbapi.aux_get(pkg, ["repository"])[0] - else: - oldrepo = "" - if oldrepo != "": - oldrepo = portdb.getRepositoryPath(oldrepo) - dir_name=os.path.abspath(os.path.dirname(file_name)+"/../..") - if (overlays_real.count(dir_name) > 0): - newrepoindex = overlays_real.index(os.path.normpath(dir_name)) - newrepo = overlays_real[newrepoindex] - newrepoindex += 1 - - # assing lookup indexes - if not oldrepo: - oldrepoindex = "?" - elif oldrepo == os.path.realpath(pkgsettings["PORTDIR"]): - oldrepoindex = "0" - else: - oldrepoindex = str(overlays_real.index(os.path.normpath(oldrepo)) + 1) - if oldrepoindex == newrepoindex \ - or not self.trees[x[1]]["vartree"].dbapi.cpv_exists(pkg): - repoadd = newrepoindex - else: - repoadd = "%s=>%s" % (oldrepoindex, newrepoindex) - - verboseadd+=teal("[%s]" % repoadd)+" " - display_overlays=True + # assign index for a previous version in the same slot + has_previous = False + repo_name_prev = None + slot_atom = "%s:%s" % (portage.dep_getkey(pkg_key), + metadata["SLOT"]) + slot_matches = vardb.match(slot_atom) + if slot_matches: + has_previous = True + repo_name_prev = vardb.aux_get(slot_matches[0], + ["repository"])[0] + + # now use the data to generate output + repoadd = None + if pkg_status == "nomerge" or not has_previous: + repoadd = repo_str(portdb, repo_name) else: - verboseadd += "[No ebuild?]" + repoadd = "%s=>%s" % (repo_str(portdb, repo_name_prev), + repo_str(portdb, repo_name)) + if repoadd: + verboseadd += teal("[%s]" % repoadd) xs = list(portage.pkgsplit(x[2])) if xs[2]=="r0": @@ -3169,13 +3196,15 @@ class depgraph(object): if verbosity == 3: print print counters - if overlays and display_overlays: + if shown_repos or repo_str.unknown_repo: print "Portage tree and overlays:" - y=0 - print " "+teal("[0]"), self.settings["PORTDIR"] - for x in overlays: - y=y+1 - print " "+teal("["+str(y)+"]"),x + show_repo_paths = list(shown_repos) + for repo_path, repo_index in shown_repos.iteritems(): + show_repo_paths[repo_index] = repo_path + if show_repo_paths: + for index, repo_path in enumerate(show_repo_paths): + print " "+teal("["+str(index)+"]"),repo_path + if repo_str.unknown_repo: print " "+teal("[?]"), "indicates that the source repository could not be determined" if "--changelog" in self.myopts: diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index a6a39c895..34d723b11 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -3290,6 +3290,16 @@ def doebuild_environment(myebuild, mydo, myroot, mysettings, debug, use_cache, m mysettings["EROOT"] = normalize_path(myroot + mysettings["EPREFIX"]) + os.sep mysettings["STARTDIR"] = getcwd() + mysettings["PORTAGE_REPO_NAME"] = "" + # bindbapi has no getRepositories() method + if mydbapi and hasattr(mydbapi, "getRepositories"): + # do we have a origin repository name for the current package + repopath = os.sep.join(pkg_dir.split(os.path.sep)[:-2]) + for reponame in mydbapi.getRepositories(): + if mydbapi.getRepositoryPath(reponame) == repopath: + mysettings["PORTAGE_REPO_NAME"] = reponame + break + mysettings["EBUILD"] = ebuild_path mysettings["O"] = pkg_dir mysettings.configdict["pkg"]["CATEGORY"] = cat diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index f90c970a6..aeb820610 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -1736,21 +1736,6 @@ class dblink(object): for x in listdir(inforoot): self.copyfile(inforoot+"/"+x) - # do we have a origin repository name for the current package - repopath = os.sep.join(self.settings["O"].split(os.sep)[:-2]) - # bindbapi has no getRepositories() method - if mydbapi and hasattr(mydbapi, "getRepositories"): - foundname = False - for reponame in mydbapi.getRepositories(): - if mydbapi.getRepositoryPath(reponame) == repopath: - fd = open(os.path.join(self.dbtmpdir, "repository"), "w") - fd.write(reponame+"\n") - fd.close() - foundname = True - break - if not foundname: - ewarn("Could not determine name of source repository at %s" % repopath, phase="preinst", key=self.mycpv) - # write local package counter for recording lcfile = open(os.path.join(self.dbtmpdir, "COUNTER"),"w") lcfile.write(str(counter)) -- 2.26.2