aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2014-11-28 05:11:18 -0800
committerZac Medico <zmedico@gentoo.org>2014-11-29 10:45:05 -0800
commit226b398c0549d5815f81921ba35fe8ff9d02052d (patch)
tree06a4193f3e698a2b3691ad1b19580613e11f2b82
parentebuild.sh: force fresh env for pkg_setup (528274) (diff)
downloadportage-226b398c0549d5815f81921ba35fe8ff9d02052d.tar.gz
portage-226b398c0549d5815f81921ba35fe8ff9d02052d.tar.bz2
portage-226b398c0549d5815f81921ba35fe8ff9d02052d.zip
emerge --info: show /bin/sh provider (527996)
Searching contents for the /bin/sh provider is somewhat slow. Therefore, use the basename of the symlink target to locate the package. If this fails, then only the basename of the symlink target will be displayed. So, typical output is something like "sh bash 4.2_p53". Since realpath is used to resolve symlinks recursively, this approach is also able to handle multiple levels of symlinks such as /bin/sh -> bb -> busybox. Note that we do not parse the output of "/bin/sh --version" because many shells do not have a --version option. The relevant section of the emerge --info output will now look something like this: Timestamp of tree: Fri, 28 Nov 2014 00:45:01 +0000 sh bash 4.2_p53 ld GNU ld (Gentoo 2.23.2 p1.0) 2.23.2 X-Gentoo-Bug: 527996 X-Gentoo-Url: https://bugs.gentoo.org/show_bug.cgi?id=527996 Acked-by: Brian Dolbec <dolsen@gentoo.org>
-rw-r--r--pym/_emerge/actions.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
index d9c45c171..048e33707 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -1556,6 +1556,47 @@ def action_info(settings, trees, myopts, myfiles):
lastSync = "Unknown"
append("Timestamp of tree: %s" % (lastSync,))
+ # Searching contents for the /bin/sh provider is somewhat
+ # slow. Therefore, use the basename of the symlink target
+ # to locate the package. If this fails, then only the
+ # basename of the symlink target will be displayed. So,
+ # typical output is something like "sh bash 4.2_p53". Since
+ # realpath is used to resolve symlinks recursively, this
+ # approach is also able to handle multiple levels of symlinks
+ # such as /bin/sh -> bb -> busybox. Note that we do not parse
+ # the output of "/bin/sh --version" because many shells
+ # do not have a --version option.
+ basename = os.path.basename(os.path.realpath(os.path.join(
+ os.sep, portage.const.EPREFIX, "bin", "sh")))
+ try:
+ Atom("null/%s" % basename)
+ except InvalidAtom:
+ matches = None
+ else:
+ try:
+ # Try a match against the basename, which should work for
+ # busybox and most shells.
+ matches = (trees[trees._running_eroot]["vartree"].dbapi.
+ match(basename))
+ except portage.exception.AmbiguousPackageName:
+ # If the name is ambiguous, then restrict our match
+ # to the app-shells category.
+ matches = (trees[trees._running_eroot]["vartree"].dbapi.
+ match("app-shells/%s" % basename))
+
+ if matches:
+ pkg = matches[-1]
+ name = pkg.cp
+ version = pkg.version
+ # Omit app-shells category from the output.
+ if name.startswith("app-shells/"):
+ name = name[len("app-shells/"):]
+ sh_str = "%s %s" % (name, version)
+ else:
+ sh_str = basename
+
+ append("sh %s" % sh_str)
+
ld_names = []
if chost:
ld_names.append(chost + "-ld")