Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 601466 - RESTRICT="!test? ( test )" is not evaluated correctly by ebuild(1)
Summary: RESTRICT="!test? ( test )" is not evaluated correctly by ebuild(1)
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core - Ebuild Support (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks: 604854
  Show dependency tree
 
Reported: 2016-12-02 16:26 UTC by Mike Gilbert
Modified: 2017-02-10 18:54 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
test ebuild (test-0.ebuild,588 bytes, text/plain)
2016-12-02 16:26 UTC, Mike Gilbert
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Gilbert gentoo-dev 2016-12-02 16:26:43 UTC
Created attachment 454918 [details]
test ebuild

See attached ebuild for context.

When I run "ebuild test-0.ebuild test", I get the output below. I would expect to see the test phase execute instead.

floppym@naomi test % sudo ebuild test-0.ebuild clean test
Forcing test.
 * setup: test is yes
>>> Unpacking source...
 * unpack: test is yes
>>> Source unpacked in /tmp/portage/app-misc/test-0/work
>>> Preparing source in /tmp/portage/app-misc/test-0/work ...
 * prepare: test is yes
>>> Source prepared.
>>> Configuring source in /tmp/portage/app-misc/test-0/work ...
 * configure: test is yes
>>> Source configured.
>>> Compiling source in /tmp/portage/app-misc/test-0/work ...
 * compile: test is yes
>>> Source compiled.
 * Skipping make test/check due to ebuild restriction.
>>> Test phase [disabled because of RESTRICT=test]: app-misc/test-0
Comment 1 Mike Gilbert gentoo-dev 2016-12-02 16:33:15 UTC
For comparison, emerge with FEATURES=test works correctly.

floppym@naomi test % sudo FEATURES=test emerge -v1O -j1 app-misc/test

These are the packages that would be merged, in order:

[ebuild  N     ] app-misc/test-0::local  USE="{test}" 0 KiB

Total: 1 package (1 new), Size of downloads: 0 KiB


>>> Verifying ebuild manifests

>>> Emerging (1 of 1) app-misc/test-0::local
 * setup: test is yes
>>> Unpacking source...
 * unpack: test is yes
>>> Source unpacked in /tmp/portage/app-misc/test-0/work
>>> Preparing source in /tmp/portage/app-misc/test-0/work ...
 * prepare: test is yes
>>> Source prepared.
>>> Configuring source in /tmp/portage/app-misc/test-0/work ...
 * configure: test is yes
>>> Source configured.
>>> Compiling source in /tmp/portage/app-misc/test-0/work ...
 * compile: test is yes
>>> Source compiled.
>>> Test phase: app-misc/test-0
 * test: test is yes
>>> Completed testing app-misc/test-0
Comment 2 Zac Medico gentoo-dev 2016-12-02 17:24:06 UTC
What's happening is that the _PackageMetadataWrapper._use_conditional_keys code is evaluating RESTRICT to remove the conditionals prematurely. This appears to solve the problem:

diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py
index 505c7a2..f1d3d41 100644
--- a/pym/portage/package/ebuild/config.py
+++ b/pym/portage/package/ebuild/config.py
@@ -1412,7 +1412,10 @@ class config(object):
 		if not isinstance(mycpv, basestring):
 			pkg = mycpv
 			mycpv = pkg.cpv
-			mydb = pkg._metadata
+			try:
+				mydb = pkg._raw_metadata
+			except AttributeError:
+				mydb = pkg._metadata
 			explicit_iuse = pkg.iuse.all
 			args_hash = (mycpv, id(pkg))
 			if pkg.built:
Comment 3 Zac Medico gentoo-dev 2016-12-02 17:33:26 UTC
(In reply to Zac Medico from comment #2)

When using _raw_metadata, we need to make sure that all of these variables are evaluated when appropriate, since we're by passing _PackageMetadataWrapper's evaluation:

	_use_conditional_keys = frozenset(
		['LICENSE', 'PROPERTIES', 'PROVIDE', 'RESTRICT',])
Comment 4 Zac Medico gentoo-dev 2016-12-03 05:35:33 UTC
It turns out that the Package instance in bin/build is using a separate config instance to calculate its USE settings, so that's what triggers this. I'll have to think about what's the best way to make things consistent. Here's one way to do it:

diff --git a/bin/ebuild b/bin/ebuild
index 1f99177..85226e2 100755
--- a/bin/ebuild
+++ b/bin/ebuild
@@ -296,6 +296,10 @@ pkg = Package(built=(pkg_type != "ebuild"), cpv=cpv,
 # portdb.porttrees in order to accomplish this).
 tmpsettings.setcpv(pkg)
 
+# Update pkg.use.enabled, in order to enforce consistency
+# for EBUILD_FORCE_TEST support (bug 601466).
+pkg._metadata['USE'] = tmpsettings['PORTAGE_USE']
+
 def stale_env_warning():
 	if "clean" not in pargs and \
 		"noauto" not in tmpsettings.features and \
Comment 6 Mike Gilbert gentoo-dev 2016-12-03 17:49:54 UTC
Minor regression: "Forcing test." is now output twice.

floppym@naomi test % ebuild test-0.ebuild clean test
Forcing test.
Forcing test.
 * setup: test is yes
>>> Unpacking source...
Comment 7 Zac Medico gentoo-dev 2016-12-03 20:42:21 UTC
Pushed, with fixup to eliminate duplicate "Forcing Test" messages:

https://gitweb.gentoo.org/proj/portage.git/commit/?id=0c06ff5f8f3e86592bbaeb38f274797505c45b2a
Comment 8 Zac Medico gentoo-dev 2017-02-10 18:54:01 UTC
Fixed in portage-2.3.3.