commit: d42384c6fd91056eab8f0450d210d9876d3efcc1
Author: James Le Cuirot <chewi <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 30 20:45:55 2023 +0000
Commit: Sam James <sam <AT> gentoo <DOT> 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 <chewi <AT> gentoo.org>
Signed-off-by: Sam James <sam <AT> 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 <[email protected]>
# Karl Trygve Kalleberg <[email protected]>
+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