if os.access(vdb_path, os.W_OK):
vdb_lock = portage_locks.lockdir(vdb_path)
mykeys = ["SLOT", "COUNTER", "PROVIDE", "USE", "IUSE",
- "RESTRICT", "DEPEND", "RDEPEND", "PDEPEND"]
+ "RESTRICT", "DEPEND", "RDEPEND", "PDEPEND", "repository"]
real_dbapi = real_vartree.dbapi
slot_counters = {}
for cpv in real_dbapi.cpv_all():
self._reinstall_nodes = {}
self.mydbapi = {}
self._mydbapi_keys = ["SLOT", "DEPEND", "RDEPEND", "PDEPEND",
- "USE", "IUSE", "PROVIDE", "RESTRICT"]
+ "USE", "IUSE", "PROVIDE", "RESTRICT", "repository"]
self.useFlags = {}
self.trees = {}
self.roots = {}
overlays_real = [os.path.realpath(t) \
for t in self.settings["PORTDIR_OVERLAY"].split()]
+ repo_display = RepoDisplay(self.roots)
+
tree_nodes = []
display_list = []
mygraph = self._parent_child_digraph
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_real = os.path.dirname(os.path.dirname(
+ os.path.dirname(ebuild_path)))
+ else:
+ repo_path_real = portdb.getRepositoryPath(repo_name)
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."""
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
- dir_name=os.path.abspath(os.path.dirname(file_name)+"/../..")
- if (overlays_real.count(dir_name)>0):
- verboseadd+=teal("["+str(overlays_real.index(
- os.path.normpath(dir_name))+1)+"]")+" "
- 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_display.repoStr(repo_path_real)
else:
- verboseadd += "[No ebuild?]"
+ repo_path_prev = None
+ if repo_name_prev:
+ repo_path_prev = portdb.getRepositoryPath(
+ repo_name_prev)
+ repoadd = "%s=>%s" % (
+ repo_display.repoStr(repo_path_prev),
+ repo_display.repoStr(repo_path_real))
+ if repoadd:
+ verboseadd += teal("[%s]" % repoadd)
xs=portage.pkgsplit(x[2])
if xs[2]=="r0":
if verbosity == 3:
print
print counters
- if overlays and display_overlays:
- print "Portage overlays:"
- y=0
- for x in overlays:
- y=y+1
- print " "+teal("["+str(y)+"]"),x
+ sys.stdout.write(str(repo_display))
if "--changelog" in self.myopts:
print
fakedb[myroot].aux_update(pkg_key, {"USE":pkgsettings["USE"]})
self.spinner.update()
+class RepoDisplay(object):
+ def __init__(self, roots):
+ self._shown_repos = {}
+ self._unknown_repo = False
+ repo_paths = set()
+ for root_config in 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)
+ self._repo_paths = repo_paths
+ self._repo_paths_real = [ os.path.realpath(repo_path) \
+ for repo_path in repo_paths ]
+
+ # pre-allocate index for PORTDIR so that it always has index 0.
+ for root_config in roots.itervalues():
+ portdb = root_config.trees["porttree"].dbapi
+ portdir = portdb.porttree_root
+ if portdir:
+ self.repoStr(portdir)
+
+ def repoStr(self, repo_path_real):
+ real_index = -1
+ if repo_path_real:
+ real_index = self._repo_paths_real.index(repo_path_real)
+ if real_index == -1:
+ s = "?"
+ self._unknown_repo = True
+ else:
+ shown_repos = self._shown_repos
+ repo_paths = self._repo_paths
+ 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
+
+ def __str__(self):
+ output = []
+ shown_repos = self._shown_repos
+ unknown_repo = self._unknown_repo
+ if shown_repos or self._unknown_repo:
+ output.append("Portage tree and overlays:\n")
+ 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):
+ output.append(" "+teal("["+str(index)+"]")+" %s\n" % repo_path)
+ if unknown_repo:
+ output.append(" "+teal("[?]") + \
+ " indicates that the source repository could not be determined\n")
+ return "".join(output)
+
class PackageCounters(object):
def __init__(self):