[gentoo-commits] proj/portage:master commit in: lib/portage/package/ebuild/_config/, lib/portage/, lib/_emerge/

2022-11-29 Thread Sam James
commit: 854379debaaf30e3dad30974c3d4055a5c75d90b
Author: Oskari Pirhonen  gmail  com>
AuthorDate: Sun Nov 27 05:02:40 2022 +
Commit: Sam James  gentoo  org>
CommitDate: Wed Nov 30 06:01:00 2022 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=854379de

Fix some type errors

Knock out some low-hanging fruit given by running

mypy --pretty --show-error-context .

inside lib/ (191 total errors found).

portage/package/ebuild/_config/special_env_vars.py:248: error: Incompatible
types in assignment (expression has type "FrozenSet[str]", variable has type
"List[str]")  [assignment]
environ_whitelist = frozenset(environ_whitelist)
^~~~
portage/package/ebuild/_config/special_env_vars.py:353: error: Incompatible
types in assignment (expression has type "FrozenSet[str]", variable has type
"List[str]")  [assignment]
environ_filter = frozenset(environ_filter)
 ^
portage/checksum.py:342: error: Incompatible types in assignment (expression
has type "int", variable has type "bool")  [assignment]
prelink_capable = 1
  ^
_emerge/Package.py: note: At top level:
_emerge/Package.py:865: error: Incompatible types in assignment (expression has
type "FrozenSet[str]", variable has type "Set[str]")  [assignment]
_all_metadata_keys = frozenset(_all_metadata_keys)
 ^
portage/getbinpkg.py:46: error: Incompatible types in assignment (expression
has type "Tuple[Type[Exception], ...]", variable has type
"List[Type[Exception]]")  [assignment]
_all_errors = tuple(_all_errors)
  ^~

Signed-off-by: Oskari Pirhonen  gmail.com>
Closes: https://github.com/gentoo/portage/pull/948
Signed-off-by: Sam James  gentoo.org>

 lib/_emerge/Package.py |   4 +-
 lib/portage/checksum.py|   2 +-
 lib/portage/getbinpkg.py   |   4 +-
 .../package/ebuild/_config/special_env_vars.py | 508 ++---
 4 files changed, 248 insertions(+), 270 deletions(-)

diff --git a/lib/_emerge/Package.py b/lib/_emerge/Package.py
index c50349e27..afb69024e 100644
--- a/lib/_emerge/Package.py
+++ b/lib/_emerge/Package.py
@@ -860,9 +860,7 @@ class Package(Task):
 return pkg
 
 
-_all_metadata_keys = set(x for x in portage.auxdbkeys)
-_all_metadata_keys.update(Package.metadata_keys)
-_all_metadata_keys = frozenset(_all_metadata_keys)
+_all_metadata_keys = 
frozenset(set(portage.auxdbkeys).union(Package.metadata_keys))
 
 _PackageMetadataWrapperBase = slot_dict_class(_all_metadata_keys)
 

diff --git a/lib/portage/checksum.py b/lib/portage/checksum.py
index 85cc36af3..7421b1c98 100644
--- a/lib/portage/checksum.py
+++ b/lib/portage/checksum.py
@@ -339,7 +339,7 @@ if os.path.exists(PRELINK_BINARY):
 proc.communicate()
 status = proc.wait()
 if os.WIFEXITED(status) and os.WEXITSTATUS(status) == os.EX_OK:
-prelink_capable = 1
+prelink_capable = True
 del cmd, proc, status
 
 

diff --git a/lib/portage/getbinpkg.py b/lib/portage/getbinpkg.py
index 799f5b171..8d06ad862 100644
--- a/lib/portage/getbinpkg.py
+++ b/lib/portage/getbinpkg.py
@@ -43,8 +43,6 @@ except ImportError as e:
 else:
 _all_errors.append(http_client_error)
 
-_all_errors = tuple(_all_errors)
-
 
 def make_metadata_dict(data):
 warnings.warn(
@@ -615,7 +613,7 @@ def dir_get_metadata(
 
 try:
 conn = create_conn(baseurl, conn)[0]
-except _all_errors as e:
+except tuple(_all_errors) as e:
 # ftplib.FTP(host) can raise errors like this:
 #   socket.error: (111, 'Connection refused')
 sys.stderr.write("!!! %s\n" % (e,))

diff --git a/lib/portage/package/ebuild/_config/special_env_vars.py 
b/lib/portage/package/ebuild/_config/special_env_vars.py
index 1de62e421..37fc2a290 100644
--- a/lib/portage/package/ebuild/_config/special_env_vars.py
+++ b/lib/portage/package/ebuild/_config/special_env_vars.py
@@ -72,8 +72,6 @@ env_blacklist = frozenset(
 )
 )
 
-environ_whitelist = []
-
 # Whitelisted variables are always allowed to enter the ebuild
 # environment. Generally, this only includes special portage
 # variables. Ebuilds can unset variables that are not whitelisted
@@ -82,275 +80,259 @@ environ_whitelist = []
 # important to set our special BASH_ENV variable in the ebuild
 # environment in order to prevent sandbox from sourcing /etc/profile
 # in it's bashrc (causing major leakage).
-environ_whitelist += [
-"ACCEPT_LICENSE",
-"BASH_ENV",
-"BASH_FUNCin_portage_iuse%%",
-"BINPKG_FORMAT",
-"BROOT",
-"BUILD_ID",
-"BUILD_PREFIX",
-"COLUMNS",
-"D",
-"DISTDIR",
-"DOC_SYMLINKS_DIR",
-"EAPI",
-"EBUILD",
-"EBUILD_FORCE_TEST",
-"EBUILD_PHASE",
-"EBUILD_PHASE_FUNC",
-"ECLASSDIR",
-"ECLASS_DEPTH",
-"ED

[gentoo-commits] proj/portage:master commit in: lib/portage/package/ebuild/_config/, /, lib/portage/package/ebuild/

2022-11-23 Thread Sam James
commit: e4902028b2cc86957fd91f411662b9710100e771
Author: James Le Cuirot  gentoo  org>
AuthorDate: Tue Nov 27 22:48:35 2018 +
Commit: Sam James  gentoo  org>
CommitDate: Wed Nov 23 23:01:57 2022 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=e4902028

Fix definition of ESYSROOT to use SYSROOT's prefix

For a given location, we were basing ESYSROOT on the prefix of that
location instead of the prefix used by the SYSROOT location. For
example, if BROOT=/foo, ROOT=/bar, EPREFIX=/baz, EROOT=/bar/baz, and
SYSROOT=/ then ESYSROOT should be /foo, not /baz.

Signed-off-by: James Le Cuirot  gentoo.org>
Closes: https://github.com/gentoo/portage/pull/932
Signed-off-by: Sam James  gentoo.org>

 NEWS   |  5 +
 lib/portage/package/ebuild/_config/LocationsManager.py | 11 +--
 lib/portage/package/ebuild/config.py   |  2 +-
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/NEWS b/NEWS
index a0463aa4c..1426a0856 100644
--- a/NEWS
+++ b/NEWS
@@ -26,6 +26,11 @@ Bug fixes:
   fatal for now. The number of failures in bug #870412 is too large for the 
time
   being.
 
+* Fix definition of ESYSROOT to use SYSROOT's prefix. For a given location, we
+  were basing ESYSROOT on the prefix of that location instead of the prefix 
used
+  by the SYSROOT location. For example, if BROOT=/foo, ROOT=/bar, EPREFIX=/baz,
+  EROOT=/bar/baz, and SYSROOT=/ then ESYSROOT should be /foo, not /baz.
+
 portage-3.0.39 (2022-11-20)
 --
 

diff --git a/lib/portage/package/ebuild/_config/LocationsManager.py 
b/lib/portage/package/ebuild/_config/LocationsManager.py
index 5c3592f5d..a92407dbd 100644
--- a/lib/portage/package/ebuild/_config/LocationsManager.py
+++ b/lib/portage/package/ebuild/_config/LocationsManager.py
@@ -93,8 +93,6 @@ class LocationsManager:
 + os.sep
 )
 
-self.esysroot = self.sysroot.rstrip(os.sep) + self.eprefix + os.sep
-
 # TODO: Set this via the constructor using
 # PORTAGE_OVERRIDE_EPREFIX.
 self.broot = portage.const.EPREFIX
@@ -405,6 +403,15 @@ class LocationsManager:
 
 self.eroot = self.target_root.rstrip(os.sep) + self.eprefix + os.sep
 
+# In a cross-prefix scenario where SYSROOT=/ and ROOT=/, assume we want
+# ESYSROOT to point to the target prefix.
+if self.sysroot == self.target_root:
+self.esysroot = self.sysroot.rstrip(os.sep) + self.eprefix + os.sep
+elif self.sysroot == "/":
+self.esysroot = self.broot + os.sep
+else:
+self.esysroot = self.sysroot
+
 self.global_config_path = GLOBAL_CONFIG_PATH
 if portage.const.EPREFIX:
 self.global_config_path = os.path.join(

diff --git a/lib/portage/package/ebuild/config.py 
b/lib/portage/package/ebuild/config.py
index 74f7ab371..a37b373cf 100644
--- a/lib/portage/package/ebuild/config.py
+++ b/lib/portage/package/ebuild/config.py
@@ -424,7 +424,6 @@ class config:
 eprefix = locations_manager.eprefix
 config_root = locations_manager.config_root
 sysroot = locations_manager.sysroot
-esysroot = locations_manager.esysroot
 broot = locations_manager.broot
 abs_user_config = locations_manager.abs_user_config
 make_conf_paths = [
@@ -467,6 +466,7 @@ class config:
 locations_manager.set_root_override(make_conf.get("ROOT"))
 target_root = locations_manager.target_root
 eroot = locations_manager.eroot
+esysroot = locations_manager.esysroot
 self.global_config_path = locations_manager.global_config_path
 
 # The expand_map is used for variable substitution



[gentoo-commits] proj/portage:master commit in: lib/portage/package/ebuild/_config/, bin/, lib/portage/package/ebuild/, man/, ...

2021-05-19 Thread Michał Górny
commit: a88f4996a9c20a638c8bf9a42bcbbc28ce0cc8dc
Author: Michał Górny  gentoo  org>
AuthorDate: Wed May 12 15:53:15 2021 +
Commit: Michał Górny  gentoo  org>
CommitDate: Wed May 19 08:06:38 2021 +
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  gentoo.org>
Acked-by: Ulrich Müller  gentoo.org>
Signed-off-by: Michał Górny  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",
   

[gentoo-commits] proj/portage:master commit in: lib/portage/package/ebuild/_config/

2020-08-03 Thread Zac Medico
commit: 1eb1b4977f1ba79d0a31aacd5683423a022767ad
Author: Aaron Bauman  gentoo  org>
AuthorDate: Mon Aug  3 20:20:17 2020 +
Commit: Zac Medico  gentoo  org>
CommitDate: Mon Aug  3 21:15:27 2020 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=1eb1b497

lib/portage/package/ebuild/_config/KeywordsManager.py: drop unused-import

Signed-off-by: Aaron Bauman  gentoo.org>
Signed-off-by: Zac Medico  gentoo.org>

 lib/portage/package/ebuild/_config/KeywordsManager.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/lib/portage/package/ebuild/_config/KeywordsManager.py 
b/lib/portage/package/ebuild/_config/KeywordsManager.py
index 136f57c35..de9cdaede 100644
--- a/lib/portage/package/ebuild/_config/KeywordsManager.py
+++ b/lib/portage/package/ebuild/_config/KeywordsManager.py
@@ -7,13 +7,12 @@ __all__ = (
 
 import warnings
 
-from _emerge.Package import Package
 import portage
 from portage import os
-from portage.dep import ExtendedAtomDict, _repo_separator, _slot_separator
+from portage.dep import ExtendedAtomDict
 from portage.localization import _
 from portage.package.ebuild._config.helper import ordered_by_atom_specificity
-from portage.util import grabdict_package, stack_lists, writemsg
+from portage.util import grabdict_package, stack_lists
 from portage.versions import _pkg_str
 
 class KeywordsManager:



[gentoo-commits] proj/portage:master commit in: lib/portage/package/ebuild/_config/, lib/portage/util/_async/, lib/_emerge/, ...

2020-06-14 Thread Zac Medico
commit: ab7556a5c0df418d61148a05347f4c73115e5747
Author: Zac Medico  gentoo  org>
AuthorDate: Sun Mar  1 02:17:52 2020 +
Commit: Zac Medico  gentoo  org>
CommitDate: Sun Jun 14 22:42:09 2020 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=ab7556a5

Support PORTAGE_LOG_FILTER_FILE_CMD (bug 709746)

This variable specifies a command that filters build log output to a
log file. The plan is to extend this to support a separate filter for
tty output in the future.

In order to enable the EbuildPhase class to write elog messages to
the build log with PORTAGE_LOG_FILTER_FILE_CMD support, convert its
_elog method to a coroutine, and add a SchedulerInterface async_output
method for it to use.

Use a new BuildLogger class to manage log output (with or without a
filter command), with compression support provided by PipeLogger.
BuildLogger has a stdin property which provides access to a writable
binary file stream (refers to a pipe) that log content is written to.

Bug: https://bugs.gentoo.org/709746
Signed-off-by: Zac Medico  gentoo.org>

 lib/_emerge/AbstractEbuildProcess.py   |   3 +-
 lib/_emerge/BinpkgFetcher.py   |   3 +-
 lib/_emerge/EbuildFetcher.py   |   3 +-
 lib/_emerge/EbuildPhase.py |  47 +++--
 lib/_emerge/SpawnProcess.py|  58 ---
 lib/portage/dbapi/_MergeProcess.py |   3 +-
 .../package/ebuild/_config/special_env_vars.py |   8 +-
 lib/portage/util/_async/BuildLogger.py | 109 +
 lib/portage/util/_async/SchedulerInterface.py  |  32 +-
 man/make.conf.5|   7 +-
 10 files changed, 243 insertions(+), 30 deletions(-)

diff --git a/lib/_emerge/AbstractEbuildProcess.py 
b/lib/_emerge/AbstractEbuildProcess.py
index 1c1955cfe..ae1aae55f 100644
--- a/lib/_emerge/AbstractEbuildProcess.py
+++ b/lib/_emerge/AbstractEbuildProcess.py
@@ -1,4 +1,4 @@
-# Copyright 1999-2019 Gentoo Foundation
+# Copyright 1999-2020 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 import errno
@@ -196,6 +196,7 @@ class AbstractEbuildProcess(SpawnProcess):
null_fd = os.open('/dev/null', os.O_RDONLY)
self.fd_pipes[0] = null_fd
 
+   self.log_filter_file = 
self.settings.get('PORTAGE_LOG_FILTER_FILE_CMD')
try:
SpawnProcess._start(self)
finally:

diff --git a/lib/_emerge/BinpkgFetcher.py b/lib/_emerge/BinpkgFetcher.py
index 36d027de3..2e5861cc1 100644
--- a/lib/_emerge/BinpkgFetcher.py
+++ b/lib/_emerge/BinpkgFetcher.py
@@ -1,4 +1,4 @@
-# Copyright 1999-2018 Gentoo Foundation
+# Copyright 1999-2020 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 import functools
@@ -158,6 +158,7 @@ class _BinpkgFetcherProcess(SpawnProcess):
self.env = fetch_env
if settings.selinux_enabled():
self._selinux_type = settings["PORTAGE_FETCH_T"]
+   self.log_filter_file = 
settings.get('PORTAGE_LOG_FILTER_FILE_CMD')
SpawnProcess._start(self)
 
def _pipe(self, fd_pipes):

diff --git a/lib/_emerge/EbuildFetcher.py b/lib/_emerge/EbuildFetcher.py
index 1e40994fb..55349c33c 100644
--- a/lib/_emerge/EbuildFetcher.py
+++ b/lib/_emerge/EbuildFetcher.py
@@ -1,4 +1,4 @@
-# Copyright 1999-2018 Gentoo Foundation
+# Copyright 1999-2020 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 import copy
@@ -225,6 +225,7 @@ class _EbuildFetcherProcess(ForkProcess):
settings["NOCOLOR"] = nocolor
 
self._settings = settings
+   self.log_filter_file = 
settings.get('PORTAGE_LOG_FILTER_FILE_CMD')
ForkProcess._start(self)
 
# Free settings now since it's no longer needed in

diff --git a/lib/_emerge/EbuildPhase.py b/lib/_emerge/EbuildPhase.py
index 477e0ba97..ddb3dc719 100644
--- a/lib/_emerge/EbuildPhase.py
+++ b/lib/_emerge/EbuildPhase.py
@@ -26,6 +26,8 @@ from portage.package.ebuild.prepare_build_dirs import 
(_prepare_workdir,
 from portage.util.futures.compat_coroutine import coroutine
 from portage.util import writemsg
 from portage.util._async.AsyncTaskFuture import AsyncTaskFuture
+from portage.util._async.BuildLogger import BuildLogger
+from portage.util.futures import asyncio
 from portage.util.futures.executor.fork import ForkExecutor
 
 try:
@@ -69,6 +71,11 @@ class EbuildPhase(CompositeTask):
_locked_phases = ("setup", "preinst", "postinst", "prerm", "postrm")
 
def _start(self):
+   future = asyncio.ensure_future(self._async_start(), 
loop=self.scheduler)
+   self._start_task(AsyncTaskFuture(future=future), 
self._async_start_exit)
+
+   @coroutine
+   def _async_start(self):
 
   

[gentoo-commits] proj/portage:master commit in: lib/portage/package/ebuild/_config/

2020-04-12 Thread Zac Medico
commit: 5570a96ddc859851036035baa4da65df2daa51a0
Author: Zac Medico  gentoo  org>
AuthorDate: Sun Apr 12 23:11:06 2020 +
Commit: Zac Medico  gentoo  org>
CommitDate: Sun Apr 12 23:45:31 2020 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=5570a96d

special_env_vars: add ENV_UNSET to environ_whitelist (bug 700830)

Add ENV_UNSET to the environ_whitelist. Since DISPLAY is also in
the environ_whitelist, ENV_UNSET must also be in environ_whitelist
in order to unset DISPLAY.

Fixes: a5e02c92fd72 ("Support ENV_UNSET for EAPI 7")
Bug: https://bugs.gentoo.org/700830
Signed-off-by: Zac Medico  gentoo.org>

 lib/portage/package/ebuild/_config/special_env_vars.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/portage/package/ebuild/_config/special_env_vars.py 
b/lib/portage/package/ebuild/_config/special_env_vars.py
index dc01339f7..440dd00b2 100644
--- a/lib/portage/package/ebuild/_config/special_env_vars.py
+++ b/lib/portage/package/ebuild/_config/special_env_vars.py
@@ -47,7 +47,7 @@ environ_whitelist += [
"DISTDIR", "DOC_SYMLINKS_DIR", "EAPI", "EBUILD",
"EBUILD_FORCE_TEST",
"EBUILD_PHASE", "EBUILD_PHASE_FUNC", "ECLASSDIR", "ECLASS_DEPTH", "ED",
-   "EMERGE_FROM", "EPREFIX", "EROOT", "ESYSROOT",
+   "EMERGE_FROM", "ENV_UNSET", "EPREFIX", "EROOT", "ESYSROOT",
"FEATURES", "FILESDIR", "HOME", "MERGE_TYPE", "NOCOLOR", "PATH",
"PKGDIR",
"PKGUSE", "PKG_LOGDIR", "PKG_TMPDIR",



[gentoo-commits] proj/portage:master commit in: lib/portage/package/ebuild/_config/

2020-01-27 Thread Zac Medico
commit: af5b57ee4d3133d9a8ca2c16aa21b7176026c8cd
Author: Zac Medico  gentoo  org>
AuthorDate: Tue Jan 28 05:01:27 2020 +
Commit: Zac Medico  gentoo  org>
CommitDate: Tue Jan 28 05:02:36 2020 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=af5b57ee

Suppress /etc/portage/package.keywords warning for API consumers

Suggested-by: Jeroen Roovers  gentoo.org>
Bug: https://bugs.gentoo.org/706298
Signed-off-by: Zac Medico  gentoo.org>

 lib/portage/package/ebuild/_config/KeywordsManager.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/portage/package/ebuild/_config/KeywordsManager.py 
b/lib/portage/package/ebuild/_config/KeywordsManager.py
index 1c12ce58e..48397b022 100644
--- a/lib/portage/package/ebuild/_config/KeywordsManager.py
+++ b/lib/portage/package/ebuild/_config/KeywordsManager.py
@@ -1,4 +1,4 @@
-# Copyright 2010-2014 Gentoo Foundation
+# Copyright 2010-2020 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 __all__ = (
@@ -8,6 +8,7 @@ __all__ = (
 import warnings
 
 from _emerge.Package import Package
+import portage
 from portage import os
 from portage.dep import ExtendedAtomDict, _repo_separator, _slot_separator
 from portage.localization import _
@@ -63,7 +64,7 @@ class KeywordsManager(object):
recursive=1, allow_wildcard=True, 
allow_repo=True,
verify_eapi=False, allow_build_id=True)
 
-   if pkgdict:
+   if pkgdict and portage._internal_caller:
warnings.warn(_("%s is deprecated, use %s 
instead") %
(user_kwrds_path, 
user_accept_kwrds_path),
UserWarning)



[gentoo-commits] proj/portage:master commit in: lib/portage/package/ebuild/_config/

2020-01-22 Thread Zac Medico
commit: 7e50a057958624dd728e858a3c07517240f85d02
Author: Zac Medico  gentoo  org>
AuthorDate: Sat Jan 18 06:06:27 2020 +
Commit: Zac Medico  gentoo  org>
CommitDate: Thu Jan 23 06:01:14 2020 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=7e50a057

UserWarning if /etc/portage/package.keywords exists

The /etc/portage/package.keywords file has been long deprecated
in favor of /etc/portage/package.accept_keywords. The file would
be useful if we could make it behave like package.keywords in
profiles (see bug 491166), but it's safest if we trigger a
UserWarning for some time before we change the meaning in a
future version of portage. The message looks like this:

UserWarning: /etc/portage/package.keywords is deprecated, use 
/etc/portage/package.accept_keywords instead

Bug: https://bugs.gentoo.org/491166
Bug: https://bugs.gentoo.org/607852
Signed-off-by: Zac Medico  gentoo.org>

 lib/portage/package/ebuild/_config/KeywordsManager.py | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/lib/portage/package/ebuild/_config/KeywordsManager.py 
b/lib/portage/package/ebuild/_config/KeywordsManager.py
index fd0a6318d..1c12ce58e 100644
--- a/lib/portage/package/ebuild/_config/KeywordsManager.py
+++ b/lib/portage/package/ebuild/_config/KeywordsManager.py
@@ -5,6 +5,8 @@ __all__ = (
'KeywordsManager',
 )
 
+import warnings
+
 from _emerge.Package import Package
 from portage import os
 from portage.dep import ExtendedAtomDict, _repo_separator, _slot_separator
@@ -54,13 +56,20 @@ class KeywordsManager(object):
self.pkeywordsdict = ExtendedAtomDict(dict)
 
if user_config:
+   user_accept_kwrds_path = os.path.join(abs_user_config, 
"package.accept_keywords")
+   user_kwrds_path = os.path.join(abs_user_config, 
"package.keywords")
pkgdict = grabdict_package(
-   os.path.join(abs_user_config, 
"package.keywords"),
+   user_kwrds_path,
recursive=1, allow_wildcard=True, 
allow_repo=True,
verify_eapi=False, allow_build_id=True)
 
+   if pkgdict:
+   warnings.warn(_("%s is deprecated, use %s 
instead") %
+   (user_kwrds_path, 
user_accept_kwrds_path),
+   UserWarning)
+
for k, v in grabdict_package(
-   os.path.join(abs_user_config, 
"package.accept_keywords"),
+   user_accept_kwrds_path,
recursive=1, allow_wildcard=True, 
allow_repo=True,
verify_eapi=False, allow_build_id=True).items():
pkgdict.setdefault(k, []).extend(v)



[gentoo-commits] proj/portage:master commit in: lib/portage/package/ebuild/_config/, repoman/lib/repoman/, man/, ...

2019-11-26 Thread Ulrich Müller
commit: 511e00d9f65abea11dfd769baf2ee939e1584ede
Author: Ulrich Müller  gentoo  org>
AuthorDate: Fri Nov 22 10:19:15 2019 +
Commit: Ulrich Müller  gentoo  org>
CommitDate: Tue Nov 26 18:25:43 2019 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=511e00d9

Rename DCO_SIGNED_OFF_BY config variable to SIGNED_OFF_BY.

Provide compatibility support for old name.
Update make.conf.5 man page.

Bug: https://bugs.gentoo.org/667432
Signed-off-by: Ulrich Müller  gentoo.org>

 lib/portage/package/ebuild/_config/special_env_vars.py |  2 +-
 lib/portage/package/ebuild/config.py   |  3 ++-
 man/make.conf.5| 13 ++---
 repoman/lib/repoman/actions.py |  8 +---
 4 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/lib/portage/package/ebuild/_config/special_env_vars.py 
b/lib/portage/package/ebuild/_config/special_env_vars.py
index e72049e33..50e7a9604 100644
--- a/lib/portage/package/ebuild/_config/special_env_vars.py
+++ b/lib/portage/package/ebuild/_config/special_env_vars.py
@@ -152,7 +152,6 @@ environ_filter += [
"BINPKG_COMPRESS", "BINPKG_COMPRESS_FLAGS",
"CLEAN_DELAY", "COLLISION_IGNORE",
"CONFIG_PROTECT", "CONFIG_PROTECT_MASK",
-   "DCO_SIGNED_OFF_BY",
"EGENCACHE_DEFAULT_OPTS", "EMERGE_DEFAULT_OPTS",
"EMERGE_LOG_DIR",
"EMERGE_WARNING_DELAY",
@@ -182,6 +181,7 @@ environ_filter += [
"RESUMECOMMAND", "RESUMECOMMAND_FTP",
"RESUMECOMMAND_HTTP", "RESUMECOMMAND_HTTPS",
"RESUMECOMMAND_RSYNC", "RESUMECOMMAND_SFTP",
+   "SIGNED_OFF_BY",
"UNINSTALL_IGNORE", "USE_EXPAND_HIDDEN", "USE_ORDER",
"__PORTAGE_HELPER"
 ]

diff --git a/lib/portage/package/ebuild/config.py 
b/lib/portage/package/ebuild/config.py
index e0dda54d4..6efb5ae86 100644
--- a/lib/portage/package/ebuild/config.py
+++ b/lib/portage/package/ebuild/config.py
@@ -157,7 +157,8 @@ class config(object):
'PORTAGE_PYM_PATH', 'PORTAGE_PYTHONPATH'])
 
_deprecated_keys = {'PORTAGE_LOGDIR': 'PORT_LOGDIR',
-   'PORTAGE_LOGDIR_CLEAN': 'PORT_LOGDIR_CLEAN'}
+   'PORTAGE_LOGDIR_CLEAN': 'PORT_LOGDIR_CLEAN',
+   'SIGNED_OFF_BY': 'DCO_SIGNED_OFF_BY'}
 
_setcpv_aux_keys = ('BDEPEND', 'DEFINED_PHASES', 'DEPEND', 'EAPI', 
'HDEPEND',
'INHERITED', 'IUSE', 'REQUIRED_USE', 'KEYWORDS', 'LICENSE', 
'PDEPEND',

diff --git a/man/make.conf.5 b/man/make.conf.5
index 44d518dbb..78ff8cb06 100644
--- a/man/make.conf.5
+++ b/man/make.conf.5
@@ -1,4 +1,4 @@
-.TH "MAKE.CONF" "5" "Jul 2019" "Portage VERSION" "Portage"
+.TH "MAKE.CONF" "5" "Nov 2019" "Portage VERSION" "Portage"
 .SH "NAME"
 make.conf \- custom settings for Portage
 .SH "SYNOPSIS"
@@ -205,8 +205,7 @@ This variable is passed by the \fIebuild scripts\fR to the 
\fIconfigure\fR
 as \fI\-\-target=${CTARGET}\fR only if it is defined.
 .TP
 .B DCO_SIGNED_OFF_BY
-This variable may contain a name and email address which will be used by
-\fBrepoman\fR(1) to add a Signed\-off\-by line to each commit message.
+See \fISIGNED_OFF_BY\fR below.  Deprecated.
 .TP
 \fBDISTDIR\fR = \fI[path]\fR
 Defines the location of your local source file repository. After packages
@@ -1141,6 +1140,14 @@ Defines the location where created RPM packages will be 
stored.
 .br
 Defaults to /var/cache/rpm.
 .TP
+.B SIGNED_OFF_BY
+This variable may contain a name and email address which will be used by
+\fBrepoman\fR(1) to add a Signed\-off\-by line to each commit message.
+The meaning of a signoff depends on the project.  Typically, it certifies
+that the committer has the rights to submit the work under a free license
+and agrees to a Certificate of Origin.  (For example, see GLEP 76 for the
+Gentoo Linux policy: \fIhttps://www.gentoo.org/glep/glep-0076.html\fR.)
+.TP
 \fBSYNC\fR = \fI[RSYNC]\fR
 Insert your preferred rsync mirror here.  This rsync server
 is used to sync the local ebuild repository when `emerge \-\-sync` is run.

diff --git a/repoman/lib/repoman/actions.py b/repoman/lib/repoman/actions.py
index 92d4d4e94..56a5255bf 100644
--- a/repoman/lib/repoman/actions.py
+++ b/repoman/lib/repoman/actions.py
@@ -1,4 +1,6 @@
 # -*- coding:utf-8 -*-
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
 
 from __future__ import print_function, unicode_literals
 
@@ -402,7 +404,7 @@ the whole commit message to abort.
def get_commit_footer(self):
portage_version = getattr(portage, "VERSION", None)
gpg_key = self.repoman_settings.get("PORTAGE_GPG_KEY", "")
-   dco_sob = self.repoman_settings.get("DCO_SIGNED_OFF_BY", "")
+   signoff = self.repoman_settings.get("SIGNED_OFF_BY", "")
report_options = []
if self.options.force:
report_options.append("--force")
@@ -470,8 +472,8 @@ the whole commit m

[gentoo-commits] proj/portage:master commit in: lib/portage/package/ebuild/_config/

2019-05-20 Thread Zac Medico
commit: b7c510f76d83ef70738b03a925ffb4a36797750d
Author: Zac Medico  gentoo  org>
AuthorDate: Mon May 20 18:45:54 2019 +
Commit: Zac Medico  gentoo  org>
CommitDate: Mon May 20 19:12:58 2019 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=b7c510f7

Fix ACCEPT_LICENSE="-*" to behave as intended (bug 686406)

Fix prune_incremental to preserve the last -*, since otherwise an
empty value would trigger fallback to a default value. This ensures
that ACCEPT_LICENSE="-*" behaves as intended.

Signed-off-by: Zac Medico  gentoo.org>

 lib/portage/package/ebuild/_config/helper.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/portage/package/ebuild/_config/helper.py 
b/lib/portage/package/ebuild/_config/helper.py
index ee0c090a0..03eba2cc4 100644
--- a/lib/portage/package/ebuild/_config/helper.py
+++ b/lib/portage/package/ebuild/_config/helper.py
@@ -57,7 +57,9 @@ def prune_incremental(split):
break
elif x == '-*':
if i == 0:
-   split = []
+   # Preserve the last -*, since otherwise an 
empty value
+   # would trigger fallback to a default value.
+   split = ['-*']
else:
split = split[-i:]
break



[gentoo-commits] proj/portage:master commit in: lib/portage/package/ebuild/_config/, bin/, lib/portage/package/ebuild/

2019-04-15 Thread Zac Medico
commit: 9cac3bfa782fe7eaa27103821a980cadf9299421
Author: Douglas Anderson  chromium  org>
AuthorDate: Thu Mar 14 15:35:06 2019 +
Commit: Zac Medico  gentoo  org>
CommitDate: Mon Apr 15 23:01:56 2019 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=9cac3bfa

Speed up testing against IUSE by not using regexp

When trying to figure out why it took so long to do a no-op kernel
build (re-build when nothing changed) on Chrome OS, I tracked down one
slowdown to cros-kernel2_src_configure().  This function was taking
~900 ms to execute.

The bulk of that slowdown was in iterating over the list of config
fragments, specifically the "use ${fragment}" test.  We currently have
77 fragments so we were effectively calling the "use" function 77
times.

Digging through the portage code, the slow part of the "use" function
was the block of code to confirm that you specified each USE flag in
your IUSE.  Commenting out the whole "elif" block of code there sped
things up so that the entire cros-kernel2_src_configure() was now
taking ~130 ms.  This means that each call to the "use" function was
taking about 10 ms.

The specific part of the test that was slow was testing against the
regular expression.  It was specifically slow in the Chrome OS kernel
build because we inherit the "cros-board" eclass which populates a
huge number of boards in the USE flag, making the regular expression
totally unwieldly.

One way to speed this whole thing up is to use a bash associative
array.  Unfortunately arrays can't come in through environment
variables, so we'll write a function that declares the array the first
time it's needed.

With this version of the code cros-kernel2_src_configure() now takes
~190 ms which seems like it's OK.  AKA 77 checks against IUSE took 60
ms or less than 1 ms per check.

NOTE: to keep EAPI 4 and older working, we keep doing the regular
expression tests there, though we now do it in the __in_portage_iuse()
function.  In at least one test the extra overhead of the function
made testing USE flags on EAPI 4 ~15% slower, but presumably this is
OK as we want to encourage folks to move to the newer EAPIs.

BUG=chromium:767073
TEST=Time some builds; confirm bad use flags still caught.

Change-Id: Ic74fa49bdf002399ba0d6c41f42d4632b07127a9
Reviewed-on: https://chromium-review.googlesource.com/1524641
Commit-Ready: Douglas Anderson  chromium.org>
Tested-by: Douglas Anderson  chromium.org>
Reviewed-by: Douglas Anderson  chromium.org>
See: 
https://chromium.googlesource.com/chromiumos/third_party/portage_tool/+/82a0776602df5707606de2099b93b8b7b1cc34a1
Bug: https://bugs.gentoo.org/680810
Signed-off-by: Zac Medico  gentoo.org>

 bin/ebuild.sh|  4 ++--
 bin/phase-helpers.sh |  6 +++---
 .../package/ebuild/_config/special_env_vars.py   |  7 ---
 lib/portage/package/ebuild/config.py | 20 +---
 4 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/bin/ebuild.sh b/bin/ebuild.sh
index d3bf0fd29..20dff6f3f 100755
--- a/bin/ebuild.sh
+++ b/bin/ebuild.sh
@@ -763,8 +763,8 @@ else
 
# If ${EBUILD_FORCE_TEST} == 1 and USE came from ${T}/environment
# then it might not have USE=test like it's supposed to here.
-   if [[ ${EBUILD_PHASE} == test && ${EBUILD_FORCE_TEST} == 1 &&
-   test =~ ${PORTAGE_IUSE} ]] && ! has test ${USE} ; then
+   if [[ ${EBUILD_PHASE} == test && ${EBUILD_FORCE_TEST} == 1 ]] &&
+   ___in_portage_iuse test && ! has test ${USE} ; then
export USE="${USE} test"
fi
declare -r USE

diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index ba3f27930..64a82b4b7 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -237,9 +237,9 @@ use() {
# Make sure we have this USE flag in IUSE, but exempt binary
# packages for API consumers like Entropy which do not require
# a full profile with IUSE_IMPLICIT and stuff (see bug #456830).
-   elif [[ -n $PORTAGE_IUSE && -n $EBUILD_PHASE &&
-   -n $PORTAGE_INTERNAL_CALLER ]] ; then
-   if [[ ! $u =~ $PORTAGE_IUSE ]] ; then
+   elif declare -f ___in_portage_iuse >/dev/null &&
+   [[ -n ${EBUILD_PHASE} && -n ${PORTAGE_INTERNAL_CALLER} ]] ; then
+   if ! ___in_portage_iuse "${u}"; then
if [[ ${EMERGE_FROM} != binary &&
! ${EAPI} =~ ^(0|1|2|3|4|4-python|4-slot-abi)$ 
]] ; then
# This is only strict starting with EAPI 5, 
since implicit IUSE

diff --git a/lib/portage/package/ebuild/_config/special_env_vars.py 
b/lib/portage/package/ebuild/_config/special_env_vars.py
index f9a0c3c0e..e72049e33 100644
--- a/lib/portage/package/ebuild/_config/special_env_vars.py
+++ b/lib/portage/package/ebuild/_config/special_env_vars.py
@@ -14,8 +14,8 @@ import re
 # to enter the config instance

[gentoo-commits] proj/portage:master commit in: lib/portage/package/ebuild/_config/

2018-08-17 Thread Zac Medico
commit: 836c5ba9352ef1fa2c14d29e8876533a9db72465
Author: Zac Medico  gentoo  org>
AuthorDate: Fri Aug 17 19:59:08 2018 +
Commit: Zac Medico  gentoo  org>
CommitDate: Fri Aug 17 22:40:09 2018 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=836c5ba9

LocationsManager: map empty root var to / (bug 663904)

When ROOT or PORTAGE_CONFIGROOT is entirely empty, map
the value to / since otherwise is becomes the current
working directory which gives undesirable results.

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

 lib/portage/package/ebuild/_config/LocationsManager.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/lib/portage/package/ebuild/_config/LocationsManager.py 
b/lib/portage/package/ebuild/_config/LocationsManager.py
index f7d7209ff..75320258f 100644
--- a/lib/portage/package/ebuild/_config/LocationsManager.py
+++ b/lib/portage/package/ebuild/_config/LocationsManager.py
@@ -60,7 +60,7 @@ class LocationsManager(object):
self.config_root = portage.const.EPREFIX + os.sep
 
self.config_root = normalize_path(os.path.abspath(
-   self.config_root)).rstrip(os.path.sep) + os.path.sep
+   self.config_root or os.sep)).rstrip(os.sep) + os.sep
 
self._check_var_directory("PORTAGE_CONFIGROOT", 
self.config_root)
self.abs_user_config = os.path.join(self.config_root, 
USER_CONFIG_PATH)
@@ -304,8 +304,7 @@ class LocationsManager(object):
self.target_root = root_overwrite
if not self.target_root.strip():
self.target_root = None
-   if self.target_root is None:
-   self.target_root = "/"
+   self.target_root = self.target_root or os.sep
 
self.target_root = normalize_path(os.path.abspath(
self.target_root)).rstrip(os.path.sep) + os.path.sep