commit:     382f4be415394886026ccd5dcd08ca96ecda31fa
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 23 16:29:13 2018 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Mar 26 17:42:50 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=382f4be4

portageq repos_config: fix <eroot> parameter (bug 648062)

The <eroot> parameter is ineffective for commands that query
configuration, since the PORTAGE_CONFIGROOT variable controls
the location of configuration files. Therefore, for portageq
repos_config, implicitly set PORTAGE_CONFIGROOT equal to the
value of the <eroot> parameter. Note that this works correctly
for both prefix and non-prefix systems, because both EROOT and
PORTAGE_CONFIGROOT are supposed to include the EPREFIX offset.

Bug: https://bugs.gentoo.org/648062

 bin/portageq | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/bin/portageq b/bin/portageq
index 0ac124fde..e9b8b20e0 100755
--- a/bin/portageq
+++ b/bin/portageq
@@ -1,5 +1,5 @@
 #!/usr/bin/python -b
-# Copyright 1999-2016 Gentoo Foundation
+# Copyright 1999-2018 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from __future__ import print_function, unicode_literals
@@ -62,6 +62,12 @@ def eval_atom_use(atom):
                atom = atom.evaluate_conditionals(use)
        return atom
 
+
+def uses_configroot(function):
+       function.uses_configroot = True
+       return function
+
+
 def uses_eroot(function):
        function.uses_eroot = True
        return function
@@ -696,6 +702,7 @@ docstrings['gentoo_mirrors'] = """
 gentoo_mirrors.__doc__ = docstrings['gentoo_mirrors']
 
 
+@uses_configroot
 @uses_eroot
 def repositories_configuration(argv):
        if len(argv) < 1:
@@ -710,6 +717,7 @@ docstrings['repositories_configuration'] = """<eroot>
 repositories_configuration.__doc__ = docstrings['repositories_configuration']
 
 
+@uses_configroot
 @uses_eroot
 def repos_config(argv):
        return repositories_configuration(argv)
@@ -1425,6 +1433,14 @@ def main(argv):
 
                os.environ["ROOT"] = root
 
+               if getattr(function, "uses_configroot", False):
+                       os.environ["PORTAGE_CONFIGROOT"] = eroot
+                       # Disable RepoConfigLoader location validation, 
allowing raw
+                       # configuration to pass through, since repo locations 
are not
+                       # necessarily expected to exist if the configuration 
comes
+                       # from a chroot.
+                       portage._sync_mode = True
+
        args = argv[2:]
 
        try:

Reply via email to