1 |
The portageq eroot parameter has been broken since commit |
2 |
c9f6aa9f0151adb3c86706eaef1914cdbdcf2b6d, due to premature instantiation |
3 |
of portage.settings (before the ROOT variable was set). Premature access |
4 |
to the portage.settings attribute must be avoided by using other |
5 |
available means to determine the EPREFIX. |
6 |
|
7 |
Fixes: c9f6aa9f0151 ("Add cross-prefix support") |
8 |
X-Gentoo-Bug: 529200 |
9 |
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=529200 |
10 |
--- |
11 |
bin/portageq | 9 ++++++++- |
12 |
pym/portage/tests/emerge/test_simple.py | 10 ++++++++-- |
13 |
2 files changed, 16 insertions(+), 3 deletions(-) |
14 |
|
15 |
diff --git a/bin/portageq b/bin/portageq |
16 |
index 009f116..ef565d1 100755 |
17 |
--- a/bin/portageq |
18 |
+++ b/bin/portageq |
19 |
@@ -1392,7 +1392,14 @@ def main(argv): |
20 |
sys.stderr.write("Run portageq with --help for info\n") |
21 |
sys.stderr.flush() |
22 |
sys.exit(os.EX_USAGE) |
23 |
- eprefix = portage.settings["EPREFIX"] |
24 |
+ # Calculate EPREFIX and ROOT that will be used to construct |
25 |
+ # portage.settings later. It's tempting to use |
26 |
+ # portage.settings["EPREFIX"] here, but that would force |
27 |
+ # instantiation of portage.settings, which we don't want to do |
28 |
+ # until after we've calculated ROOT (see bug #529200). |
29 |
+ eprefix = os.environ.get("EPREFIX", portage.const.EPREFIX) |
30 |
+ if eprefix: |
31 |
+ eprefix = portage.util.normalize_path(eprefix) |
32 |
eroot = portage.util.normalize_path(argv[2]) |
33 |
|
34 |
if eprefix: |
35 |
diff --git a/pym/portage/tests/emerge/test_simple.py b/pym/portage/tests/emerge/test_simple.py |
36 |
index 6c20a07..0101362 100644 |
37 |
--- a/pym/portage/tests/emerge/test_simple.py |
38 |
+++ b/pym/portage/tests/emerge/test_simple.py |
39 |
@@ -217,6 +217,8 @@ pkg_preinst() { |
40 |
self.assertFalse(test_ebuild is None) |
41 |
|
42 |
cross_prefix = os.path.join(eprefix, "cross_prefix") |
43 |
+ cross_root = os.path.join(eprefix, "cross_root") |
44 |
+ cross_eroot = os.path.join(cross_root, eprefix.lstrip(os.sep)) |
45 |
|
46 |
test_commands = ( |
47 |
env_update_cmd, |
48 |
@@ -318,6 +320,10 @@ pkg_preinst() { |
49 |
portageq_cmd + ("has_version", cross_prefix, "dev-libs/A"), |
50 |
({"EPREFIX" : cross_prefix},) + \ |
51 |
portageq_cmd + ("has_version", cross_prefix, "dev-libs/B"), |
52 |
+ |
53 |
+ # Test ROOT support |
54 |
+ ({"ROOT": cross_root},) + emerge_cmd + ("dev-libs/B",), |
55 |
+ portageq_cmd + ("has_version", cross_eroot, "dev-libs/B"), |
56 |
) |
57 |
|
58 |
distdir = playground.distdir |
59 |
@@ -372,8 +378,8 @@ pkg_preinst() { |
60 |
os.environ["__PORTAGE_TEST_HARDLINK_LOCKS"] |
61 |
|
62 |
updates_dir = os.path.join(test_repo_location, "profiles", "updates") |
63 |
- dirs = [cachedir, cachedir_pregen, cross_prefix, distdir, fake_bin, |
64 |
- portage_tmpdir, updates_dir, |
65 |
+ dirs = [cachedir, cachedir_pregen, cross_eroot, cross_prefix, |
66 |
+ distdir, fake_bin, portage_tmpdir, updates_dir, |
67 |
user_config_dir, var_cache_edb] |
68 |
etc_symlinks = ("dispatch-conf.conf", "etc-update.conf") |
69 |
# Override things that may be unavailable, or may have portability |
70 |
-- |
71 |
2.0.4 |