From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: bin/, /
Date: Wed, 2 Aug 2023 06:31:23 +0000 (UTC) [thread overview]
Message-ID: <1690957880.d42384c6fd91056eab8f0450d210d9876d3efcc1.sam@gentoo> (raw)
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 <aeoo@gentoo.org>
# Karl Trygve Kalleberg <karltk@gentoo.org>
+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
next reply other threads:[~2023-08-02 6:31 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-02 6:31 Sam James [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-01-15 21:49 [gentoo-commits] proj/portage:master commit in: bin/, / Zac Medico
2025-01-09 17:10 James Le Cuirot
2024-12-15 7:58 Ulrich Müller
2024-11-21 12:22 Ulrich Müller
2024-11-04 20:52 Zac Medico
2023-06-09 13:03 Sam James
2023-05-14 5:04 Ulrich Müller
2023-05-01 7:21 Sam James
2023-04-18 15:22 Ulrich Müller
2023-04-09 6:52 Sam James
2022-11-30 22:29 Sam James
2022-11-30 1:22 Sam James
2022-10-04 0:25 Sam James
2022-09-29 20:45 Sam James
2022-09-29 20:45 Sam James
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1690957880.d42384c6fd91056eab8f0450d210d9876d3efcc1.sam@gentoo \
--to=sam@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox