Gentoo Archives: gentoo-commits

From: Zac Medico <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: pym/_emerge/
Date: Sat, 29 Nov 2014 18:48:41
Message-Id: 1417286705.226b398c0549d5815f81921ba35fe8ff9d02052d.zmedico@gentoo
1 commit: 226b398c0549d5815f81921ba35fe8ff9d02052d
2 Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
3 AuthorDate: Fri Nov 28 13:11:18 2014 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Sat Nov 29 18:45:05 2014 +0000
6 URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=226b398c
7
8 emerge --info: show /bin/sh provider (527996)
9
10 Searching contents for the /bin/sh provider is somewhat slow.
11 Therefore, use the basename of the symlink target to locate the
12 package. If this fails, then only the basename of the symlink target
13 will be displayed. So, typical output is something like
14 "sh bash 4.2_p53". Since realpath is used to resolve symlinks
15 recursively, this approach is also able to handle multiple levels of
16 symlinks such as /bin/sh -> bb -> busybox. Note that we do not parse
17 the output of "/bin/sh --version" because many shells do not have
18 a --version option.
19
20 The relevant section of the emerge --info output will now look
21 something like this:
22
23 Timestamp of tree: Fri, 28 Nov 2014 00:45:01 +0000
24 sh bash 4.2_p53
25 ld GNU ld (Gentoo 2.23.2 p1.0) 2.23.2
26
27 X-Gentoo-Bug: 527996
28 X-Gentoo-Url: https://bugs.gentoo.org/show_bug.cgi?id=527996
29 Acked-by: Brian Dolbec <dolsen <AT> gentoo.org>
30
31 ---
32 pym/_emerge/actions.py | 41 +++++++++++++++++++++++++++++++++++++++++
33 1 file changed, 41 insertions(+)
34
35 diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
36 index d9c45c1..048e337 100644
37 --- a/pym/_emerge/actions.py
38 +++ b/pym/_emerge/actions.py
39 @@ -1556,6 +1556,47 @@ def action_info(settings, trees, myopts, myfiles):
40 lastSync = "Unknown"
41 append("Timestamp of tree: %s" % (lastSync,))
42
43 + # Searching contents for the /bin/sh provider is somewhat
44 + # slow. Therefore, use the basename of the symlink target
45 + # to locate the package. If this fails, then only the
46 + # basename of the symlink target will be displayed. So,
47 + # typical output is something like "sh bash 4.2_p53". Since
48 + # realpath is used to resolve symlinks recursively, this
49 + # approach is also able to handle multiple levels of symlinks
50 + # such as /bin/sh -> bb -> busybox. Note that we do not parse
51 + # the output of "/bin/sh --version" because many shells
52 + # do not have a --version option.
53 + basename = os.path.basename(os.path.realpath(os.path.join(
54 + os.sep, portage.const.EPREFIX, "bin", "sh")))
55 + try:
56 + Atom("null/%s" % basename)
57 + except InvalidAtom:
58 + matches = None
59 + else:
60 + try:
61 + # Try a match against the basename, which should work for
62 + # busybox and most shells.
63 + matches = (trees[trees._running_eroot]["vartree"].dbapi.
64 + match(basename))
65 + except portage.exception.AmbiguousPackageName:
66 + # If the name is ambiguous, then restrict our match
67 + # to the app-shells category.
68 + matches = (trees[trees._running_eroot]["vartree"].dbapi.
69 + match("app-shells/%s" % basename))
70 +
71 + if matches:
72 + pkg = matches[-1]
73 + name = pkg.cp
74 + version = pkg.version
75 + # Omit app-shells category from the output.
76 + if name.startswith("app-shells/"):
77 + name = name[len("app-shells/"):]
78 + sh_str = "%s %s" % (name, version)
79 + else:
80 + sh_str = basename
81 +
82 + append("sh %s" % sh_str)
83 +
84 ld_names = []
85 if chost:
86 ld_names.append(chost + "-ld")