Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 489022

Summary: portageq-2.2.1 portageq ignores eroot parameter
Product: Portage Development Reporter: Andrey <ahipp0>
Component: Core - External InteractionAssignee: Portage team <dev-portage>
Status: UNCONFIRMED ---    
Severity: normal CC: ahipp0, maffblaster, redlizard
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: A simple fix (or a workaround) to reload portage settings.

Description Andrey 2013-10-22 15:21:59 UTC
At least `portageq match` and `portageq contents` seems to ignore the eroot parameter.
As far as I understand, the code that manages the eroot argument applies to all @uses_eroot functions, so almost all portageq functions are affected.

Reproducible: Always

Steps to Reproduce:
1. mkdir /new_root
2. emerge -av1 --root=/new_root test-bug/qqq
3. portageq match /new_root ''
Actual Results:  
package list from the host system (/) like
app-admin/eselect-1.3.8
...
sys-apps/portage-2.2.1
...
x11-base/xorg-server-1.14.3-r2

Expected Results:  
test-bug/qqq-9999


This produces the expected result:
ROOT=/new_root portageq match /new_root ''

And even this does the same:
ROOT=/new_root portageq match / ''
Comment 1 Andrey 2013-10-22 15:39:31 UTC
My git bisect result:
c9f6aa9f0151adb3c86706eaef1914cdbdcf2b6d is the first bad commit
commit c9f6aa9f0151adb3c86706eaef1914cdbdcf2b6d
Author: Ruud Koolen <redlizard@redlizard.nl>
Date:   Mon Jun 17 09:21:41 2013 +0200

    Add cross-prefix support
Comment 2 Andrey 2013-10-23 08:44:10 UTC
(In reply to Andrey Hippo from comment #1)
> My git bisect result:
> c9f6aa9f0151adb3c86706eaef1914cdbdcf2b6d is the first bad commit
> commit c9f6aa9f0151adb3c86706eaef1914cdbdcf2b6d
> Author: Ruud Koolen <redlizard@redlizard.nl>
> Date:   Mon Jun 17 09:21:41 2013 +0200
> 
>     Add cross-prefix support

I suppose, the bad change is
diff --git a/bin/portageq b/bin/portageq
index c88ee88..1ae1fe1 100755
--- a/bin/portageq
+++ b/bin/portageq
@@ -1232,7 +1232,7 @@ def main(argv):
                        sys.stderr.write("Run portageq with --help for info\n")
                        sys.stderr.flush()
                        sys.exit(os.EX_USAGE)
-               eprefix = portage.const.EPREFIX
+               eprefix = portage.settings["EPREFIX"]
                eroot = portage.util.normalize_path(argv[2])
 
                if eprefix:

While looking harmless, it actually makes portage.settings[] (see [1]) accessed before the following ROOT adjustment (see [2]):
os.environ["ROOT"] = root

This, in turn, makes portage.settings['EROOT'], called afterwards (see [3]), return (cached) EROOT value as of before os.environ["ROOT"] adjustment ([2]).


1314                 eprefix = portage.settings["EPREFIX"] # <---------- 1
1315                 eroot = portage.util.normalize_path(argv[2])
1316 
1317                 if eprefix:
...
1325                         root = eroot[:1-len(eprefix)]
1326                 else:
1327                         root = eroot
1328 
1329                 os.environ["ROOT"] = root # <---------------------- 2
1330 
1331         args = argv[2:]
1332 
1333         try:
1334                 if uses_eroot:
1335                         args[0] = portage.settings['EROOT'] # <---- 3
1336                 retval = function(args)
Comment 3 Andrey 2013-10-23 09:21:01 UTC
Created attachment 361694 [details, diff]
A simple fix (or a workaround) to reload portage settings.