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.
Created attachment 314571 [details, diff] e-file-portageq.patch
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)
(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
(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.
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?
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...)
+*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.