Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 420111 - app-portage/pfl - e-file: use portageq instead of emerge --info
Summary: app-portage/pfl - e-file: use portageq instead of emerge --info
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal enhancement (vote)
Assignee: Daniel Pielmeier
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2012-06-07 13:23 UTC by Jeroen Roovers (RETIRED)
Modified: 2013-10-06 17:28 UTC (History)
2 users (show)

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


Attachments
e-file-portageq.patch (420111-portageq.patch,1.20 KB, patch)
2012-06-07 13:24 UTC, Jeroen Roovers (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jeroen Roovers (RETIRED) gentoo-dev 2012-06-07 13:23:42 UTC
e-file uses `emerge --info | grep PORTDIR' to get PORTDIR, but that's a waste of a lot of time. Much quicker is portageq, which can return the value so no grepping and "awkward" (haha) string mangling is needed.

Patch to follow.
Comment 1 Jeroen Roovers (RETIRED) gentoo-dev 2012-06-07 13:24:50 UTC
Created attachment 314571 [details, diff]
e-file-portageq.patch
Comment 2 Martin Väth 2012-06-08 07:16:41 UTC
Just a few notes:
1. "portageq portdir" exists
2. "type" is not POSIX. Better replace it by "command -v"
3. "eix --print PORTDIR" is much quicker than portageq (of course, this can
only be used if "command -v eix >/dev/null 2>%1" returns 0)
Comment 3 Jeroen Roovers (RETIRED) gentoo-dev 2012-06-09 14:18:09 UTC
(In reply to comment #2)
> Just a few notes:
> 1. "portageq portdir" exists

Correct!

> 3. "eix --print PORTDIR" is much quicker than portageq (of course, this can
> only be used if "command -v eix >/dev/null 2>%1" returns 0)

elmer ~ # time eix --print PORTDIR
/world/gentoo/portage/

real    0m0.633s
user    0m0.050s
sys     0m0.100s

elmer ~ # time echo $( . /etc/make.globals 2>/dev/null; . /etc/make.conf 2>/dev/null; echo ${PORTDIR:-/usr/portage} )
/world/gentoo/portage

real    0m0.047s
user    0m0.020s
sys     0m0.000s
Comment 4 Martin Väth 2012-06-14 20:27:53 UTC
(In reply to comment #3)
> elmer ~ # time eix --print PORTDIR
> elmer ~ # time echo $( . /etc/make.globals 2>/dev/null; . /etc/make.conf

I am not sure what you want to say here:
I was comparing the speed of eix with the speed of portageq.
Of course, shell-sourcing is even faster, but it is not reliable here:
For instance, certain escapes are handled differentiy, and if your
shell is /bin/dash even a "source" command will bail out.
Comment 5 Daniel Pielmeier gentoo-dev 2012-06-15 11:16:14 UTC
I don't think it makes much sense arguing about such tiny details. In the long run it is planned to replace e-file with a python implementation (see bug #413191). This way it can use the portage api which I think renders this discussion useless. Just do a:
import portage
PORTDIR = portage.portdb.porttree_root
or something like this and be done.

PS: Martin why did you change the status to RESOLVED FIXED?
Comment 6 Martin Väth 2012-06-15 16:07:30 UTC
I did not intend to change the status:
It was shown in my browser as "resolved fixed", and I didn't touch it.
(Perhaps this was a problem of noscript blocking some code...)
Comment 7 Daniel Pielmeier gentoo-dev 2013-10-06 17:28:03 UTC
+*pfl-2.4 (06 Oct 2013)
+
+  06 Oct 2013; Daniel Pielmeier <billie@gentoo.org> +pfl-2.4.ebuild,
+  +files/e-file-20110906-portageq.patch:
+  Version bump. Fixes bug #420111, thanks to Jeroen Roovers for the patch.
+  Fixed bug #481296, thanks to Alice Ferrazzi for the report and Daniel for the
+  fix.

For now I have committed the patch with the portageq approach. Maybe there will be a python version of e-file some time but until then this should do.