Re: [gentoo-portage-dev] [PATCH] portageq: fix eroot parameter (bug #529200)

2014-11-17 Thread Alexander Berntsen
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

On 14/11/14 18:36, Zac Medico wrote:
 That won't work, because you can't reference eprefix on the right
 hand side of the assignment, and the whole right hand side must
 evaluate before the eprefix reference is initialized.
Oh right. My python-fu isn't as strong as it used to be. Thanks.

- -- 
Alexander
berna...@gentoo.org
https://secure.plaimi.net/~alexander
-BEGIN PGP SIGNATURE-
Version: GnuPG v2
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iF4EAREIAAYFAlRpqxUACgkQRtClrXBQc7V+iAEAmJtBB4yZRAmb0i6HHHG+V2zh
COJ58I6Q5iuPGjrVimkA/0qQVYGC66czxZ6JP4lOC+NWf5n6EMOpi2jS7kOZzxcv
=84lS
-END PGP SIGNATURE-



Re: [gentoo-portage-dev] [PATCH] portageq: fix eroot parameter (bug #529200)

2014-11-14 Thread Alexander Berntsen
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

On 14/11/14 08:42, Zac Medico wrote:
 + eprefix = os.environ.get(EPREFIX, portage.const.EPREFIX)
 + if eprefix:
 + eprefix = portage.util.normalize_path(eprefix)
Why not just:
  eprefix = os.environ.get(EPREFIX, portage.const.EPREFIX) and \
portage.util.normalize_path(eprefix)
?

I don't care *that* much. Patch looks good otherwise, so go ahead  merge,
with or without my proposed change.
- -- 
Alexander
berna...@gentoo.org
https://secure.plaimi.net/~alexander
-BEGIN PGP SIGNATURE-
Version: GnuPG v2
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iF4EAREIAAYFAlRlw/gACgkQRtClrXBQc7VfNgEAlDyhLlgp8kagXSfFbLyQFjWS
RsE7bGdLkulDbOO4oR4BAIuKxwFKx7yUkregTqiyS7aNX7jdQcY3YhOAdcHte0Cw
=7o+I
-END PGP SIGNATURE-



Re: [gentoo-portage-dev] [PATCH] portageq: fix eroot parameter (bug #529200)

2014-11-14 Thread Zac Medico
On 11/14/2014 12:57 AM, Alexander Berntsen wrote:
 On 14/11/14 08:42, Zac Medico wrote:
 +eprefix = os.environ.get(EPREFIX, portage.const.EPREFIX)
 +if eprefix:
 +eprefix = portage.util.normalize_path(eprefix)
 Why not just:
   eprefix = os.environ.get(EPREFIX, portage.const.EPREFIX) and \
 portage.util.normalize_path(eprefix)
 ?

That won't work, because you can't reference eprefix on the right hand
side of the assignment, and the whole right hand side must evaluate
before the eprefix reference is initialized.

 I don't care *that* much. Patch looks good otherwise, so go ahead  merge,
 with or without my proposed change.
 

Merged, thanks.

-- 
Thanks,
Zac



[gentoo-portage-dev] [PATCH] portageq: fix eroot parameter (bug #529200)

2014-11-13 Thread Zac Medico
The portageq eroot parameter has been broken since commit
c9f6aa9f0151adb3c86706eaef1914cdbdcf2b6d, due to premature instantiation
of portage.settings (before the ROOT variable was set). Premature access
to the portage.settings attribute must be avoided by using other
available means to determine the EPREFIX.

Fixes: c9f6aa9f0151 (Add cross-prefix support)
X-Gentoo-Bug: 529200
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=529200
---
 bin/portageq|  9 -
 pym/portage/tests/emerge/test_simple.py | 10 --
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/bin/portageq b/bin/portageq
index 009f116..ef565d1 100755
--- a/bin/portageq
+++ b/bin/portageq
@@ -1392,7 +1392,14 @@ def main(argv):
sys.stderr.write(Run portageq with --help for info\n)
sys.stderr.flush()
sys.exit(os.EX_USAGE)
-   eprefix = portage.settings[EPREFIX]
+   # Calculate EPREFIX and ROOT that will be used to construct
+   # portage.settings later. It's tempting to use
+   # portage.settings[EPREFIX] here, but that would force
+   # instantiation of portage.settings, which we don't want to do
+   # until after we've calculated ROOT (see bug #529200).
+   eprefix = os.environ.get(EPREFIX, portage.const.EPREFIX)
+   if eprefix:
+   eprefix = portage.util.normalize_path(eprefix)
eroot = portage.util.normalize_path(argv[2])
 
if eprefix:
diff --git a/pym/portage/tests/emerge/test_simple.py 
b/pym/portage/tests/emerge/test_simple.py
index 6c20a07..0101362 100644
--- a/pym/portage/tests/emerge/test_simple.py
+++ b/pym/portage/tests/emerge/test_simple.py
@@ -217,6 +217,8 @@ pkg_preinst() {
self.assertFalse(test_ebuild is None)
 
cross_prefix = os.path.join(eprefix, cross_prefix)
+   cross_root = os.path.join(eprefix, cross_root)
+   cross_eroot = os.path.join(cross_root, eprefix.lstrip(os.sep))
 
test_commands = (
env_update_cmd,
@@ -318,6 +320,10 @@ pkg_preinst() {
portageq_cmd + (has_version, cross_prefix, 
dev-libs/A),
({EPREFIX : cross_prefix},) + \
portageq_cmd + (has_version, cross_prefix, 
dev-libs/B),
+
+   # Test ROOT support
+   ({ROOT: cross_root},) + emerge_cmd + (dev-libs/B,),
+   portageq_cmd + (has_version, cross_eroot, 
dev-libs/B),
)
 
distdir = playground.distdir
@@ -372,8 +378,8 @@ pkg_preinst() {
os.environ[__PORTAGE_TEST_HARDLINK_LOCKS]
 
updates_dir = os.path.join(test_repo_location, profiles, 
updates)
-   dirs = [cachedir, cachedir_pregen, cross_prefix, distdir, 
fake_bin,
-   portage_tmpdir, updates_dir,
+   dirs = [cachedir, cachedir_pregen, cross_eroot, cross_prefix,
+   distdir, fake_bin, portage_tmpdir, updates_dir,
user_config_dir, var_cache_edb]
etc_symlinks = (dispatch-conf.conf, etc-update.conf)
# Override things that may be unavailable, or may have 
portability
-- 
2.0.4