commit: a88f4996a9c20a638c8bf9a42bcbbc28ce0cc8dc Author: Michał Górny <mgorny <AT> gentoo <DOT> org> AuthorDate: Wed May 12 15:53:15 2021 +0000 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> CommitDate: Wed May 19 08:06:38 2021 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=a88f4996
Implement PROPERTIES=test_network and ALLOW_TEST The 'test_network' property can be used to indicate that the test phase requires access to the Internet (but RESTRICT=test should still be used). If present, network-sandbox will be disabled throughout the test phase. This opens up the possibility of adding further 'test_*' properties. Additionally, ALLOW_TEST can be used to ignore RESTRICT=test in a subset of packages. When the value includes 'network' token, tests using 'test_network' property are reenabled. When the value includes 'all' token, all instances of RESTRICT=test are ignored. Bug: https://bugs.gentoo.org/553696 Reviewed-by: Zac Medico <zmedico <AT> gentoo.org> Acked-by: Ulrich Müller <ulm <AT> gentoo.org> Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> bin/ebuild.sh | 3 ++- bin/phase-functions.sh | 8 +++++--- lib/portage/const.py | 2 +- .../package/ebuild/_config/special_env_vars.py | 3 ++- lib/portage/package/ebuild/config.py | 22 ++++++++++++++++++---- lib/portage/package/ebuild/doebuild.py | 15 +++++++++------ man/make.conf.5 | 21 ++++++++++++++++++++- 7 files changed, 57 insertions(+), 17 deletions(-) diff --git a/bin/ebuild.sh b/bin/ebuild.sh index ed0218787..bf070080d 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright 1999-2018 Gentoo Foundation +# Copyright 1999-2021 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # Prevent aliases from causing portage to act inappropriately. @@ -647,6 +647,7 @@ if ! has "$EBUILD_PHASE" clean cleanrm ; then fi if [[ "${EBUILD_PHASE}" != "depend" ]] ; then + PROPERTIES=${PORTAGE_PROPERTIES} RESTRICT=${PORTAGE_RESTRICT} [[ -e $PORTAGE_BUILDDIR/.ebuild_changed ]] && \ rm "$PORTAGE_BUILDDIR/.ebuild_changed" diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh index 90e622e75..db30fdefa 100644 --- a/bin/phase-functions.sh +++ b/bin/phase-functions.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright 1999-2019 Gentoo Authors +# Copyright 1999-2021 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # Hardcoded bash lists are needed for backward compatibility with @@ -23,7 +23,7 @@ PORTAGE_READONLY_VARS="D EBUILD EBUILD_PHASE EBUILD_PHASE_FUNC \ PORTAGE_ECLASS_LOCATIONS \ PORTAGE_GID PORTAGE_GRPNAME PORTAGE_INST_GID PORTAGE_INST_UID \ PORTAGE_INTERNAL_CALLER PORTAGE_IPC_DAEMON PORTAGE_IUSE PORTAGE_LOG_FILE \ - PORTAGE_MUTABLE_FILTERED_VARS PORTAGE_OVERRIDE_EPREFIX \ + PORTAGE_MUTABLE_FILTERED_VARS PORTAGE_OVERRIDE_EPREFIX PORTAGE_PROPERTIES \ PORTAGE_PYM_PATH PORTAGE_PYTHON PORTAGE_PYTHONPATH \ PORTAGE_READONLY_METADATA PORTAGE_READONLY_VARS \ PORTAGE_REPO_NAME PORTAGE_REPOSITORIES PORTAGE_RESTRICT \ @@ -489,7 +489,9 @@ __dyn_test() { die "The source directory '${S}' doesn't exist" fi - if has test ${RESTRICT} ; then + if has test ${RESTRICT} && ! has all ${ALLOW_TEST} && + ! { has test_network ${PROPERTIES} && has network ${ALLOW_TEST}; } + then einfo "Skipping make test/check due to ebuild restriction." __vecho ">>> Test phase [disabled because of RESTRICT=test]: ${CATEGORY}/${PF}" diff --git a/lib/portage/const.py b/lib/portage/const.py index 7effcd85d..76fea8293 100644 --- a/lib/portage/const.py +++ b/lib/portage/const.py @@ -1,5 +1,5 @@ # portage: Constants -# Copyright 1998-2019 Gentoo Authors +# Copyright 1998-2021 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 import os diff --git a/lib/portage/package/ebuild/_config/special_env_vars.py b/lib/portage/package/ebuild/_config/special_env_vars.py index 8b65762ea..72fc31401 100644 --- a/lib/portage/package/ebuild/_config/special_env_vars.py +++ b/lib/portage/package/ebuild/_config/special_env_vars.py @@ -1,4 +1,4 @@ -# Copyright 2010-2020 Gentoo Authors +# Copyright 2010-2021 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 __all__ = ( @@ -68,6 +68,7 @@ environ_whitelist += [ "PORTAGE_INST_GID", "PORTAGE_INST_UID", "PORTAGE_IPC_DAEMON", "PORTAGE_IUSE", "PORTAGE_ECLASS_LOCATIONS", "PORTAGE_LOG_FILE", "PORTAGE_OVERRIDE_EPREFIX", "PORTAGE_PIPE_FD", + "PORTAGE_PROPERTIES", "PORTAGE_PYM_PATH", "PORTAGE_PYTHON", "PORTAGE_PYTHONPATH", "PORTAGE_QUIET", "PORTAGE_REPO_NAME", "PORTAGE_REPOSITORIES", "PORTAGE_RESTRICT", diff --git a/lib/portage/package/ebuild/config.py b/lib/portage/package/ebuild/config.py index 0d0b51053..773135b3d 100644 --- a/lib/portage/package/ebuild/config.py +++ b/lib/portage/package/ebuild/config.py @@ -1359,12 +1359,13 @@ class config: values['ACCEPT_LICENSE'] = settings._license_manager.get_prunned_accept_license( \ settings.mycpv, use, settings.get('LICENSE', ''), settings.get('SLOT'), settings.get('PORTAGE_REPO_NAME')) - values['PORTAGE_RESTRICT'] = self._restrict(use, settings) + values['PORTAGE_PROPERTIES'] = self._flatten('PROPERTIES', use, settings) + values['PORTAGE_RESTRICT'] = self._flatten('RESTRICT', use, settings) return values - def _restrict(self, use, settings): + def _flatten(self, var, use, settings): try: - restrict = set(use_reduce(settings.get('RESTRICT', ''), uselist=use, flat=True)) + restrict = set(use_reduce(settings.get(var, ''), uselist=use, flat=True)) except InvalidDependString: restrict = set() return ' '.join(sorted(restrict)) @@ -1713,17 +1714,25 @@ class config: iuse_implicit_match = self._iuse_implicit_match if pkg is None: + raw_properties = pkg_configdict.get("PROPERTIES") raw_restrict = pkg_configdict.get("RESTRICT") else: + raw_properties = pkg._raw_metadata["PROPERTIES"] raw_restrict = pkg._raw_metadata["RESTRICT"] restrict_test = False if raw_restrict: try: if built_use is not None: + properties = use_reduce(raw_properties, + uselist=built_use, flat=True) restrict = use_reduce(raw_restrict, uselist=built_use, flat=True) else: + properties = use_reduce(raw_properties, + uselist=frozenset(x for x in self['USE'].split() + if x in explicit_iuse or iuse_implicit_match(x)), + flat=True) restrict = use_reduce(raw_restrict, uselist=frozenset(x for x in self['USE'].split() if x in explicit_iuse or iuse_implicit_match(x)), @@ -1731,7 +1740,10 @@ class config: except PortageException: pass else: - restrict_test = "test" in restrict + allow_test = self.get('ALLOW_TEST', '').split() + restrict_test = ( + "test" in restrict and not "all" in allow_test and + not ("test_network" in properties and "network" in allow_test)) if restrict_test and "test" in self.features: # Handle it like IUSE="-test", since features USE is @@ -1754,6 +1766,8 @@ class config: lazy_vars = self._lazy_vars(built_use, self) env_configdict.addLazySingleton('ACCEPT_LICENSE', lazy_vars.__getitem__, 'ACCEPT_LICENSE') + env_configdict.addLazySingleton('PORTAGE_PROPERTIES', + lazy_vars.__getitem__, 'PORTAGE_PROPERTIES') env_configdict.addLazySingleton('PORTAGE_RESTRICT', lazy_vars.__getitem__, 'PORTAGE_RESTRICT') diff --git a/lib/portage/package/ebuild/doebuild.py b/lib/portage/package/ebuild/doebuild.py index 476689d5e..86c1d40b4 100644 --- a/lib/portage/package/ebuild/doebuild.py +++ b/lib/portage/package/ebuild/doebuild.py @@ -1,4 +1,4 @@ -# Copyright 2010-2020 Gentoo Authors +# Copyright 2010-2021 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 __all__ = ['doebuild', 'doebuild_environment', 'spawn', 'spawnebuild'] @@ -142,11 +142,14 @@ def _doebuild_spawn(phase, settings, actionmap=None, **kwargs): kwargs['ipc'] = 'ipc-sandbox' not in settings.features or \ phase in _ipc_phases kwargs['mountns'] = 'mount-sandbox' in settings.features - kwargs['networked'] = 'network-sandbox' not in settings.features or \ - (phase == 'unpack' and \ - 'live' in settings.configdict['pkg'].get('PROPERTIES', '').split()) or \ - phase in _ipc_phases or \ - 'network-sandbox' in settings['PORTAGE_RESTRICT'].split() + kwargs['networked'] = ( + 'network-sandbox' not in settings.features or + (phase == 'unpack' and + 'live' in settings['PORTAGE_PROPERTIES'].split()) or + (phase == 'test' and + 'test_network' in settings['PORTAGE_PROPERTIES'].split()) or + phase in _ipc_phases or + 'network-sandbox' in settings['PORTAGE_RESTRICT'].split()) kwargs['pidns'] = ('pid-sandbox' in settings.features and phase not in _global_pid_phases) diff --git a/man/make.conf.5 b/man/make.conf.5 index 8d551c95e..badaea18e 100644 --- a/man/make.conf.5 +++ b/man/make.conf.5 @@ -1,4 +1,4 @@ -.TH "MAKE.CONF" "5" "Feb 2021" "Portage VERSION" "Portage" +.TH "MAKE.CONF" "5" "May 2021" "Portage VERSION" "Portage" .SH "NAME" make.conf \- custom settings for Portage .SH "SYNOPSIS" @@ -1139,6 +1139,25 @@ settings from ebuilds. See also \fBebuild\fR(5). Set this to cause portage to ignore any \fIQA_WX_LOAD\fR override settings from ebuilds. See also \fBebuild\fR(5). .TP +\fBALLOW_TEST\fR = \fI[token]...\fR +This variable can be used to select the kinds of additional tests to run, +particularly overriding \fBRESTRICT\fR="\fBtest\fR". It contains +a whitespace-separated list of tokens. The following tokens are currently +recognized: +.RS +.TP +.B all +Run tests in all packages, even if they specify \fBRESTRICT\fR="\fBtest\fR". +This option is certain to cause test failures, it is intended to be used +by developers when testing specific packages. +.TP +.B network +Run tests in packages specifying \fBPROPERTIES\fR="\fBtest_network\fR". Note +that this will most likely cause Internet access during the test suite which +could cause additional costs, privacy concerns and intermittent test failures. +.TP +.RE +.TP .B RESUMECOMMAND This variable contains the command used for resuming package sources that have been partially downloaded. It should be defined using the same format