From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 6567A15801C for ; Wed, 2 Aug 2023 06:31:28 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A739FE0C75; Wed, 2 Aug 2023 06:31:27 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 92A9DE0C5E for ; Wed, 2 Aug 2023 06:31:27 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id BBC0C335CEE for ; Wed, 2 Aug 2023 06:31:26 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id EA645EB8 for ; Wed, 2 Aug 2023 06:31:23 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1690957880.d42384c6fd91056eab8f0450d210d9876d3efcc1.sam@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: bin/, / X-VCS-Repository: proj/portage X-VCS-Files: NEWS bin/emerge-webrsync bin/etc-update X-VCS-Directories: / bin/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: d42384c6fd91056eab8f0450d210d9876d3efcc1 X-VCS-Branch: master Date: Wed, 2 Aug 2023 06:31:23 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 5c41f6b9-f12d-45df-adbc-c30c8ee07e46 X-Archives-Hash: 4a51f69ea89feeaffb0c5637d5188462 commit: d42384c6fd91056eab8f0450d210d9876d3efcc1 Author: James Le Cuirot gentoo org> AuthorDate: Sun Jul 30 20:45:55 2023 +0000 Commit: Sam James gentoo org> CommitDate: Wed Aug 2 06:31:20 2023 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=d42384c6 Make non-Python (s)bin scripts use other scripts from the same directory This is particularly important when Portage is installed in a venv to ensure that other scripts are launched using the same environment. Signed-off-by: James Le Cuirot gentoo.org> Signed-off-by: Sam James gentoo.org> NEWS | 3 +++ bin/emerge-webrsync | 20 ++++++++------------ bin/etc-update | 10 +++++++--- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/NEWS b/NEWS index 1f34bdd90..0e3541af4 100644 --- a/NEWS +++ b/NEWS @@ -17,6 +17,9 @@ Bug fixes: * gpkg: Fix timestamp for binary packages (bug #909067). +* Ensure non-Python (s)bin scripts launch other Python-based Portage scripts + using the same environment. + portage-3.0.49 (2023-06-21) -------------- diff --git a/bin/emerge-webrsync b/bin/emerge-webrsync index 3835977fc..7b3163b81 100755 --- a/bin/emerge-webrsync +++ b/bin/emerge-webrsync @@ -71,16 +71,12 @@ die() { argv0=$0 -# Use portageq from the same directory/prefix as the current script, so -# that we don't have to rely on PATH including the current EPREFIX. -scriptpath=${BASH_SOURCE[0]} -if [[ -x "${scriptpath%/*}/portageq" ]]; then - portageq=${scriptpath%/*}/portageq -elif type -P portageq > /dev/null ; then - portageq=portageq -else - die "could not find 'portageq'; aborting" -fi +# Use emerge and portageq from the same directory/prefix as the current script, +# so that we don't have to rely on PATH including the current EPREFIX. +emerge=$(PATH="${BASH_SOURCE[0]%/*}:${PATH}" type -P emerge) +[[ -n ${emerge} ]] || die "could not find 'emerge'; aborting" +portageq=$(PATH="${BASH_SOURCE[0]%/*}:${PATH}" type -P portageq) +[[ -n ${portageq} ]] || die "could not find 'portageq'; aborting" eval "$("${portageq}" envvar -v DISTDIR EPREFIX FEATURES \ FETCHCOMMAND GENTOO_MIRRORS \ @@ -461,14 +457,14 @@ sync_local() { if has metadata-transfer ${FEATURES} ; then einfo "Updating cache ..." - emerge --metadata + "${emerge}" --metadata fi local post_sync=${PORTAGE_CONFIGROOT%/}/etc/portage/bin/post_sync [[ -x "${post_sync}" ]] && "${post_sync}" # --quiet suppresses output if there are no relevant news items - has news ${FEATURES} && emerge --check-news --quiet + has news ${FEATURES} && "${emerge}" --check-news --quiet return 0 } diff --git a/bin/etc-update b/bin/etc-update index 14bd80b84..97c163420 100755 --- a/bin/etc-update +++ b/bin/etc-update @@ -10,6 +10,8 @@ # Leo Lipelis # Karl Trygve Kalleberg +cd "${BASH_SOURCE[0]%/*}" +BINDIR=${PWD} cd / type -P gsed >/dev/null && sed() { gsed "$@"; } @@ -767,7 +769,7 @@ while [[ -n $1 ]] ; do -p|--preen) PREEN=true;; -q|--quiet) QUIET=true;; -v|--verbose) VERBOSE=true;; - -V|--version) emerge --version; exit 0;; + -V|--version) "$(PATH="${BINDIR}:${PATH}" type -P emerge)" --version; exit 0;; --automode) parse_automode_flag $2 && shift || usage 1 "Invalid mode '$2'";; -*) usage 1 "Invalid option '$1'";; *) break;; @@ -801,8 +803,10 @@ portage_vars=( NO_COLOR ) -if type -P portageq > /dev/null; then - eval $(${PORTAGE_PYTHON:+"${PORTAGE_PYTHON}"} "$(type -P portageq)" envvar -v "${portage_vars[@]}") +portageq=$(PATH="${BINDIR}:${PATH}" type -P portageq) + +if [[ -n ${portageq} ]]; then + eval $(${PORTAGE_PYTHON:+"${PORTAGE_PYTHON}"} "${portageq}" envvar -v "${portage_vars[@]}") else [[ ${OS_FAMILY} == 'gentoo' ]] && die "missing portageq" fi