[gentoo-commits] proj/portage:master commit in: bin/, lib/portage/dbapi/, lib/_emerge/
commit: d55d415a4f68b0d2b0c4dca00cce2d9aee934faa Author: Zac Medico gentoo org> AuthorDate: Sat Mar 9 22:01:18 2024 + Commit: Zac Medico gentoo org> CommitDate: Sat Mar 9 22:49:03 2024 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=d55d415a EbuildPhase/EbuildBinpkg: Ensure PKGDIR subdirectory permissions Bug: https://bugs.gentoo.org/71 Signed-off-by: Zac Medico gentoo.org> bin/misc-functions.sh| 8 ++-- lib/_emerge/EbuildBinpkg.py | 3 ++- lib/_emerge/EbuildPhase.py | 3 +++ lib/portage/dbapi/bintree.py | 18 +- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh index 4ce3acbfdc..696f2a6133 100755 --- a/bin/misc-functions.sh +++ b/bin/misc-functions.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Copyright 1999-2023 Gentoo Authors +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # # Miscellaneous shell functions that make use of the ebuild env but don't need @@ -511,7 +511,11 @@ __dyn_package() { export SANDBOX_ON="0" [[ -z "${PORTAGE_BINPKG_TMPFILE}" ]] && \ die "PORTAGE_BINPKG_TMPFILE is unset" - mkdir -p "${PORTAGE_BINPKG_TMPFILE%/*}" || die "mkdir failed" + if [[ ! -d ${PORTAGE_BINPKG_TMPFILE%/*} ]]; then + # Warn because we don't set PKGDIR directory permissions here. + ewarn "__dyn_package: Creating PORTAGE_BINPKG_TMPFILE parent dir: ${PORTAGE_BINPKG_TMPFILE%/*}" + mkdir -p "${PORTAGE_BINPKG_TMPFILE%/*}" || die "mkdir failed" + fi if [[ ! -z "${BUILD_ID}" ]]; then echo -n "${BUILD_ID}" > "${PORTAGE_BUILDDIR}"/build-info/BUILD_ID diff --git a/lib/_emerge/EbuildBinpkg.py b/lib/_emerge/EbuildBinpkg.py index 97b69ae018..26d828e4d2 100644 --- a/lib/_emerge/EbuildBinpkg.py +++ b/lib/_emerge/EbuildBinpkg.py @@ -1,4 +1,4 @@ -# Copyright 1999-2023 Gentoo Authors +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 import io @@ -29,6 +29,7 @@ class EbuildBinpkg(CompositeTask): pkg_allocated_path, build_id = bintree.getname_build_id( pkg.cpv, allocate_new=True ) +bintree._ensure_dir(os.path.dirname(pkg_allocated_path)) self.pkg_allocated_path = pkg_allocated_path self._binpkg_tmpfile = self.pkg_allocated_path + "." + str(portage.getpid()) diff --git a/lib/_emerge/EbuildPhase.py b/lib/_emerge/EbuildPhase.py index 86a64be78e..73c284fe41 100644 --- a/lib/_emerge/EbuildPhase.py +++ b/lib/_emerge/EbuildPhase.py @@ -254,6 +254,9 @@ class EbuildPhase(CompositeTask): ) else: raise InvalidBinaryPackageFormat(binpkg_format) +self.settings.mycpv._db.bintree._ensure_dir( +os.path.dirname(self.settings["PORTAGE_BINPKG_TMPFILE"]) +) def _async_start_exit(self, task): task.future.cancelled() or task.future.result() diff --git a/lib/portage/dbapi/bintree.py b/lib/portage/dbapi/bintree.py index 4ba1407cda..7bc1f60f6d 100644 --- a/lib/portage/dbapi/bintree.py +++ b/lib/portage/dbapi/bintree.py @@ -72,6 +72,7 @@ import traceback import warnings from gzip import GzipFile from itertools import chain +from pathlib import PurePath from urllib.parse import urlparse @@ -839,11 +840,18 @@ class binarytree: return pkgdir_gid = pkgdir_st.st_gid pkgdir_grp_mode = 0o2070 & pkgdir_st.st_mode -try: -ensure_dirs(path, gid=pkgdir_gid, mode=pkgdir_grp_mode, mask=0) -except PortageException: -if not os.path.isdir(path): -raise + +components = [] +for component in PurePath(path).relative_to(self.pkgdir).parts: +components.append(component) +component_path = os.path.join(self.pkgdir, *components) +try: +ensure_dirs( +component_path, gid=pkgdir_gid, mode=pkgdir_grp_mode, mask=0 +) +except PortageException: +if not os.path.isdir(component_path): +raise def _file_permissions(self, path): try:
[gentoo-commits] proj/portage:master commit in: bin/, lib/portage/package/ebuild/_config/
commit: 2410f8d7dde2ac12de4ec040696bcbb51e09ce9f Author: Sam James gentoo org> AuthorDate: Sat Aug 19 13:54:08 2023 + Commit: Sam James gentoo org> CommitDate: Sat Aug 19 14:49:34 2023 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=2410f8d7 save-ebuild-env.sh, special_env_vars.py: add https_proxy For parity with http_proxy. Bug: https://bugs.gentoo.org/691434 Bug: https://bugs.gentoo.org/835927 Bug: https://bugs.gentoo.org/911629 Signed-off-by: Sam James gentoo.org> bin/save-ebuild-env.sh | 2 +- lib/portage/package/ebuild/_config/special_env_vars.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh index 20cd868665..3a2560aabf 100644 --- a/bin/save-ebuild-env.sh +++ b/bin/save-ebuild-env.sh @@ -28,7 +28,7 @@ __save_ebuild_env() { # misc variables inherited from the calling environment unset COLORTERM DISPLAY EDITOR LESS LESSOPEN LOGNAME LS_COLORS PAGER \ - TERM TERMCAP USER ftp_proxy http_proxy no_proxy + TERM TERMCAP USER ftp_proxy http_proxy https_proxy no_proxy # other variables inherited from the calling environment unset CVS_RSH ECHANGELOG_USER GPG_AGENT_INFO \ diff --git a/lib/portage/package/ebuild/_config/special_env_vars.py b/lib/portage/package/ebuild/_config/special_env_vars.py index beb411188c..ef8f06abe3 100644 --- a/lib/portage/package/ebuild/_config/special_env_vars.py +++ b/lib/portage/package/ebuild/_config/special_env_vars.py @@ -215,6 +215,7 @@ environ_whitelist = frozenset( "USER", "ftp_proxy", "http_proxy", +"https_proxy", "no_proxy", # tempdir settings "TMPDIR",
[gentoo-commits] proj/portage:master commit in: bin/, lib/portage/util/
commit: 041da67db3a61d19fa5b287db4da9c51794af115 Author: Sam James gentoo org> AuthorDate: Mon Oct 17 22:07:58 2022 + Commit: Sam James gentoo org> CommitDate: Mon Oct 17 22:12:04 2022 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=041da67d xz: pass -q to xz Avoids noise from memlimit-compress. Signed-off-by: Sam James gentoo.org> bin/ecompress | 2 +- lib/portage/util/compression_probe.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ecompress b/bin/ecompress index e78d6931f..78a53ccac 100755 --- a/bin/ecompress +++ b/bin/ecompress @@ -128,7 +128,7 @@ if [[ ${PORTAGE_COMPRESS_FLAGS+set} != "set" ]] ; then # See: https://bugs.gentoo.org/672916 # Setting '--rm' will remove the source files after a successful compression. lz4) PORTAGE_COMPRESS_FLAGS="-m --rm";; - xz) PORTAGE_COMPRESS_FLAGS="-9 -T$(___makeopts_jobs) --memlimit-compress=50%";; + xz) PORTAGE_COMPRESS_FLAGS="-9 -T$(___makeopts_jobs) --memlimit-compress=50% -q";; zstd) PORTAGE_COMPRESS_FLAGS="-q --rm -T$(___makeopts_jobs)";; esac fi diff --git a/lib/portage/util/compression_probe.py b/lib/portage/util/compression_probe.py index ddd8cf9ad..66c7aeb47 100644 --- a/lib/portage/util/compression_probe.py +++ b/lib/portage/util/compression_probe.py @@ -37,7 +37,7 @@ _compressors = { "package": "app-arch/lzop", }, "xz": { -"compress": "xz -T{JOBS} --memlimit-compress=50% ${BINPKG_COMPRESS_FLAGS}", +"compress": "xz -T{JOBS} --memlimit-compress=50% -q ${BINPKG_COMPRESS_FLAGS}", "decompress": "xz -T{JOBS} -d", "package": "app-arch/xz-utils", },
[gentoo-commits] proj/portage:master commit in: bin/, lib/portage/util/, lib/portage/, lib/portage/_emirrordist/
commit: 205d41608e55f78b620f8c3a0cb204c88df041ee Author: Mike Gilbert gentoo org> AuthorDate: Sat Jul 9 04:26:12 2022 + Commit: Mike Gilbert gentoo org> CommitDate: Mon Aug 1 17:30:28 2022 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=205d4160 Avoid calling root-level logging functions Instead, establish a named logger in each module. This will allow for easier filtering of log messages if we ever expand the use of the logging module. Closes: https://github.com/gentoo/portage/pull/849 Signed-off-by: Mike Gilbert gentoo.org> bin/doins.py | 8 +++-- lib/portage/_emirrordist/Config.py | 10 +++ lib/portage/_emirrordist/ContentDB.py| 6 ++-- lib/portage/_emirrordist/DeletionIterator.py | 8 +++-- lib/portage/_emirrordist/DeletionTask.py | 28 +- lib/portage/_emirrordist/FetchTask.py| 44 +++- lib/portage/_emirrordist/MirrorDistTask.py | 36 +++ lib/portage/eapi.py | 2 ++ lib/portage/util/shelve.py | 4 ++- 9 files changed, 79 insertions(+), 67 deletions(-) diff --git a/bin/doins.py b/bin/doins.py index 087756218..7905c5c0d 100644 --- a/bin/doins.py +++ b/bin/doins.py @@ -26,6 +26,8 @@ import sys from portage.util import movefile from portage.util.file_copy import copyfile +logger = logging.getLogger("portage.bin.doins") + def _warn(helper, msg): """Output warning message to stderr. @@ -199,7 +201,7 @@ class _InsInProcessInstallRunner: if self._parsed_options.preserve_timestamps: _set_timestamps(sstat, dest) except Exception: -logging.exception( +logger.exception( "Failed to copy file: " "_parsed_options=%r, source=%r, dest_dir=%r", self._parsed_options, source, @@ -383,7 +385,7 @@ class _InstallRunner: except Exception: if self._helpers_can_die: raise -logging.exception("install_dir failed.") +logger.exception("install_dir failed.") def _doins(opts, install_runner, relpath, source_root): @@ -428,7 +430,7 @@ def _doins(opts, install_runner, relpath, source_root): os.symlink(linkto, dest) return True except Exception: -logging.exception( +logger.exception( "Failed to create symlink: " "opts=%r, relpath=%r, source_root=%r", opts, relpath, diff --git a/lib/portage/_emirrordist/Config.py b/lib/portage/_emirrordist/Config.py index 78b7a482a..734313c07 100644 --- a/lib/portage/_emirrordist/Config.py +++ b/lib/portage/_emirrordist/Config.py @@ -12,6 +12,8 @@ from portage.package.ebuild.fetch import MirrorLayoutConfig from portage.util import grabdict, grablines from .ContentDB import ContentDB +logger = logging.getLogger(__name__) + class Config: def __init__(self, options, portdb, event_loop): @@ -89,13 +91,11 @@ class Config: def _open_log(self, log_desc, log_path, mode): if log_path is None or getattr(self.options, "dry_run", False): -log_func = logging.info +log_func = logger.info line_format = "%s: %%s" % log_desc add_newline = False if log_path is not None: -logging.warning( -"dry-run: %s log " "redirected to logging.info" % log_desc -) +logger.warning("dry-run: %s log redirected to logging.info" % log_desc) else: self._open_files.append(io.open(log_path, mode=mode, encoding="utf_8")) line_format = "%s\n" @@ -137,7 +137,7 @@ class Config: db = dbshelve.open(db_file, flags=open_flag) if dry_run: -logging.warning("dry-run: %s db opened in readonly mode" % db_desc) +logger.warning("dry-run: %s db opened in readonly mode" % db_desc) if not isinstance(db, dict): volatile_db = dict((k, db[k]) for k in db) db.close() diff --git a/lib/portage/_emirrordist/ContentDB.py b/lib/portage/_emirrordist/ContentDB.py index 6a5efbe95..ac6140257 100644 --- a/lib/portage/_emirrordist/ContentDB.py +++ b/lib/portage/_emirrordist/ContentDB.py @@ -8,6 +8,8 @@ import typing from portage.package.ebuild.fetch import DistfileName +logger = logging.getLogger(__name__) + class ContentDB: """ @@ -110,10 +112,10 @@ class ContentDB: pass if remaining: -logging.debug(("drop '%s' revision(s) from content db") % filename) +logger.debug(("drop '%s' revision(s) from content db") % filename) self._shelve[distfile_key] = remaining else: -logging.debug(("drop '%s' from content db") %
[gentoo-commits] proj/portage:master commit in: bin/, lib/portage/_sets/, lib/portage/, lib/portage/cache/
commit: 4354ceea00b531054f552330371194bbbdb3efb1 Author: Thomas Bracht Laumann Jespersen laumann xyz> AuthorDate: Tue Apr 12 12:32:27 2022 + Commit: Sam James gentoo org> CommitDate: Wed Apr 13 03:26:36 2022 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=4354ceea cleanup: replace '== None' with 'is None' Essentially the following script: find -name '*.py' |xargs sed -i -e 's/== None/is None/g' Reading through DEVELOPING it says to prefer 'foo is not None' over 'foo != None' and grepping for '== None' got a few hits. Signed-off-by: Thomas Bracht Laumann Jespersen laumann.xyz> Signed-off-by: Sam James gentoo.org> bin/ebuild| 2 +- bin/portageq | 2 +- lib/portage/_sets/files.py| 2 +- lib/portage/cache/anydbm.py | 2 +- lib/portage/cache/cache_errors.py | 2 +- lib/portage/mail.py | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/ebuild b/bin/ebuild index bab8d52ad..546ab9d1c 100755 --- a/bin/ebuild +++ b/bin/ebuild @@ -435,7 +435,7 @@ for arg in pargs: except PermissionDenied as e: portage.writemsg("!!! Permission Denied: %s\n" % (e,), noiselevel=-1) a = 1 -if a == None: +if a is None: print("Could not run the required binary?") a = 127 if a: diff --git a/bin/portageq b/bin/portageq index 73657650c..a4ee319a0 100755 --- a/bin/portageq +++ b/bin/portageq @@ -1475,7 +1475,7 @@ def usage(argv): help_mode = "--help" in argv for name in commands: doc = docstrings.get(name) -if doc == None: +if doc is None: print(" " + name) print(" MISSING DOCUMENTATION!") print("") diff --git a/lib/portage/_sets/files.py b/lib/portage/_sets/files.py index 30fc80bd4..4d7f6f1ab 100644 --- a/lib/portage/_sets/files.py +++ b/lib/portage/_sets/files.py @@ -59,7 +59,7 @@ class StaticFileSet(EditablePackageSet): if len(line) == 0 and key != None: setattr(self, key, " ".join(value)) key = None -elif line[-1] == ":" and key == None: +elif line[-1] == ":" and key is None: key = line[:-1].lower() value = [] elif key != None: diff --git a/lib/portage/cache/anydbm.py b/lib/portage/cache/anydbm.py index ce0077e3f..2ab82a9f8 100644 --- a/lib/portage/cache/anydbm.py +++ b/lib/portage/cache/anydbm.py @@ -55,7 +55,7 @@ class database(fs_template.FsBased): # try again if failed try: -if self.__db == None: +if self.__db is None: # dbm.open() will not work with bytes in python-3.1: # TypeError: can't concat bytes to str if gdbm is None: diff --git a/lib/portage/cache/cache_errors.py b/lib/portage/cache/cache_errors.py index 080029734..bc8114ec1 100644 --- a/lib/portage/cache/cache_errors.py +++ b/lib/portage/cache/cache_errors.py @@ -36,7 +36,7 @@ class GeneralCacheCorruption(CacheError): class InvalidRestriction(CacheError): def __init__(self, key, restriction, exception=None): -if exception == None: +if exception is None: exception = "" self.key, self.restriction, self.ex = key, restriction, ex diff --git a/lib/portage/mail.py b/lib/portage/mail.py index 7ffb0d269..82bad6676 100644 --- a/lib/portage/mail.py +++ b/lib/portage/mail.py @@ -42,7 +42,7 @@ def create_message(sender, recipient, subject, body, attachments=None): from email.mime.multipart import MIMEMultipart as MultipartMessage from email.utils import formatdate -if attachments == None: +if attachments is None: mymessage = TextMessage(body) else: mymessage = MultipartMessage()
[gentoo-commits] proj/portage:master commit in: bin/, lib/portage/, lib/portage/package/ebuild/_config/
commit: 13f1a19ed3db9534e74d23254e41ef7c30c5b9fe Author: Michał Górny gentoo org> AuthorDate: Fri Sep 3 16:29:56 2021 + Commit: Michał Górny gentoo org> CommitDate: Fri Sep 10 07:16:40 2021 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=13f1a19e Include INHERIT value in generated cache PkgCore uses an additional md5-cache INHERIT key to indicate eclasses explicitly inherited in an ebuild. Update Portage to emit the same key to restore cache compatibility. Signed-off-by: Michał Górny gentoo.org> bin/ebuild.sh | 8 +++- bin/phase-functions.sh | 2 +- lib/portage/__init__.py| 2 +- lib/portage/package/ebuild/_config/special_env_vars.py | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/bin/ebuild.sh b/bin/ebuild.sh index 381bcb5c8..07ca58d22 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -402,6 +402,9 @@ inherit() { unset $__export_funcs_var has $1 $INHERITED || export INHERITED="$INHERITED $1" + if [[ ${ECLASS_DEPTH} -eq 1 ]]; then + export PORTAGE_EXPLICIT_INHERIT="${PORTAGE_EXPLICIT_INHERIT} $1" + fi fi shift @@ -648,6 +651,7 @@ if ! has "$EBUILD_PHASE" clean cleanrm ; then unset INHERITED IUSE REQUIRED_USE ECLASS E_IUSE E_REQUIRED_USE unset E_DEPEND E_RDEPEND E_PDEPEND E_BDEPEND E_IDEPEND E_PROPERTIES unset E_RESTRICT PROVIDES_EXCLUDE REQUIRES_EXCLUDE + unset PORTAGE_EXPLICIT_INHERIT if [[ $PORTAGE_DEBUG != 1 || ${-/x/} != $- ]] ; then source "$EBUILD" || die "error sourcing ebuild" @@ -757,7 +761,7 @@ if [[ $EBUILD_PHASE = depend ]] ; then metadata_keys=( DEPEND RDEPEND SLOT SRC_URI RESTRICT HOMEPAGE LICENSE DESCRIPTION KEYWORDS INHERITED IUSE REQUIRED_USE PDEPEND BDEPEND - EAPI PROPERTIES DEFINED_PHASES IDEPEND + EAPI PROPERTIES DEFINED_PHASES IDEPEND INHERIT ) if ! ___eapi_has_BDEPEND; then @@ -767,6 +771,8 @@ if [[ $EBUILD_PHASE = depend ]] ; then unset IDEPEND fi + INHERIT=${PORTAGE_EXPLICIT_INHERIT} + # The extra $(echo) commands remove newlines. for f in "${metadata_keys[@]}" ; do echo "${f}=$(echo ${!f})" >&${PORTAGE_PIPE_FD} || exit $? diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh index 0bb5d86e1..d3221993d 100644 --- a/bin/phase-functions.sh +++ b/bin/phase-functions.sh @@ -20,7 +20,7 @@ PORTAGE_READONLY_VARS="D EBUILD EBUILD_PHASE EBUILD_PHASE_FUNC \ PORTAGE_BUILD_USER PORTAGE_BUNZIP2_COMMAND \ PORTAGE_BZIP2_COMMAND PORTAGE_COLORMAP PORTAGE_CONFIGROOT \ PORTAGE_DEBUG PORTAGE_DEPCACHEDIR PORTAGE_EBUILD_EXIT_FILE \ - PORTAGE_ECLASS_LOCATIONS \ + PORTAGE_ECLASS_LOCATIONS PORTAGE_EXPLICIT_INHERIT \ 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_PROPERTIES \ diff --git a/lib/portage/__init__.py b/lib/portage/__init__.py index 232d77f0e..a41ca4323 100644 --- a/lib/portage/__init__.py +++ b/lib/portage/__init__.py @@ -519,7 +519,7 @@ auxdbkeys = ( 'RESTRICT', 'HOMEPAGE', 'LICENSE', 'DESCRIPTION', 'KEYWORDS', 'INHERITED', 'IUSE', 'REQUIRED_USE', 'PDEPEND', 'BDEPEND', 'EAPI', - 'PROPERTIES', 'DEFINED_PHASES', 'IDEPEND', + 'PROPERTIES', 'DEFINED_PHASES', 'IDEPEND', 'INHERIT', ) def portageexit(): diff --git a/lib/portage/package/ebuild/_config/special_env_vars.py b/lib/portage/package/ebuild/_config/special_env_vars.py index 456af1838..8e314a6d6 100644 --- a/lib/portage/package/ebuild/_config/special_env_vars.py +++ b/lib/portage/package/ebuild/_config/special_env_vars.py @@ -22,7 +22,7 @@ env_blacklist = frozenset(( "KEYWORDS", "LICENSE", "MERGE_TYPE", "PDEPEND", "PF", "PKGUSE", "PORTAGE_BACKGROUND", "PORTAGE_BACKGROUND_UNMERGE", "PORTAGE_BUILDDIR_LOCKED", - "PORTAGE_BUILT_USE", "PORTAGE_CONFIGROOT", + "PORTAGE_BUILT_USE", "PORTAGE_CONFIGROOT", "PORTAGE_EXPLICIT_INHERIT", "PORTAGE_INTERNAL_CALLER", "PORTAGE_IUSE", "PORTAGE_NONFATAL", "PORTAGE_PIPE_FD", "PORTAGE_REPO_NAME", "PORTAGE_USE", "PROPERTIES", "RDEPEND", "REPOSITORY",
[gentoo-commits] proj/portage:master commit in: bin/, lib/portage/package/ebuild/, lib/_emerge/
commit: 689c79fc573879086aa809b62d9d4f4c8418f1fb Author: Michał Górny gentoo org> AuthorDate: Tue May 25 14:00:32 2021 + Commit: Michał Górny gentoo org> CommitDate: Fri Jun 11 17:48:06 2021 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=689c79fc Use an explicit empty dir for pkg_* phases [WIP] Create and use an explicit ${PORTAGE_BUILDDIR}/empty as working directory for pkg_* phases, as proposed for EAPI 8. Note that this patch doesn't work fully -- empty is not cleared between pkg_preinst and pkg_postinst, and between pkg_prerm and pkg_postrm. Reviewed-by: Zac Medico gentoo.org> Signed-off-by: Michał Górny gentoo.org> bin/ebuild.sh | 6 +++--- bin/phase-functions.sh | 3 ++- lib/_emerge/EbuildPhase.py | 5 - lib/portage/package/ebuild/doebuild.py | 5 + 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/bin/ebuild.sh b/bin/ebuild.sh index c8fe3d0f1..2c3b985a9 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -186,9 +186,9 @@ export SANDBOX_ON=0 # Ensure that $PWD is sane whenever possible, to protect against # exploitation of insecure search path for python -c in ebuilds. # See bug #239560, bug #469338, and bug #595028. -if [[ -d ${HOME} ]]; then - # Use portage's temporary HOME directory if available. - cd "${HOME}" || die +# EAPI 8 requires us to use an empty directory here. +if [[ -d ${PORTAGE_BUILDDIR}/empty ]]; then + cd "${PORTAGE_BUILDDIR}/empty" || die else cd "${PORTAGE_PYM_PATH}" || \ die "PORTAGE_PYM_PATH does not exist: '${PORTAGE_PYM_PATH}'" diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh index 6a0300165..71411d414 100644 --- a/bin/phase-functions.sh +++ b/bin/phase-functions.sh @@ -278,7 +278,8 @@ __dyn_clean() { cd "${PORTAGE_PYM_PATH}" || \ die "PORTAGE_PYM_PATH does not exist: '${PORTAGE_PYM_PATH}'" - rm -rf "${PORTAGE_BUILDDIR}/image" "${PORTAGE_BUILDDIR}/homedir" + rm -rf "${PORTAGE_BUILDDIR}/image" "${PORTAGE_BUILDDIR}/homedir" \ + "${PORTAGE_BUILDDIR}/empty" rm -f "${PORTAGE_BUILDDIR}/.installed" if [[ $EMERGE_FROM = binary ]] || \ diff --git a/lib/_emerge/EbuildPhase.py b/lib/_emerge/EbuildPhase.py index 26c770d29..6c2e737c4 100644 --- a/lib/_emerge/EbuildPhase.py +++ b/lib/_emerge/EbuildPhase.py @@ -21,7 +21,7 @@ from portage.util._dyn_libs.soname_deps_qa import ( ) from portage.package.ebuild.prepare_build_dirs import (_prepare_workdir, _prepare_fake_distdir, _prepare_fake_filesdir) -from portage.util import writemsg +from portage.util import writemsg, ensure_dirs from portage.util._async.AsyncTaskFuture import AsyncTaskFuture from portage.util._async.BuildLogger import BuildLogger from portage.util.futures import asyncio @@ -41,6 +41,7 @@ portage.proxy.lazyimport.lazyimport(globals(), 'portage.elog:messages@elog_messages', 'portage.package.ebuild.doebuild:_check_build_log,' + \ '_post_phase_cmds,_post_phase_userpriv_perms,' + \ + '_post_phase_emptydir_cleanup,' + '_post_src_install_soname_symlinks,' + \ '_post_src_install_uid_fix,_postinst_bsdflags,' + \ '_post_src_install_write_metadata,' + \ @@ -89,6 +90,7 @@ class EbuildPhase(CompositeTask): 'logging', self.phase)) except OSError: pass + ensure_dirs(os.path.join(self.settings["PORTAGE_BUILDDIR"], "empty")) if self.phase in ('nofetch', 'pretend', 'setup'): @@ -270,6 +272,7 @@ class EbuildPhase(CompositeTask): settings = self.settings _post_phase_userpriv_perms(settings) + _post_phase_emptydir_cleanup(settings) if self.phase == "unpack": # Bump WORKDIR timestamp, in case tar gave it a timestamp diff --git a/lib/portage/package/ebuild/doebuild.py b/lib/portage/package/ebuild/doebuild.py index b1557edd7..0cbc2d01b 100644 --- a/lib/portage/package/ebuild/doebuild.py +++ b/lib/portage/package/ebuild/doebuild.py @@ -1770,6 +1770,11 @@ def _post_phase_userpriv_perms(mysettings): filemode=0o600, filemask=0) +def _post_phase_emptydir_cleanup(mysettings): + empty_dir = os.path.join(mysettings["PORTAGE_BUILDDIR"], "empty") + shutil.rmtree(empty_dir, ignore_errors=True) + + def _check_build_log(mysettings, out=None): """ Search the content of $PORTAGE_LOG_FILE if it exists
[gentoo-commits] proj/portage:master commit in: bin/, lib/portage/tests/resolver/
commit: aef49531a084eb39c7e1cde16fc1a22c060135fd Author: Zac Medico gentoo org> AuthorDate: Sun Jun 28 19:30:10 2020 + Commit: Zac Medico gentoo org> CommitDate: Thu Jul 2 17:11:25 2020 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=aef49531 ecompress: optimize docompress -x precompressed comparison Use sort and comm with temporary files in order to compare lists of docompress -x and precompressed files, since the file lists can be extremely large. Also strip ${D%/} from paths in order to reduce length. Bug: https://bugs.gentoo.org/721516 Suggested-by: Robin H. Johnson gentoo.org> Signed-off-by: Zac Medico gentoo.org> bin/ecompress| 27 lib/portage/tests/resolver/ResolverPlayground.py | 1 + 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/bin/ecompress b/bin/ecompress index 60b083834..7991bcfbe 100755 --- a/bin/ecompress +++ b/bin/ecompress @@ -19,29 +19,30 @@ while [[ $# -gt 0 ]] ; do shift skip_dirs=() - skip_files=() + > "${T}/.ecompress_skip_files" || die for skip; do if [[ -d ${ED%/}/${skip#/} ]]; then skip_dirs+=( "${ED%/}/${skip#/}" ) else rm -f "${ED%/}/${skip#/}.ecompress" || die - skip_files+=("${ED%/}/${skip#/}") + printf -- '%s\n' "${EPREFIX}/${skip#/}" >> "${T}/.ecompress_skip_files" || die fi done if [[ ${#skip_dirs[@]} -gt 0 ]]; then - while read -r -d ''; do - skip_files+=("${REPLY%.ecompress}") + while read -r -d '' skip; do + skip=${skip%.ecompress} + printf -- '%s\n' "${skip#${D%/}}" >> "${T}/.ecompress_skip_files" || die done < <(find "${skip_dirs[@]}" -name '*.ecompress' -print0 -delete || die) fi - if [[ ${#skip_files[@]} -gt 0 && -s ${T}/.ecompress_had_precompressed ]]; then - sed_args=() - for f in "${skip_files[@]}"; do - sed_args+=("s|^${f}\$||;") - done - sed_args+=('/^$/d') - sed -f - -i "${T}/.ecompress_had_precompressed" <<< "${sed_args[@]}" || die + if [[ -s ${T}/.ecompress_skip_files && -s ${T}/.ecompress_had_precompressed ]]; then + # Filter skipped files from ${T}/.ecompress_had_precompressed, + # using temporary files since these lists can be extremely large. + LC_COLLATE=C sort -u "${T}/.ecompress_skip_files" > "${T}/.ecompress_skip_files_sorted" || die + LC_COLLATE=C sort -u "${T}/.ecompress_had_precompressed" > "${T}/.ecompress_had_precompressed_sorted" || die + LC_COLLATE=C comm -13 "${T}/.ecompress_skip_files_sorted" "${T}/.ecompress_had_precompressed_sorted" > "${T}/.ecompress_had_precompressed" || die + rm -f "${T}/.ecompress_had_precompressed_sorted" "${T}/.ecompress_skip_files"{,_sorted} fi exit 0 @@ -81,7 +82,7 @@ while [[ $# -gt 0 ]] ; do continue 2 fi done - echo "${path}" >> "${T}"/.ecompress_had_precompressed + printf -- '%s\n' "${path#${D%/}}" >> "${T}"/.ecompress_had_precompressed || die ;; esac @@ -196,7 +197,7 @@ if [[ -s ${T}/.ecompress_had_precompressed ]]; then eqawarn n=0 while read -r f; do - eqawarn " ${f#${D%/}}" + eqawarn " ${f}" if [[ $(( n++ )) -eq 10 ]]; then eqawarn " ..." break diff --git a/lib/portage/tests/resolver/ResolverPlayground.py b/lib/portage/tests/resolver/ResolverPlayground.py index de80a0cc1..ec2e31ae9 100644 --- a/lib/portage/tests/resolver/ResolverPlayground.py +++ b/lib/portage/tests/resolver/ResolverPlayground.py @@ -91,6 +91,7 @@ class ResolverPlayground(object): "chgrp", "chmod", "chown", + "comm", "cp", "egrep", "env",
[gentoo-commits] proj/portage:master commit in: bin/, lib/portage/util/_dyn_libs/
commit: 25fbe7bc1a92a6877f2fecfba93ac932f359ce2f Author: Zac Medico gentoo org> AuthorDate: Sun Mar 29 18:09:33 2020 + Commit: Zac Medico gentoo org> CommitDate: Wed Apr 8 06:02:45 2020 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=25fbe7bc NeededEntry: infer implicit soname from file basename (bug 715162) For dynamic libraries, infer an implicit DT_SONAME setting from the file basename, which is consistent with dynamic linking behavior in practice. This makes it possible to resolve soname dependencies for musl's libc.so which lacks a DT_SONAME setting. Bug: https://bugs.gentoo.org/715162 Signed-off-by: Zac Medico gentoo.org> bin/misc-functions.sh | 6 ++ lib/portage/util/_dyn_libs/LinkageMapELF.py | 16 2 files changed, 22 insertions(+) diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh index 4f8a4112d..9efe99b87 100755 --- a/bin/misc-functions.sh +++ b/bin/misc-functions.sh @@ -183,6 +183,12 @@ install_qa_check() { soname=${l%%;*}; l=${l#*;} rpath=${l%%;*}; l=${l#*;}; [ "${rpath}" = " - " ] && rpath="" needed=${l%%;*}; l=${l#*;} + + # Infer implicit soname from basename (bug 715162). + if [[ -z ${soname} && $(file "${D%/}${obj}") == *"SB shared object"* ]]; then + soname=${obj##*/} + fi + echo "${obj} ${needed}" >> "${PORTAGE_BUILDDIR}"/build-info/NEEDED echo "${arch:3};${obj};${soname};${rpath};${needed}" >> "${PORTAGE_BUILDDIR}"/build-info/NEEDED.ELF.2 done } diff --git a/lib/portage/util/_dyn_libs/LinkageMapELF.py b/lib/portage/util/_dyn_libs/LinkageMapELF.py index 70bec116a..2d4929445 100644 --- a/lib/portage/util/_dyn_libs/LinkageMapELF.py +++ b/lib/portage/util/_dyn_libs/LinkageMapELF.py @@ -311,6 +311,22 @@ class LinkageMapELF(object): raise # File removed concurrently. continue + + # Infer implicit soname from basename (bug 715162). + if not entry.soname: + try: + proc = subprocess.Popen([b'file', + _unicode_encode(entry.filename, + encoding=_encodings['fs'], errors='strict')], + stdout=subprocess.PIPE) + out, err = proc.communicate() + proc.wait() + except EnvironmentError: + pass + else: + if b'SB shared object' in out: + entry.soname = os.path.basename(entry.filename) + entry.multilib_category = compute_multilib_category(elf_header) entry.filename = entry.filename[root_len:] owner = plibs.pop(entry.filename, None)
[gentoo-commits] proj/portage:master commit in: bin/, lib/portage/dbapi/
commit: b24a484ab190af9c9b96b9ef01837aded845fb54 Author: Zac Medico gentoo org> AuthorDate: Mon Nov 18 01:32:38 2019 + Commit: Zac Medico gentoo org> CommitDate: Mon Nov 18 01:41:27 2019 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=b24a484a dblink: add quickpkg method Bug: https://bugs.gentoo.org/699986 Signed-off-by: Zac Medico gentoo.org> bin/quickpkg | 34 -- lib/portage/dbapi/vartree.py | 50 2 files changed, 54 insertions(+), 30 deletions(-) diff --git a/bin/quickpkg b/bin/quickpkg index c28a3e382..df8c1a8e8 100755 --- a/bin/quickpkg +++ b/bin/quickpkg @@ -10,7 +10,6 @@ import math import signal import subprocess import sys -import tarfile from os import path as osp if osp.isfile(osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), ".portage_not_installed")): @@ -23,10 +22,8 @@ from portage.dbapi.dep_expand import dep_expand from portage.dep import Atom, use_reduce from portage.exception import (AmbiguousPackageName, InvalidAtom, InvalidData, InvalidDependString, PackageSetNotFound, PermissionDenied) -from portage.util import ConfigProtect, ensure_dirs, shlex_split, varexpand, _xattr +from portage.util import ensure_dirs, shlex_split, varexpand, _xattr xattr = _xattr.xattr -from portage.dbapi.vartree import dblink, tar_contents -from portage.checksum import perform_md5 from portage._sets import load_default_config, SETPREFIX from portage.process import find_binary from portage.util.compression_probe import _compressors @@ -35,13 +32,11 @@ from portage.util._eventloop.global_event_loop import global_event_loop def quickpkg_atom(options, infos, arg, eout): settings = portage.settings - root = portage.settings['ROOT'] eroot = portage.settings['EROOT'] trees = portage.db[eroot] vartree = trees["vartree"] vardb = vartree.dbapi bintree = trees["bintree"] - xattrs = 'xattr' in settings.features include_config = options.include_config == "y" include_unmodified_config = options.include_unmodified_config == "y" @@ -104,26 +99,6 @@ def quickpkg_atom(options, infos, arg, eout): eout.ewarn("%s: it might not be legal to redistribute this." % cpv) eout.ebegin("Building package for %s" % cpv) pkgs_for_arg += 1 - contents = dblnk.getcontents() - protect = None - if not include_config: - confprot = ConfigProtect(eroot, - shlex_split(settings.get("CONFIG_PROTECT", "")), - shlex_split(settings.get("CONFIG_PROTECT_MASK", "")), - case_insensitive=("case-insensitive-fs" - in settings.features)) - def protect(filename): - if not confprot.isprotected(filename): - return False - if include_unmodified_config: - file_data = contents[filename] - if file_data[0] == "obj": - orig_md5 = file_data[2].lower() - cur_md5 = perform_md5(filename, calc_prelink=1) - if orig_md5 == cur_md5: - return False - excluded_config_files.append(filename) - return True existing_metadata = dict(zip(fix_metadata_keys, vardb.aux_get(cpv, fix_metadata_keys))) category, pf = portage.catsplit(cpv) @@ -167,10 +142,9 @@ def quickpkg_atom(options, infos, arg, eout): cmd = [x for x in cmd if x != ""] with open(binpkg_tmpfile, "wb") as fobj: proc = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=fobj) - # The tarfile module will write pax headers holding the - # xattrs only if PAX_FORMAT is specified here. - with tarfile.open(mode="w|",format=tarfile.PAX_FORMAT if xattrs else tarfile.DEFAULT_FORMAT, fileobj=proc.stdin) as tar: - tar_contents(contents, root, tar, protect=protect, xattrs=xattrs) + excluded_config_files = dblnk.quickpkg(proc.stdin, + include_config=include_config, +
[gentoo-commits] proj/portage:master commit in: bin/, lib/portage/
commit: 0d18c696230bcabe007e35194e4b97a38f3b69f5 Author: Zac Medico gentoo org> AuthorDate: Sun Jan 20 04:02:35 2019 + Commit: Zac Medico gentoo org> CommitDate: Sun Jan 20 23:31:41 2019 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=0d18c696 pid-ns-init: fix child process signal disposition (bug 675828) Use subprocess.Popen to correctly configure the signal disposition of the child process, since os.fork leaves the signal disposition in a state which may be inappropriate for various signals including SIGPIPE, SIGQUIT, SIGTERM, and SIGINT. For python implementations other that CPython >= 3, use preexec_fn to manually configure the signal disposition (I have found that this is necessary for CPython 2.7 and all PyPy versions tested, including PyPy3). Bug: https://bugs.gentoo.org/675828 Signed-off-by: Zac Medico gentoo.org> bin/pid-ns-init| 39 +-- lib/portage/process.py | 1 + 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/bin/pid-ns-init b/bin/pid-ns-init index 182d00a43..f9b8cc4f3 100644 --- a/bin/pid-ns-init +++ b/bin/pid-ns-init @@ -2,25 +2,44 @@ # Copyright 2018-2019 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 +import errno import functools import os +import platform import signal +import subprocess import sys +if sys.version_info.major < 3 or platform.python_implementation() != 'CPython': + def signal_disposition_preexec(): + for signum in ( + signal.SIGHUP, + signal.SIGINT, + signal.SIGPIPE, + signal.SIGQUIT, + signal.SIGTERM, + ): + signal.signal(signum, signal.SIG_DFL) +else: + # CPython >= 3 subprocess.Popen handles this internally. + signal_disposition_preexec = None + + KILL_SIGNALS = ( signal.SIGINT, signal.SIGTERM, signal.SIGHUP, ) + def forward_kill_signal(main_child_pid, signum, frame): os.kill(main_child_pid, signum) def main(argv): if len(argv) < 2: - return 'Usage: {} or [arg]..'.format(argv[0]) + return 'Usage: {} or [arg]..'.format(argv[0]) if len(argv) == 2: # The child process is init (pid 1) in a child pid namespace, and @@ -28,14 +47,17 @@ def main(argv): # (forwarding signals to init and forwarding exit status to the parent # process). main_child_pid = int(argv[1]) + proc = None else: # The current process is init (pid 1) in a child pid namespace. - binary = argv[1] - args = argv[2:] + pass_fds, binary, args = tuple(int(fd) for fd in argv[1].split(',')), argv[2], argv[3:] - main_child_pid = os.fork() - if main_child_pid == 0: - os.execv(binary, args) + popen_kwargs = {} + if sys.version_info.major > 2: + popen_kwargs['pass_fds'] = pass_fds + proc = subprocess.Popen(args, executable=binary, + preexec_fn=signal_disposition_preexec, **popen_kwargs) + main_child_pid = proc.pid sig_handler = functools.partial(forward_kill_signal, main_child_pid) for signum in KILL_SIGNALS: @@ -50,6 +72,11 @@ def main(argv): continue raise if pid == main_child_pid: + if proc is not None: + # Suppress warning messages like this: + # ResourceWarning: subprocess 1234 is still running + proc.returncode = 0 + if os.WIFEXITED(status): return os.WEXITSTATUS(status) elif os.WIFSIGNALED(status): diff --git a/lib/portage/process.py b/lib/portage/process.py index 6af3ac37d..dd3d58ddc 100644 --- a/lib/portage/process.py +++ b/lib/portage/process.py @@ -571,6 +571,7 @@ def _exec(binary, mycommand, opt_name, fd_pipes, portage._python_interpreter, os.path.join(portage._bin_path, 'pid-ns-init'), + _unicode_encode(','.join(str(fd) for fd in fd_pipes)), binary] + myargs else: # Execute a supervisor process which will forward
[gentoo-commits] proj/portage:master commit in: bin/, lib/portage/
commit: fb406579b1d13c1ba23b28e0bb794c22878a58c0 Author: Zac Medico gentoo org> AuthorDate: Sun Jan 13 23:06:35 2019 + Commit: Zac Medico gentoo org> CommitDate: Tue Jan 15 05:45:55 2019 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=fb406579 pid-sandbox: execute pid-ns-init as pid 1 (bug 675312) Execute pid-ns-init as the first fork after unshare, as required for it to have pid 1 and become the default reaper of orphaned descendant processes. In _exec, exec a separate pid-ns-init process to behave as a supervisor which will forward signals to init and forward exit status to the parent process. Fixes: a75d5546e3a4 ("Introduce a tiny init replacement for inside pid namespace") Bug: https://bugs.gentoo.org/675312 Reviewed-by: Brian Dolbec gentoo.org> Signed-off-by: Zac Medico gentoo.org> bin/pid-ns-init| 44 lib/portage/process.py | 25 +++-- 2 files changed, 59 insertions(+), 10 deletions(-) diff --git a/bin/pid-ns-init b/bin/pid-ns-init index 843257b70..182d00a43 100644 --- a/bin/pid-ns-init +++ b/bin/pid-ns-init @@ -1,23 +1,59 @@ #!/usr/bin/env python -# Copyright 2018 Gentoo Authors +# Copyright 2018-2019 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 +import functools import os +import signal import sys +KILL_SIGNALS = ( + signal.SIGINT, + signal.SIGTERM, + signal.SIGHUP, +) + +def forward_kill_signal(main_child_pid, signum, frame): + os.kill(main_child_pid, signum) + + def main(argv): if len(argv) < 2: - return 'Usage: {} '.format(argv[0]) - main_child_pid = int(argv[1]) + return 'Usage: {} or [arg]..'.format(argv[0]) + + if len(argv) == 2: + # The child process is init (pid 1) in a child pid namespace, and + # the current process supervises from within the global pid namespace + # (forwarding signals to init and forwarding exit status to the parent + # process). + main_child_pid = int(argv[1]) + else: + # The current process is init (pid 1) in a child pid namespace. + binary = argv[1] + args = argv[2:] + + main_child_pid = os.fork() + if main_child_pid == 0: + os.execv(binary, args) + + sig_handler = functools.partial(forward_kill_signal, main_child_pid) + for signum in KILL_SIGNALS: + signal.signal(signum, sig_handler) # wait for child processes while True: - pid, status = os.wait() + try: + pid, status = os.wait() + except OSError as e: + if e.errno == errno.EINTR: + continue + raise if pid == main_child_pid: if os.WIFEXITED(status): return os.WEXITSTATUS(status) elif os.WIFSIGNALED(status): + signal.signal(os.WTERMSIG(status), signal.SIG_DFL) os.kill(os.getpid(), os.WTERMSIG(status)) # go to the unreachable place break diff --git a/lib/portage/process.py b/lib/portage/process.py index 7103b6b31..6af3ac37d 100644 --- a/lib/portage/process.py +++ b/lib/portage/process.py @@ -564,15 +564,28 @@ def _exec(binary, mycommand, opt_name, fd_pipes, noiselevel=-1) else: if unshare_pid: - # pid namespace requires us to become init - fork_ret = os.fork() - if fork_ret != 0: - os.execv(portage._python_interpreter, [ + main_child_pid = os.fork() + if main_child_pid == 0: + # pid namespace requires us to become init + binary, myargs = portage._python_interpreter, [ portage._python_interpreter, os.path.join(portage._bin_path, 'pid-ns-init'), - '%s' % fork_ret, - ])
[gentoo-commits] proj/portage:master commit in: bin/, lib/portage/package/ebuild/
commit: be2312f4f9bf854897431440734a765f5279c7d1 Author: Zac Medico gentoo org> AuthorDate: Wed Jan 2 23:40:57 2019 + Commit: Zac Medico gentoo org> CommitDate: Thu Jan 3 08:24:40 2019 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=be2312f4 ebuild.sh: sandbox write to ${PORTAGE_TMPDIR}/portage (bug 673738) In ebuild.sh, grant sandbox write access directly to ${PORTAGE_TMPDIR}/portage, since write access to ${PORTAGE_TMPDIR} itself is not needed. Also, remove the _check_temp_dir symlink check from bug 378403, since a symlink is permissible if write access is granted directly to ${PORTAGE_TMPDIR}/portage. Bug: https://bugs.gentoo.org/673738 Bug: https://bugs.gentoo.org/378403 Signed-off-by: Zac Medico gentoo.org> bin/ebuild.sh | 4 ++-- lib/portage/package/ebuild/doebuild.py | 27 ++- 2 files changed, 4 insertions(+), 27 deletions(-) diff --git a/bin/ebuild.sh b/bin/ebuild.sh index 00524d019..978643af7 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -161,8 +161,8 @@ addwrite() { __sb_append_var WRITE "$@" ; } adddeny(){ __sb_append_var DENY"$@" ; } addpredict() { __sb_append_var PREDICT "$@" ; } -addwrite "${PORTAGE_TMPDIR}" -addread "/:${PORTAGE_TMPDIR}" +addwrite "${PORTAGE_TMPDIR}/portage" +addread "/:${PORTAGE_TMPDIR}/portage" [[ -n ${PORTAGE_GPG_DIR} ]] && addpredict "${PORTAGE_GPG_DIR}" # Avoid sandbox violations in temporary directories. diff --git a/lib/portage/package/ebuild/doebuild.py b/lib/portage/package/ebuild/doebuild.py index 2dd458835..baebb9a27 100644 --- a/lib/portage/package/ebuild/doebuild.py +++ b/lib/portage/package/ebuild/doebuild.py @@ -82,6 +82,7 @@ from portage.util import ( apply_recursive_permissions, from portage.util.cpuinfo import get_cpu_count from portage.util.lafilefixer import rewrite_lafile from portage.util.compression_probe import _compressors +from portage.util.path import first_existing from portage.util.socks5 import get_socks5_proxy from portage.versions import _pkgsplit from _emerge.BinpkgEnvExtractor import BinpkgEnvExtractor @@ -1296,31 +1297,7 @@ def _check_temp_dir(settings): # as some people use a separate PORTAGE_TMPDIR mount # we prefer that as the checks below would otherwise be pointless # for those people. - tmpdir = os.path.realpath(settings["PORTAGE_TMPDIR"]) - if os.path.exists(os.path.join(tmpdir, "portage")): - checkdir = os.path.realpath(os.path.join(tmpdir, "portage")) - if ("sandbox" in settings.features or - "usersandox" in settings.features) and \ - not checkdir.startswith(tmpdir + os.sep): - msg = _("The 'portage' subdirectory of the directory " - "referenced by the PORTAGE_TMPDIR variable appears to be " - "a symlink. In order to avoid sandbox violations (see bug " - "#378403), you must adjust PORTAGE_TMPDIR instead of using " - "the symlink located at '%s'. A suitable PORTAGE_TMPDIR " - "setting would be '%s'.") % \ - (os.path.join(tmpdir, "portage"), checkdir) - lines = [] - lines.append("") - lines.append("") - lines.extend(wrap(msg, 72)) - lines.append("") - for line in lines: - if line: - line = "!!! %s" % (line,) - writemsg("%s\n" % (line,), noiselevel=-1) - return 1 - else: - checkdir = tmpdir + checkdir = first_existing(os.path.join(settings["PORTAGE_TMPDIR"], "portage")) if not os.access(checkdir, os.W_OK): writemsg(_("%s is not writable.\n"
[gentoo-commits] proj/portage:master commit in: bin/, lib/portage/
commit: a75d5546e3a49599280c222a75471981bf2a7837 Author: Michał Górny gentoo org> AuthorDate: Tue Nov 13 21:34:14 2018 + Commit: Michał Górny gentoo org> CommitDate: Sun Nov 18 12:25:04 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=a75d5546 Introduce a tiny init replacement for inside pid namespace Reviewed-by: Zac Medico gentoo.org> Signed-off-by: Michał Górny gentoo.org> bin/pid-ns-init| 30 ++ lib/portage/process.py | 11 ++- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/bin/pid-ns-init b/bin/pid-ns-init new file mode 100644 index 0..843257b70 --- /dev/null +++ b/bin/pid-ns-init @@ -0,0 +1,30 @@ +#!/usr/bin/env python +# Copyright 2018 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +import os +import sys + + +def main(argv): + if len(argv) < 2: + return 'Usage: {} '.format(argv[0]) + main_child_pid = int(argv[1]) + + # wait for child processes + while True: + pid, status = os.wait() + if pid == main_child_pid: + if os.WIFEXITED(status): + return os.WEXITSTATUS(status) + elif os.WIFSIGNALED(status): + os.kill(os.getpid(), os.WTERMSIG(status)) + # go to the unreachable place + break + + # this should never be reached + return 127 + + +if __name__ == '__main__': + sys.exit(main(sys.argv)) diff --git a/lib/portage/process.py b/lib/portage/process.py index dee126c3c..75ec299f0 100644 --- a/lib/portage/process.py +++ b/lib/portage/process.py @@ -544,13 +544,14 @@ def _exec(binary, mycommand, opt_name, fd_pipes, env, gid, groups, uid, umask, else: if unshare_pid: # pid namespace requires us to become init - # TODO: do init-ty stuff - # therefore, fork() ASAP fork_ret = os.fork() if fork_ret != 0: - pid, status = os.waitpid(fork_ret, 0) - assert pid == fork_ret - os._exit(status) + os.execv(portage._python_interpreter, [ + portage._python_interpreter, + os.path.join(portage._bin_path, + 'pid-ns-init'), + '%s' % fork_ret, + ]) if unshare_mount: # mark the whole filesystem as slave to avoid # mounts escaping the namespace
[gentoo-commits] proj/portage:master commit in: bin/, lib/portage/dbapi/, lib/_emerge/, cnf/, lib/portage/sync/modules/rsync/, /, ...
commit: 3f462e983b2e08107e0f7e4a2753d8deca4ac62a Author: Zac Medico gentoo org> AuthorDate: Mon Aug 6 23:38:55 2018 + Commit: Zac Medico gentoo org> CommitDate: Mon Aug 6 23:38:55 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=3f462e98 Refer to "ebuild repository" rather than "portage tree" README | 4 ++-- bin/ebuild | 2 +- bin/ebuild.sh | 2 +- cnf/make.conf.example | 8 lib/_emerge/actions.py | 2 +- lib/_emerge/create_world_atom.py| 2 +- lib/_emerge/depgraph.py | 2 +- lib/_emerge/search.py | 2 +- lib/portage/__init__.py | 2 +- lib/portage/_global_updates.py | 2 +- lib/portage/dbapi/porttree.py | 2 +- lib/portage/dbapi/vartree.py| 2 +- lib/portage/emaint/modules/merges/merges.py | 2 +- lib/portage/news.py | 2 +- lib/portage/package/ebuild/config.py| 2 +- lib/portage/sync/modules/rsync/rsync.py | 2 +- man/emerge.1| 10 +- man/make.conf.5 | 2 +- man/portage.5 | 6 +++--- repoman/README | 2 +- repoman/lib/repoman/__init__.py | 2 +- repoman/lib/repoman/utilities.py| 2 +- repoman/man/repoman.1 | 2 +- 23 files changed, 33 insertions(+), 33 deletions(-) diff --git a/README b/README index 311d036f4..cae987242 100644 --- a/README +++ b/README @@ -3,8 +3,8 @@ About Portage Portage is a package management system based on ports collections. The Package Manager Specification Project (PMS) standardises and documents -the behaviour of Portage so that the Portage tree can be used by other -package managers. +the behaviour of Portage so that ebuild repositories can be used by +other package managers. Dependencies diff --git a/bin/ebuild b/bin/ebuild index a49e28b99..5aa3ead95 100755 --- a/bin/ebuild +++ b/bin/ebuild @@ -143,7 +143,7 @@ if not os.path.isabs(ebuild): mycwd = portage.normalize_path(pwd) ebuild = os.path.join(mycwd, ebuild) ebuild = portage.normalize_path(ebuild) -# portdbapi uses the canonical path for the base of the portage tree, but +# portdbapi uses the canonical path for the base of the ebuild repository, but # subdirectories of the base can be built from symlinks (like crossdev does). ebuild_portdir = os.path.realpath( os.path.dirname(os.path.dirname(os.path.dirname(ebuild diff --git a/bin/ebuild.sh b/bin/ebuild.sh index 98ed570c2..5491c4f58 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -279,7 +279,7 @@ inherit() { then # This is disabled in the *rm phases because they frequently give # false alarms due to INHERITED in /var/db/pkg being outdated - # in comparison the the eclasses from the portage tree. It's + # in comparison to the eclasses from the ebuild repository. It's # disabled for nofetch, since that can be called by repoman and # that triggers bug #407449 due to repoman not exporting # non-essential variables such as INHERITED. diff --git a/cnf/make.conf.example b/cnf/make.conf.example index 04f3a0274..36fc9a8e4 100644 --- a/cnf/make.conf.example +++ b/cnf/make.conf.example @@ -13,7 +13,7 @@ # very extensive set of USE variables described in our USE variable HOWTO at # https://wiki.gentoo.org/wiki/Handbook:X86/Working/USE # -# The available list of use flags with descriptions is in your portage tree. +# The available list of use flags with descriptions is in the ebuild repository. # Use 'less' to view them: --> less /usr/portage/profiles/use.desc <-- # # 'ufed' is an ncurses/dialog interface available in portage to make handling @@ -102,7 +102,7 @@ # the application being installed. #PORTAGE_TMPDIR=/var/tmp # -# PORTDIR is the location of the portage tree. This is the repository +# PORTDIR is the location of the ebuild repository. This is the repository # for all profile information as well as all ebuilds. If you change # this, you must update your /etc/portage/make.profile symlink accordingly. # ***Warning*** @@ -193,7 +193,7 @@ # Synchronizing Portage # = # -# Each of these settings affects how Gentoo synchronizes your Portage tree. +# Each of these settings affects how Gentoo synchronizes the ebuild repository. # Synchronization is handled by rsync and these settings allow some control # over how it is done. # @@ -220,7 +220,7 @@ #SYNC="rsync://rsync.gentoo.org/gentoo-portage" # # PORTAGE_RSYNC_RETRIES sets the number of times
[gentoo-commits] proj/portage:master commit in: bin/, lib/portage/sync/modules/webrsync/, man/
commit: 726789b64dd713a761ebdc78abb3d64fff2a7984 Author: Zac Medico gentoo org> AuthorDate: Mon Jul 23 04:10:40 2018 + Commit: Zac Medico gentoo org> CommitDate: Sat Jul 28 05:53:06 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=726789b6 webrsync: support sync-openpgp-key-path (bug 661838) Add repos.conf sync-webrsync-verify-signature = true|false setting that enables sync-openpgp-key-path support like in the rsync and git sync modules. This is disabled by default, in order to avoid interference with legacy manual PORTAGE_GPG_DIR configuration. When sync-webrsync-verify-signature = true is set in repos.conf, if the PORTAGE_GPG_DIR has not been exported, emerge-webrsync will assume that it has been called directly and it will output an error message advising the user to instead call emerge --sync or emaint sync. Bug: https://bugs.gentoo.org/661838 Reviewed-by: Brian Dolbec gentoo.org> bin/emerge-webrsync | 16 +- lib/portage/sync/modules/webrsync/__init__.py | 4 +- lib/portage/sync/modules/webrsync/webrsync.py | 74 +++ man/portage.5 | 5 ++ 4 files changed, 88 insertions(+), 11 deletions(-) diff --git a/bin/emerge-webrsync b/bin/emerge-webrsync index b135567b7..f622dde3e 100755 --- a/bin/emerge-webrsync +++ b/bin/emerge-webrsync @@ -10,7 +10,14 @@ # - all output should prob be converted to e* funcs # - add support for ROOT +# repos.conf configuration for use with emerge --sync and emaint sync +# using keyring from app-crypt/openpgp-keys-gentoo-release: +# [gentoo] +# sync-type = webrsync +# sync-webrsync-verify-signature = true +# sync-openpgp-key-path = /usr/share/openpgp-keys/gentoo-release.asc # +# Alternative (legacy) PORTAGE_GPG_DIR configuration: # gpg key import # KEY_ID=0x96D8BF6D # gpg --homedir /etc/portage/gnupg --keyserver subkeys.pgp.net --recv-keys $KEY_ID @@ -67,7 +74,14 @@ do_verbose=0 do_debug=0 keep=false -if has webrsync-gpg ${FEATURES} ; then +if has $(__repo_attr "${repo_name}" sync-webrsync-verify-signature | \ + LC_ALL=C tr '[:upper:]' '[:lower:]') true yes; then + if [[ ! -d ${PORTAGE_GPG_DIR} ]]; then + eecho "Do not call ${argv0##*/} directly, instead call emerge --sync or emaint sync." + exit 1 + fi + WEBSYNC_VERIFY_SIGNATURE=1 +elif has webrsync-gpg ${FEATURES}; then WEBSYNC_VERIFY_SIGNATURE=1 else WEBSYNC_VERIFY_SIGNATURE=0 diff --git a/lib/portage/sync/modules/webrsync/__init__.py b/lib/portage/sync/modules/webrsync/__init__.py index dc7def20c..1e09d1a47 100644 --- a/lib/portage/sync/modules/webrsync/__init__.py +++ b/lib/portage/sync/modules/webrsync/__init__.py @@ -45,7 +45,9 @@ module_spec = { 'exists and is a valid repository', }, 'validate_config': CheckSyncConfig, - 'module_specific_options': (), + 'module_specific_options': ( + 'sync-webrsync-verify-signature', + ), }, } } diff --git a/lib/portage/sync/modules/webrsync/webrsync.py b/lib/portage/sync/modules/webrsync/webrsync.py index 3d79f4557..1b4c08e65 100644 --- a/lib/portage/sync/modules/webrsync/webrsync.py +++ b/lib/portage/sync/modules/webrsync/webrsync.py @@ -1,17 +1,25 @@ '''WebRsync module for portage''' +import io import logging import portage from portage import os from portage.util import writemsg_level +from portage.util.futures import asyncio from portage.output import create_color_func good = create_color_func("GOOD") bad = create_color_func("BAD") warn = create_color_func("WARN") from portage.sync.syncbase import SyncBase +try: + from gemato.exceptions import GematoException + import gemato.openpgp +except ImportError: + gemato = None + class WebRsync(SyncBase): '''WebRSync sync class''' @@ -39,15 +47,63 @@ class WebRsync(SyncBase): for var in ['uid', 'gid', 'groups']: self.spawn_kwargs.pop(var, None) - exitcode = portage.process.spawn_bash("%s" % \ - (self.bin_command), - **self.spawn_kwargs) - if exitcode != os.EX_OK: - msg = "!!! emerge-webrsync error in %s" % self.repo.location - self.logger(self.xterm_titles, msg) - writemsg_level(msg + "\n", level=logging.ERROR, noiselevel=-1) - return (exitcode, False) - return (exitcode, True) + verbose = '--verbose' in self.options['emerge_config'].opts + quiet = '--quiet' in self.options['emerge_config'].opts + openpgp_env = None + try: + if self.repo.module_specific_options.get( +