Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 527996 - sys-apps/portage: emerge --info should show /bin/sh provider
Summary: sys-apps/portage: emerge --info should show /bin/sh provider
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core - Interface (emerge) (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks:
 
Reported: 2014-11-02 11:41 UTC by Pacho Ramos
Modified: 2023-12-24 17:26 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
first-owner.py: benchmark time taken to locate an owner of a file (first-owner.py,603 bytes, text/x-python)
2014-11-27 21:36 UTC, Zac Medico
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Pacho Ramos gentoo-dev 2014-11-02 11:41:28 UTC
Looks like more people is trying to migrate /bin/sh away from bash to other shells (usually dash, but I have also seen people using tcsh)

I think would be interesting to show the /bin/sh provider in emerge --info then (ideally, it could also show the package and version that is used for that provider as looks like different dash versions behave differently on regard of the compat they provide with bash (bug 527644))

Thanks a lot
Comment 1 Zac Medico gentoo-dev 2014-11-27 20:54:41 UTC
(In reply to Pacho Ramos from comment #0)
> I think would be interesting to show the /bin/sh provider in emerge --info
> then (ideally, it could also show the package and version that is used for
> that provider as looks like different dash versions behave differently on
> regard of the compat they provide with bash (bug 527644))

Thanks to indexing, performance of the vardbapi._owners.iter_owners method should be good enough to query the package that owns the file that /bin/sh references.

Alternatively, we could simply parse the output of '/bin/sh --version'.
Comment 2 Zac Medico gentoo-dev 2014-11-27 21:36:21 UTC
Created attachment 390424 [details]
first-owner.py: benchmark time taken to locate an owner of a file

This script can be used to gauge the performance impact of locating an owner of a file. Example usage:

	time first-owner.py /bin/bash

With ~2500 installed packages, real time is about 2.5 seconds on one of my computers with Core i5-2400S. On another computer with the same installed packages but with Core i3-3217U, real time is about 4.8 seconds. Both measurements are with hot cache.

Based on this measurements, I think maybe we should simply parse the output of '/bin/sh --version'.
Comment 3 Zac Medico gentoo-dev 2014-11-28 04:26:29 UTC
It seems that dash does not have a --version option. I guess we can use a simple mapping like /bin/sh -> name -> app-shells/${name} to query the version.
Comment 4 Pacho Ramos gentoo-dev 2014-11-28 09:46:27 UTC
(In reply to Zac Medico from comment #3)
> It seems that dash does not have a --version option. I guess we can use a
> simple mapping like /bin/sh -> name -> app-shells/${name} to query the
> version.

Maybe it should try to look at app-shells on a first try... but I am unsure if all shell providers are there. Doesn't busybox (on sys-apps) also provide a shell? 

But, maybe it would be enough to look for app-shells/ stuff and, if not found, simply show a warning in the output that would lead us to ask the reporter about it :/

If we would have some virtual/sh package listing the known providers maybe would be easier as would only need to look for that list of providers instead of all the tree, but looks like we don't have that virtual (probably because the alternatives are still not drop-in replacements)
Comment 5 Zac Medico gentoo-dev 2014-11-28 10:48:21 UTC
(In reply to Pacho Ramos from comment #4)
> Maybe it should try to look at app-shells on a first try... but I am unsure
> if all shell providers are there. Doesn't busybox (on sys-apps) also provide
> a shell? 

Yeah. I guess we could have it just search for any package with the same name as the symlink target, and if there are matches from multiple categories, then prefer app-shells.
Comment 6 Zac Medico gentoo-dev 2014-11-28 13:14:41 UTC
I have a patch in this branch:

	https://github.com/zmedico/portage/commits/bug_527996
Comment 7 Pacho Ramos gentoo-dev 2014-11-28 13:23:30 UTC
Thanks

What will it do if both fail? I would simply show a warning (for example, I think some people has "bb" (from busybox?) as /bin/sh provider
Comment 8 Zac Medico gentoo-dev 2014-11-28 20:11:53 UTC
(In reply to Pacho Ramos from comment #7)
> What will it do if both fail? I would simply show a warning (for example, I
> think some people has "bb" (from busybox?) as /bin/sh provider

Is will say "sh bb" if it can't locate a package named bb.
Comment 9 Pacho Ramos gentoo-dev 2014-11-28 20:50:33 UTC
OK :)
Comment 10 Zac Medico gentoo-dev 2014-11-28 21:19:15 UTC
I've posted a patch for review here:

http://thread.gmane.org/gmane.linux.gentoo.portage.devel/4846
Comment 11 Zac Medico gentoo-dev 2014-11-29 01:01:13 UTC
Actually, bb properly map to sys-apps/busybox because bb is a symlink to busybox, and my patch uses os.path.realpath() to resolve symlinks recursively. I will update comments in the patch to note this.
Comment 12 Zac Medico gentoo-dev 2014-11-29 18:50:25 UTC
This is in the master branch:

https://github.com/gentoo/portage/commit/226b398c0549d5815f81921ba35fe8ff9d02052d
Comment 13 Brian Dolbec (RETIRED) gentoo-dev 2014-12-04 05:38:48 UTC
This is in the portage-2.2.15 release.