[gentoo-commits] proj/portage:master commit in: bin/

2026-01-06 Thread Sam James
commit: 32e6c7615985deca4b0522283fb274d2f8c97ee5
Author: Sam James  gentoo  org>
AuthorDate: Wed Jan  7 05:33:40 2026 +
Commit: Sam James  gentoo  org>
CommitDate: Wed Jan  7 05:33:40 2026 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=32e6c761

estrip: copy build ID for splitdebug file from original source w/ 
FEATURES=-installources

This is another attempt for what wa reverted in
e12ac86cb72002b216be0ae316ae7062a91268fa.

Bug: https://bugs.gentoo.org/968220
Signed-off-by: Sam James  gentoo.org>

 bin/estrip | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/bin/estrip b/bin/estrip
index 590e40f76e..6e2a5b6235 100755
--- a/bin/estrip
+++ b/bin/estrip
@@ -168,6 +168,12 @@ save_elf_debug() {
buildid=$("${name_of[debugedit]}" -i \
-s "${CATEGORY}/${PF}:${SLOT}" \
"${src}")
+
+   # We need to process the splitdebug 
file too
+   # if we're doing it at this late 
juncture (bug #968220)
+   "${name_of[objcopy]}" --dump-section 
.note.gnu.build-id="${inode_link}_buildid" "${src}" \
+   && "${name_of[objcopy]}" 
--update-section .note.gnu.build-id="${inode_link}_buildid" "${dst}"
+   rm -f "${inode_link}_buildid"
elif ! contains_word buildid 
"${warned_for[debugedit]}"; then
warned_for[debugedit]+=" buildid"
stash_warning <<-'EOF'



[gentoo-commits] proj/portage:master commit in: bin/

2026-01-06 Thread Sam James
commit: e12ac86cb72002b216be0ae316ae7062a91268fa
Author: Sam James  gentoo  org>
AuthorDate: Wed Jan  7 05:31:24 2026 +
Commit: Sam James  gentoo  org>
CommitDate: Wed Jan  7 05:31:24 2026 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=e12ac86c

Revert "estrip: adjust build ID adjustment for splitdebug w/ 
FEATURES=-installsources"

This reverts commit 86eded1c04bd633e46d65449a4dc063579caadd6.

As Andre Ryan reports on the bug, this can't work because debugedit -i
isn't starting from the same inputs for its hash.

Bug: https://bugs.gentoo.org/968220
Signed-off-by: Sam James  gentoo.org>

 bin/estrip | 6 --
 1 file changed, 6 deletions(-)

diff --git a/bin/estrip b/bin/estrip
index bc6071f8fb..590e40f76e 100755
--- a/bin/estrip
+++ b/bin/estrip
@@ -168,12 +168,6 @@ save_elf_debug() {
buildid=$("${name_of[debugedit]}" -i \
-s "${CATEGORY}/${PF}:${SLOT}" \
"${src}")
-
-   # We need to process the splitdebug 
file too
-   # if we're doing it at this late 
juncture (bug #968220)
-   "${name_of[debugedit]}" -i \
-   -s "${CATEGORY}/${PF}:${SLOT}" \
-   "${dst}"
elif ! contains_word buildid 
"${warned_for[debugedit]}"; then
warned_for[debugedit]+=" buildid"
stash_warning <<-'EOF'



[gentoo-commits] proj/portage:master commit in: bin/

2026-01-04 Thread Sam James
commit: 3f1e03e53470f6ec495ea8514fd448ffd99ec65c
Author: Sam James  gentoo  org>
AuthorDate: Sun Jan  4 14:15:15 2026 +
Commit: Sam James  gentoo  org>
CommitDate: Sun Jan  4 14:15:15 2026 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=3f1e03e5

bin: add comment wrt packdebug choice of xz

As explained in 333ca73072b5f3628a2913c136c5c5b52a371bf5, but let's
add a comment here to be clear it's not an oversight.

Signed-off-by: Sam James  gentoo.org>

 bin/misc-functions.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh
index cf287933da..0aea28b7c9 100755
--- a/bin/misc-functions.sh
+++ b/bin/misc-functions.sh
@@ -513,6 +513,8 @@ __generate_packdebug() {
install -d "${debugpath}"/"${CATEGORY}"{,/"${PN}"} \
|| die "Failed to generate target debug directory"
 
+   # xz is hardcoded here as it's the only format that supports random
+   # access.
(
unset IFS
local 
tarfile="${debugpath}/${CATEGORY}/${PN}/${PF}-${BUILD_ID}-debug.tar.xz"



[gentoo-commits] proj/portage:master commit in: bin/

2025-12-31 Thread Sam James
commit: 86eded1c04bd633e46d65449a4dc063579caadd6
Author: Sam James  gentoo  org>
AuthorDate: Wed Dec 31 20:44:55 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Wed Dec 31 20:44:55 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=86eded1c

estrip: adjust build ID adjustment for splitdebug w/ FEATURES=-installsources

Some deduplication here is probably a good idea. But let's get this minimal
fix out first.

Bug: https://bugs.gentoo.org/968220
Signed-off-by: Sam James  gentoo.org>

 bin/estrip | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/bin/estrip b/bin/estrip
index 590e40f76e..bc6071f8fb 100755
--- a/bin/estrip
+++ b/bin/estrip
@@ -168,6 +168,12 @@ save_elf_debug() {
buildid=$("${name_of[debugedit]}" -i \
-s "${CATEGORY}/${PF}:${SLOT}" \
"${src}")
+
+   # We need to process the splitdebug 
file too
+   # if we're doing it at this late 
juncture (bug #968220)
+   "${name_of[debugedit]}" -i \
+   -s "${CATEGORY}/${PF}:${SLOT}" \
+   "${dst}"
elif ! contains_word buildid 
"${warned_for[debugedit]}"; then
warned_for[debugedit]+=" buildid"
stash_warning <<-'EOF'



[gentoo-commits] proj/portage:master commit in: bin/

2025-12-31 Thread Sam James
commit: ddf48f45685d05821e9eabca3ed6d19f5b397883
Author: Sam James  gentoo  org>
AuthorDate: Wed Dec 31 12:16:45 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Wed Dec 31 12:16:45 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=ddf48f45

estrip: fix typo in debugedit call

This was from a broken rebase.

Fixes: b724e677e39eaa790380a2a13ab264a9b23e2572
Signed-off-by: Sam James  gentoo.org>

 bin/estrip | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/estrip b/bin/estrip
index 3b2e4dfc62..590e40f76e 100755
--- a/bin/estrip
+++ b/bin/estrip
@@ -167,7 +167,7 @@ save_elf_debug() {
# bundled libraries.
buildid=$("${name_of[debugedit]}" -i \
-s "${CATEGORY}/${PF}:${SLOT}" \
-   "${x}")
+   "${src}")
elif ! contains_word buildid 
"${warned_for[debugedit]}"; then
warned_for[debugedit]+=" buildid"
stash_warning <<-'EOF'



[gentoo-commits] proj/portage:master commit in: bin/

2025-12-16 Thread Sam James
commit: d7d6fd54f1c936e89c5e4467c6c1f33b217325ca
Author: Sam James  gentoo  org>
AuthorDate: Tue Dec 16 09:36:27 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Dec 16 09:39:40 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=d7d6fd54

bin: emerge, ebuild: don't define signal handlers in global scope

This breaks when `emerge` is frozen. Do what we do in `egencache`. We
do need to use the same boilerplate in all bin/* though...

Bug: https://bugs.gentoo.org/941956
Bug: https://bugs.gentoo.org/967199
Signed-off-by: Sam James  gentoo.org>

 bin/ebuild | 10 +-
 bin/emerge | 10 +-
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/bin/ebuild b/bin/ebuild
index 0c6369e016..3fc6e334cb 100755
--- a/bin/ebuild
+++ b/bin/ebuild
@@ -22,11 +22,6 @@ def debug_signal(_signum, _frame):
 pdb.set_trace()
 
 
-# Prevent "[Errno 32] Broken pipe" exceptions when writing to a pipe.
-signal.signal(signal.SIGPIPE, signal.SIG_DFL)
-signal.signal(signal.SIGTERM, signal_interrupt)
-signal.signal(signal.SIGUSR1, debug_signal)
-
 import argparse
 from os import path as osp
 import shlex
@@ -61,6 +56,11 @@ from _emerge.RootConfig import RootConfig
 
 
 def main():
+# Prevent "[Errno 32] Broken pipe" exceptions when writing to a pipe.
+signal.signal(signal.SIGPIPE, signal.SIG_DFL)
+signal.signal(signal.SIGTERM, signal_interrupt)
+signal.signal(signal.SIGUSR1, debug_signal)
+
 portage.process.sanitize_fds()
 description = "See the ebuild(1) man page for more info"
 usage = "Usage: ebuild   [command] ..."

diff --git a/bin/emerge b/bin/emerge
index 9e5d59cb04..d4f50fa9a3 100755
--- a/bin/emerge
+++ b/bin/emerge
@@ -22,11 +22,6 @@ def debug_signal(_signum, _frame):
 pdb.set_trace()
 
 
-# Prevent "[Errno 32] Broken pipe" exceptions when writing to a pipe.
-signal.signal(signal.SIGPIPE, signal.SIG_DFL)
-signal.signal(signal.SIGTERM, signal_interrupt)
-signal.signal(signal.SIGUSR1, debug_signal)
-
 from os import path as osp
 
 if osp.isfile(
@@ -46,6 +41,11 @@ from _emerge.main import emerge_main
 
 
 def main():
+# Prevent "[Errno 32] Broken pipe" exceptions when writing to a pipe.
+signal.signal(signal.SIGPIPE, signal.SIG_DFL)
+signal.signal(signal.SIGTERM, signal_interrupt)
+signal.signal(signal.SIGUSR1, debug_signal)
+
 portage.process.sanitize_fds()
 try:
 retval = emerge_main()



[gentoo-commits] proj/portage:master commit in: bin/

2025-12-15 Thread Sam James
commit: cb6d7479a0b87b28435039386e0e7f61ddbb9900
Author: Sam James  gentoo  org>
AuthorDate: Tue Dec 16 04:11:07 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Dec 16 04:11:07 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=cb6d7479

Revert "save-build-env: Strip out non-reproducible variables"

This reverts commit 81a8ae90a23652973d094440ef6d08dd34ee32d1.

As Kerin points out on the bug, this isn't needed (anymore -- it was
needed at the time of the PR, but not at the time of application) since
8a607ed23beb4995627f9c4e2c7580469ace56bb.

Bug: https://bugs.gentoo.org/914441
Signed-off-by: Sam James  gentoo.org>

 bin/save-ebuild-env.sh | 4 
 1 file changed, 4 deletions(-)

diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
index 73b245121c..7e6bd6120e 100644
--- a/bin/save-ebuild-env.sh
+++ b/bin/save-ebuild-env.sh
@@ -47,10 +47,6 @@ __save_ebuild_env() (
# identical, so strip them from the binpkg. It's also not needed
# for installing / removing a package.
unset MAKEOPTS NINJAOPTS
-
-   # These variables are constantly changing. Strip them so we
-   # don't introduce non-reproducible data into the binpkg.
-   unset EPOCHREALTIME EPOCHSECONDS SRANDOM
fi
 
MAPFILE+=(



[gentoo-commits] proj/portage:master commit in: bin/

2025-12-15 Thread Sam James
commit: 81a8ae90a23652973d094440ef6d08dd34ee32d1
Author: Raul E Rangel  chromium  org>
AuthorDate: Wed Apr 24 18:49:02 2024 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Dec 16 03:21:43 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=81a8ae90

save-build-env: Strip out non-reproducible variables

Bash provides access to the time and a random data via variables. We
don't want to persist these values when generating a binpkg.

Bug: https://bugs.gentoo.org/914441
Signed-off-by: Raul E Rangel  chromium.org>
Part-of: https://github.com/gentoo/portage/pull/1311
Closes: https://github.com/gentoo/portage/pull/1311
Signed-off-by: Sam James  gentoo.org>

 bin/save-ebuild-env.sh | 4 
 1 file changed, 4 insertions(+)

diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
index 7e6bd6120e..73b245121c 100644
--- a/bin/save-ebuild-env.sh
+++ b/bin/save-ebuild-env.sh
@@ -47,6 +47,10 @@ __save_ebuild_env() (
# identical, so strip them from the binpkg. It's also not needed
# for installing / removing a package.
unset MAKEOPTS NINJAOPTS
+
+   # These variables are constantly changing. Strip them so we
+   # don't introduce non-reproducible data into the binpkg.
+   unset EPOCHREALTIME EPOCHSECONDS SRANDOM
fi
 
MAPFILE+=(



[gentoo-commits] proj/portage:master commit in: bin/

2025-12-15 Thread Sam James
commit: 898b045364e614a092a5cdd37b70956df0f424cf
Author: Sam James  gentoo  org>
AuthorDate: Tue Dec 16 03:17:06 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Dec 16 03:17:06 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=898b0453

etc-update: support Artix Linux

Bug: https://bugs.gentoo.org/864565
Thanks-to: Tobias Leupold  stonemx.de>
Signed-off-by: Sam James  gentoo.org>

 bin/etc-update | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/etc-update b/bin/etc-update
index a25457cfab..8d85bc5d84 100755
--- a/bin/etc-update
+++ b/bin/etc-update
@@ -45,7 +45,7 @@ else
*:suse:*|*:opensuse:*|*:opensuse-tumbleweed:*) OS_FAMILY='rpm';;
*:fedora:*|*:rhel:*) OS_FAMILY='rpm';;
*:debian:*|*:ubuntu:*) OS_FAMILY='dpkg';;
-   *:arch:*) OS_FAMILY='arch' NEW_EXT='pacnew';;
+   *:arch:*|*:artix:*) OS_FAMILY='arch' NEW_EXT='pacnew';;
*) OS_FAMILY='gentoo';;
esac
 fi



[gentoo-commits] proj/portage:master commit in: bin/, man/, lib/portage/tests/emerge/

2025-12-15 Thread Sam James
commit: 1a135f1a0f1b26c277bb75db6667c6a816c2931f
Author: benaryorg  benary  org>
AuthorDate: Thu Oct 30 15:47:19 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Dec 16 03:15:01 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=1a135f1a

etc-update: Allow overriding the os-family

This allows tests on CI runners to run the *etc-update* tests for
arbitrary target distributions.

Signed-off-by: benaryorg  benary.org>
Part-of: https://github.com/gentoo/portage/pull/1494
Signed-off-by: Sam James  gentoo.org>

 bin/etc-update  | 22 ++
 lib/portage/tests/emerge/test_config_protect.py |  1 +
 man/etc-update.1|  6 ++
 3 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/bin/etc-update b/bin/etc-update
index fff5d99550..e3bc3da251 100755
--- a/bin/etc-update
+++ b/bin/etc-update
@@ -34,14 +34,20 @@ get_config() {
"${PORTAGE_CONFIGROOT}"etc/etc-update.conf)
 }
 
-OS_RELEASE_POSSIBLE_IDS=$(source /etc/os-release >/dev/null 2>&1; echo 
":${ID}:${ID_LIKE//[[:space:]]/:}:")
-
-case ${OS_RELEASE_POSSIBLE_IDS} in
-   *:suse:*|*:opensuse:*|*:opensuse-tumbleweed:*) OS_FAMILY='rpm';;
-   *:fedora:*|*:rhel:*) OS_FAMILY='rpm';;
-   *:arch:*) OS_FAMILY='arch' NEW_EXT='pacnew';;
-   *) OS_FAMILY='gentoo';;
-esac
+# Allow overriding the detected os family using an environment variable.
+# The primary use is for the CI runner to force a specific behaviour for tests.
+if [[ -n ${ETC_UPDATE_OS_FAMILY} ]]; then
+   OS_FAMILY="${ETC_UPDATE_OS_FAMILY}"
+else
+   OS_RELEASE_POSSIBLE_IDS=$(source /etc/os-release >/dev/null 2>&1; echo 
":${ID}:${ID_LIKE//[[:space:]]/:}:")
+
+   case ${OS_RELEASE_POSSIBLE_IDS} in
+   *:suse:*|*:opensuse:*|*:opensuse-tumbleweed:*) OS_FAMILY='rpm';;
+   *:fedora:*|*:rhel:*) OS_FAMILY='rpm';;
+   *:arch:*) OS_FAMILY='arch' NEW_EXT='pacnew';;
+   *) OS_FAMILY='gentoo';;
+   esac
+fi
 
 if [[ ${OS_FAMILY} == 'gentoo' ]]; then
get_basename() {

diff --git a/lib/portage/tests/emerge/test_config_protect.py 
b/lib/portage/tests/emerge/test_config_protect.py
index 59a2c23b90..32a4790f5a 100644
--- a/lib/portage/tests/emerge/test_config_protect.py
+++ b/lib/portage/tests/emerge/test_config_protect.py
@@ -220,6 +220,7 @@ src_install() {
 "DISTDIR": distdir,
 "EMERGE_DEFAULT_OPTS": "-v",
 "EMERGE_WARNING_DELAY": "0",
+"ETC_UPDATE_OS_FAMILY": "gentoo",
 "INFODIR": "",
 "INFOPATH": "",
 "PATH": path,

diff --git a/man/etc-update.1 b/man/etc-update.1
index 9b82e1f5c5..0f7f80b44c 100644
--- a/man/etc-update.1
+++ b/man/etc-update.1
@@ -18,6 +18,12 @@ See \fBmake.conf\fR(5) for more information.
 .PP
 \fIetc\-update\fR respects the normal \fIPORTAGE_CONFIGROOT\fR and
 \fIEROOT\fR variables for finding the aforementioned config protect variables.
+.PP
+Multiple target distributions are supported, including \fIportage\fR(5),
+\fIrpm\fR(1), \fIpacman\fR(1), and \fIdpkg\fR(1) based systems.  Detection of
+the target package management system is done by inspecting
+\fI/etc/os\-release\fR. \fIETC_UPDATE_OS_FAMILY\fR can be used to override this
+detection.
 .SH "OPTIONS"
 .TP
 .BR \-d ", " \-\-debug



[gentoo-commits] proj/portage:master commit in: bin/

2025-12-15 Thread Sam James
commit: 887fce6e46755741db85dc1e419f57ee03b69740
Author: benaryorg  benary  org>
AuthorDate: Thu Oct 30 12:08:24 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Dec 16 03:15:02 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=887fce6e

etc-update: Add Debian support

Technically this also adds Ubuntu support but I have not tested that one
at all. Using this on Debian works as expected given the code is
basically copied over from the *rpm* section with suffixes changed. At
time of writing it does not seem like Debian has any tool similar to
this despite having feature requests for something similar from at least
2001.

Signed-off-by: benaryorg  benary.org>
Part-of: https://github.com/gentoo/portage/pull/1494
Closes: https://github.com/gentoo/portage/pull/1494
Signed-off-by: Sam James  gentoo.org>

 bin/etc-update | 21 +
 1 file changed, 21 insertions(+)

diff --git a/bin/etc-update b/bin/etc-update
index e3bc3da251..a25457cfab 100755
--- a/bin/etc-update
+++ b/bin/etc-update
@@ -44,6 +44,7 @@ else
case ${OS_RELEASE_POSSIBLE_IDS} in
*:suse:*|*:opensuse:*|*:opensuse-tumbleweed:*) OS_FAMILY='rpm';;
*:fedora:*|*:rhel:*) OS_FAMILY='rpm';;
+   *:debian:*|*:ubuntu:*) OS_FAMILY='dpkg';;
*:arch:*) OS_FAMILY='arch' NEW_EXT='pacnew';;
*) OS_FAMILY='gentoo';;
esac
@@ -89,6 +90,20 @@ elif [[ ${OS_FAMILY} == 'rpm' ]]; then
get_live_file() {
printf -- '%s\n' "${cfg_file}" |sed -e 's/\.rpmsave$//' -e 
's/\.rpmnew$//' -e 's/\.rpmorig$//'
}
+# In dpkg we have dpkg-old, dpkg-dist, dpkg-new.
+elif [[ ${OS_FAMILY} == 'dpkg' ]]; then
+   get_basename() {
+   printf -- '%s\n' "${1}" |sed -e 's/\.dpkg-old$//' -e 
's/\.dpkg-new$//' -e 's/\.dpkg-dist$//'
+   }
+   get_basename_find_opt() {
+   printf -- '%s\n' "${1}.dpkg-???*"
+   }
+   get_scan_regexp() {
+   echo 
"s:\(^.*/\)\(.*\)\(\.\(dpkg-old|dpkg-new|dpkg-dist\)\):\1\2\3$b\1$b\3$b\2:"
+   }
+   get_live_file() {
+   printf -- '%s\n' "${cfg_file}" |sed -e 's/\.dpkg-old$//' -e 
's/\.dpkg-new$//' -e 's/\.dpkg-dist$//'
+   }
 fi
 
 cmd_var_is_valid() {
@@ -790,6 +805,12 @@ if [[ ${OS_FAMILY} == 'rpm' ]]; then
CONFIG_PROTECT='/etc /usr/share'
CONFIG_PROTECT_MASK=''
[[ -f /etc/sysconfig/etc-update ]] && . /etc/sysconfig/etc-update
+elif [[ ${OS_FAMILY} == 'dpkg' ]]; then
+   PORTAGE_CONFIGROOT='/'
+   PORTAGE_TMPDIR='/tmp'
+   CONFIG_PROTECT='/etc /usr/share'
+   CONFIG_PROTECT_MASK=''
+   [[ -f /etc/default/etc-update ]] && . /etc/default/etc-update
 elif [[ ${OS_FAMILY} == 'arch' ]]; then
PORTAGE_CONFIGROOT='/'
PORTAGE_TMPDIR='/tmp'



[gentoo-commits] proj/portage:master commit in: bin/

2025-11-28 Thread Ulrich Müller
commit: a959ea2dd7734d6ac5d374e45f7b5ba43949476e
Author: Ulrich Müller  gentoo  org>
AuthorDate: Thu Nov 27 15:11:54 2025 +
Commit: Ulrich Müller  gentoo  org>
CommitDate: Fri Nov 28 08:18:13 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=a959ea2d

phase-helpers.sh: Move assert() from isolated-functions to here

assert() is no longer used internally.

Signed-off-by: Ulrich Müller  gentoo.org>

 bin/isolated-functions.sh | 8 
 bin/phase-helpers.sh  | 8 
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index 7d43d71314..a7dd6d78c9 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -22,14 +22,6 @@ fi
 # It _must_ preceed all the calls to die and assert.
 shopt -s expand_aliases
 
-assert() {
-   local x pipestatus=( "${PIPESTATUS[@]}" )
-   ___eapi_has_assert || die "'${FUNCNAME}' banned in EAPI ${EAPI}"
-   for x in "${pipestatus[@]}"; do
-   [[ ${x} -eq 0 ]] || die "$@"
-   done
-}
-
 # Simplified version of pipestatus() for internal use
 __pipestatus() {
local status=( "${PIPESTATUS[@]}" ) s ret=0

diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index 619965e0b9..4b36a0f27f 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -28,6 +28,14 @@ if ! contains_word strip "${PORTAGE_RESTRICT}"; then
 PORTAGE_DOSTRIP+=( / )
 fi
 
+assert() {
+   local x pipestatus=( "${PIPESTATUS[@]}" )
+   ___eapi_has_assert || die "'${FUNCNAME}' banned in EAPI ${EAPI}"
+   for x in "${pipestatus[@]}"; do
+   [[ ${x} -eq 0 ]] || die "$@"
+   done
+}
+
 into() {
if [[ "$1" == "/" ]]; then
export __E_DESTTREE=""



[gentoo-commits] proj/portage:master commit in: bin/

2025-11-28 Thread Ulrich Müller
commit: 21b9458ec44fab14d915f64476dd8b48f7081cc5
Author: Ulrich Müller  gentoo  org>
AuthorDate: Thu Nov 27 15:10:04 2025 +
Commit: Ulrich Müller  gentoo  org>
CommitDate: Fri Nov 28 08:18:13 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=21b9458e

*.sh: Replace internal assert calls

assert() cannot be used in EAPI 9. Instead, define an internal
__pipestatus() function.

Thanks to Florian Schmaus for pointing this out.

Fixes: afaf72e840d910c17e23335c8069c5bd40faf4f7
Signed-off-by: Ulrich Müller  gentoo.org>

 bin/isolated-functions.sh | 9 +
 bin/misc-functions.sh | 5 +++--
 bin/phase-functions.sh| 6 +++---
 3 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index 393a36ed64..7d43d71314 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -30,6 +30,15 @@ assert() {
done
 }
 
+# Simplified version of pipestatus() for internal use
+__pipestatus() {
+   local status=( "${PIPESTATUS[@]}" ) s ret=0
+   for s in "${status[@]}"; do
+   [[ ${s} -ne 0 ]] && ret=${s}
+   done
+   return "${ret}"
+}
+
 shopt -s extdebug
 
 # __dump_trace([number of funcs on stack to skip],

diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh
index 204500e2ac..22531d98b1 100755
--- a/bin/misc-functions.sh
+++ b/bin/misc-functions.sh
@@ -1,7 +1,7 @@
 #!/usr/bin/env bash
 # shellcheck disable=SC2128
 
-# Copyright 1999-2024 Gentoo Authors
+# Copyright 1999-2025 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
@@ -540,7 +540,8 @@ __dyn_package() {
 
gtar ${tar_options} -cf - ${PORTAGE_BINPKG_TAR_OPTS} -C "${D}" 
. | \
${PORTAGE_COMPRESSION_COMMAND} > 
"${PORTAGE_BINPKG_TMPFILE}"
-   assert "failed to pack binary package: 
'${PORTAGE_BINPKG_TMPFILE}'"
+   __pipestatus \
+   || die "failed to pack binary package: 
'${PORTAGE_BINPKG_TMPFILE}'"
 
PYTHONPATH=${PORTAGE_PYTHONPATH:-${PORTAGE_PYM_PATH}} \
"${PORTAGE_PYTHON:-/usr/bin/python}" 
"${PORTAGE_BIN_PATH}"/xpak-helper.py recompose \

diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh
index 98b2784c96..cd22209595 100644
--- a/bin/phase-functions.sh
+++ b/bin/phase-functions.sh
@@ -753,7 +753,7 @@ __dyn_install() {
__save_ebuild_env --exclude-init-phases | __filter_readonly_variables \
--filter-path --filter-sandbox --allow-extra-vars > \
"${PORTAGE_BUILDDIR}"/build-info/environment
-   assert "__save_ebuild_env failed"
+   __pipestatus || die "__save_ebuild_env failed"
cd "${PORTAGE_BUILDDIR}"/build-info || die
 
${PORTAGE_BZIP2_COMMAND} -f9 environment
@@ -1072,7 +1072,7 @@ __ebuild_main() {
__filter_readonly_variables --filter-path \
--filter-sandbox --allow-extra-vars \
| ${PORTAGE_BZIP2_COMMAND} -c -f9 > 
"${PORTAGE_UPDATE_ENV}"
-   assert "__save_ebuild_env failed"
+   __pipestatus || die "__save_ebuild_env failed"
fi
;;
unpack|prepare|configure|compile|test|clean|install)
@@ -1166,7 +1166,7 @@ __ebuild_main() {
cd "${PORTAGE_PYM_PATH}"
__save_ebuild_env | __filter_readonly_variables \
--filter-features > "${T}/environment"
-   assert "__save_ebuild_env failed"
+   __pipestatus || die "__save_ebuild_env failed"
 
chgrp "${PORTAGE_GRPNAME:-portage}" "${T}/environment"
chmod g+w "${T}/environment"



[gentoo-commits] proj/portage:master commit in: bin/

2025-11-26 Thread Zac Medico
commit: a146eb4c4d0c3e9ad2978b791421dfb81d9c7538
Author: Zac Medico  gentoo  org>
AuthorDate: Sat Nov 22 08:55:08 2025 +
Commit: Zac Medico  gentoo  org>
CommitDate: Thu Nov 27 05:16:22 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=a146eb4c

portageq: Replace lazyimport with function local import

Also do not bother to close the global_event_loop since it is
now closed by an atexit hook.

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

 bin/portageq | 34 +-
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/bin/portageq b/bin/portageq
index d10cbd9475..2f2925274f 100755
--- a/bin/portageq
+++ b/bin/portageq
@@ -68,19 +68,6 @@ try:
 from portage.eapi import eapi_has_repo_deps
 from portage.util import writemsg, writemsg_stdout, no_color
 
-portage.proxy.lazyimport.lazyimport(
-globals(),
-"re",
-"subprocess",
-"_emerge.Package:Package",
-"_emerge.RootConfig:RootConfig",
-"_emerge.is_valid_package_atom:insert_category_into_atom",
-"portage.dbapi._expand_new_virt:expand_new_virt",
-"portage._sets.base:InternalPackageSet",
-"portage.util._eventloop.global_event_loop:global_event_loop",
-"portage.xml.metadata:MetaDataXML",
-)
-
 def eval_atom_use(atom):
 if "USE" in os.environ:
 use = frozenset(os.environ["USE"].split())
@@ -493,6 +480,10 @@ try:
 
 @uses_eroot
 def best_visible(argv):
+from _emerge.Package import Package
+from _emerge.RootConfig import RootConfig
+from portage._sets.base import InternalPackageSet
+
 if len(argv) < 2:
 writemsg("ERROR: insufficient parameters!\n", noiselevel=-1)
 return 2
@@ -680,6 +671,8 @@ try:
 
 @uses_eroot
 def expand_virtual(argv):
+from portage.dbapi._expand_new_virt import expand_new_virt
+
 if len(argv) != 2:
 writemsg(f"ERROR: expected 2 parameters, got {len(argv)}!\n", 
noiselevel=-1)
 return 2
@@ -1104,6 +1097,8 @@ try:
 
 class MaintainerEmailMatcher:
 def __init__(self, maintainer_emails):
+import re
+
 self._re = re.compile(f"^({'|'.join(maintainer_emails)})$", re.I)
 
 def __call__(self, metadata_xml):
@@ -1120,6 +1115,12 @@ try:
 return not metadata_xml.maintainers()
 
 def pquery(parser, opts, args):
+import re
+from _emerge.Package import Package
+from _emerge.RootConfig import RootConfig
+from _emerge.is_valid_package_atom import insert_category_into_atom
+from portage.xml.metadata import MetaDataXML
+
 portdb = portage.db[portage.root]["porttree"].dbapi
 root_config = RootConfig(portdb.settings, portage.db[portage.root], 
None)
 
@@ -1440,6 +1441,8 @@ try:
 eapi = os.environ.get("EAPI")
 
 def elog(elog_funcname, lines):
+import subprocess
+
 cmd = f"source 
'{os.environ['PORTAGE_BIN_PATH']}/isolated-functions.sh' ; "
 for line in lines:
 cmd += f"{elog_funcname} {shlex.quote(line)} ; "
@@ -1564,10 +1567,7 @@ try:
 sys.exit(1)
 
 if __name__ == "__main__":
-try:
-sys.exit(main(sys.argv))
-finally:
-global_event_loop().close()
+sys.exit(main(sys.argv))
 
 except KeyboardInterrupt as e:
 # Prevent traceback on ^C



[gentoo-commits] proj/portage:master commit in: bin/

2025-11-26 Thread Sam James
commit: 4d86f2c183a535d8085a823d51effdab8d05b4f3
Author: Sam James  gentoo  org>
AuthorDate: Thu Nov 27 04:15:25 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Thu Nov 27 04:15:25 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=4d86f2c1

src_test: apply MAKEFLAGS tweak as done for emake

Copy da7c15042191648cb21a886b8afcf739b55c66c3 for src_test's custom
make calls (we avoid emake for other reasons in there, see comment wrt
nonfatal), otherwise we don't make use of the jobserver for tests.

Bug: https://bugs.gentoo.org/692576
Signed-off-by: Sam James  gentoo.org>

 bin/phase-helpers.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index e1f301a5f5..619965e0b9 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -744,6 +744,9 @@ __eapi0_src_compile() {
 }
 
 __eapi0_src_test() {
+   # Prevent MAKEOPTS from resetting MAKEFLAGS jobserver mode for bug 
692576.
+   [[ -n ${MAKEFLAGS} ]] && local MAKEOPTS=""
+
# Since we don't want emake's automatic die
# support (EAPI 4 and later), and we also don't
# want the warning messages that it produces if



[gentoo-commits] proj/portage:master commit in: bin/install-qa-check.d/

2025-11-24 Thread Zac Medico
commit: 885d12b0f7188fc6558fd8f8e46a83a7a370dc6d
Author: Zac Medico  gentoo  org>
AuthorDate: Tue Nov 18 03:00:35 2025 +
Commit: Zac Medico  gentoo  org>
CommitDate: Mon Nov 24 22:06:59 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=885d12b0

install-qa-check.d/60pkgconfig: only match lines with known prefix

This prevents false positive for compiler lines that can
refer to compiler wrappers /usr/lib/ccache for example.

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

 bin/install-qa-check.d/60pkgconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/bin/install-qa-check.d/60pkgconfig 
b/bin/install-qa-check.d/60pkgconfig
index 27df0fb877..74a8397517 100644
--- a/bin/install-qa-check.d/60pkgconfig
+++ b/bin/install-qa-check.d/60pkgconfig
@@ -84,7 +84,8 @@ pkgconfig_check() {
fi
elif [[ ${f} == *lib64/pkgconfig* ]] ; then
# We want to match /lib/, /lib/foo/, but not e.g. 
/lib64 or /lib64/, or libfoo
-   if grep -E -q '=(/usr)?/lib\b' ${f} ; then
+   # Only check lines with a known prefix in order to 
avoid false positives
+   if grep -E -q -e '^libdir=(/usr)?/lib\b' -e 
'^Libs(\.private)?:.*/lib\b' "${f}" ; then
bad_libdir+=( "${f//${D}}" )
fi
fi



[gentoo-commits] proj/portage:master commit in: bin/

2025-11-22 Thread Ulrich Müller
commit: 0d222fbe7ac1ad3a4f1b61482015e19bad923d41
Author: Ulrich Müller  gentoo  org>
AuthorDate: Mon Nov 17 17:22:20 2025 +
Commit: Ulrich Müller  gentoo  org>
CommitDate: Sat Nov 22 19:52:33 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=0d222fbe

EAPI 9: Update Bash version from 5.2 to 5.3

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

 bin/eapi.sh   | 2 +-
 bin/ebuild.sh | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/bin/eapi.sh b/bin/eapi.sh
index 7babdf62e0..f5a58da097 100644
--- a/bin/eapi.sh
+++ b/bin/eapi.sh
@@ -86,7 +86,7 @@ ___eapi_usev_has_second_arg() 
  [[ ${1-${EAPI-0}
 ___eapi_bash_3_2()  [[ ${1-${EAPI-0}} == [0-5] ]]
 ___eapi_bash_4_2()  [[ ${1-${EAPI-0}} == [67]  ]]
 ___eapi_bash_5_0()  [[ ${1-${EAPI-0}} == 8 ]]
-___eapi_bash_5_2()  [[ ${1-${EAPI-0}} != [0-8] ]]
+___eapi_bash_5_3()  [[ ${1-${EAPI-0}} != [0-8] ]]
 ___eapi_enables_failglob_in_global_scope()  [[ ${1-${EAPI-0}} != [0-5] ]]
 ___eapi_has_ENV_UNSET() [[ ${1-${EAPI-0}} != [0-6] ]]
 ___eapi_has_strict_keepdir()[[ ${1-${EAPI-0}} != [0-7] ]]

diff --git a/bin/ebuild.sh b/bin/ebuild.sh
index 12adee68b4..6e59e65d3d 100755
--- a/bin/ebuild.sh
+++ b/bin/ebuild.sh
@@ -34,10 +34,10 @@ __check_bash_version() {
dependent="EAPI ${EAPI}"
(( compat_maj = maj = 5 ))
(( compat_min = min = 0 ))
-   elif ___eapi_bash_5_2; then
+   elif ___eapi_bash_5_3; then
dependent="EAPI ${EAPI}"
(( compat_maj = maj = 5 ))
-   (( compat_min = min = 2 ))
+   (( compat_min = min = 3 ))
fi
 
# Ensure that the minimum required version is satisfied.



[gentoo-commits] proj/portage:master commit in: bin/

2025-11-16 Thread Sam James
commit: 6e687a2a0d69874980bea6cee844d64dc42d10e7
Author: Sam James  gentoo  org>
AuthorDate: Mon Nov 17 06:04:22 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Mon Nov 17 06:04:22 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=6e687a2a

Revert "ecompress: enhance the diagnostics where PORTAGE_COMPRESS is set as 
"true""

This reverts commit e1d973f18e4836665eda914665c6d20c1c196b33. I rebased
before when merging this commit and didn't fixup Kerin's 'See-also' note again.

Will reapply properly shortly.

Bug: https://bugs.gentoo.org/965903
Signed-off-by: Sam James  gentoo.org>

 bin/ecompress | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/bin/ecompress b/bin/ecompress
index 1c0f04589a..0073cb47b9 100755
--- a/bin/ecompress
+++ b/bin/ecompress
@@ -250,11 +250,7 @@ fi
 
 # figure out the new suffix
 if ! PORTAGE_COMPRESS_SUFFIX=$(guess_suffix); then
-   error="${0##*/}: failed to determine the suffix of archives created by 
${PORTAGE_COMPRESS@Q}"
-   if [[ ${PORTAGE_COMPRESS##*/} == @(true|:) ]]; then
-   error+=' (to disable compression, set PORTAGE_COMPRESS="" 
instead)'
-   fi
-   die "${error}"
+   die "Failed to determine the suffix of archives created by 
${PORTAGE_COMPRESS@Q}"
 fi
 
 export PORTAGE_COMPRESS_SUFFIX PORTAGE_COMPRESS_FLAGS PORTAGE_COMPRESS



[gentoo-commits] proj/portage:master commit in: bin/

2025-11-16 Thread Sam James
commit: 4bcb638bb2e250f1954b1e09fe053fae1b92f91b
Author: Kerin Millar  plushkava  net>
AuthorDate: Mon Nov 10 17:24:03 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Mon Nov 17 06:04:59 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=4bcb638b

ecompress: enhance the diagnostics where PORTAGE_COMPRESS is set as "true"

Some define PORTAGE_COMPRESS as "true" or ":" to inhibit compression but
the correct way to go about it is to define the compressor as the empty
string. For such cases, refine the exception message so that users may
better understand its ramifications.

ecompress: failed to determine the suffix of archives created by 'true'
(to disable compression, set PORTAGE_COMPRESS="" instead)

See-also: 6edb8eac940f0bdd538a59cc8f1070efba161b53
See-also: 3483b585a0d416ab345666b885e325bbfaf231bf
See-also: 3498e0f1c1fe6c7f23707d0e56462fbc8dfb487d
Closes: https://bugs.gentoo.org/965903
Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/ecompress | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/bin/ecompress b/bin/ecompress
index 0073cb47b9..1c0f04589a 100755
--- a/bin/ecompress
+++ b/bin/ecompress
@@ -250,7 +250,11 @@ fi
 
 # figure out the new suffix
 if ! PORTAGE_COMPRESS_SUFFIX=$(guess_suffix); then
-   die "Failed to determine the suffix of archives created by 
${PORTAGE_COMPRESS@Q}"
+   error="${0##*/}: failed to determine the suffix of archives created by 
${PORTAGE_COMPRESS@Q}"
+   if [[ ${PORTAGE_COMPRESS##*/} == @(true|:) ]]; then
+   error+=' (to disable compression, set PORTAGE_COMPRESS="" 
instead)'
+   fi
+   die "${error}"
 fi
 
 export PORTAGE_COMPRESS_SUFFIX PORTAGE_COMPRESS_FLAGS PORTAGE_COMPRESS



[gentoo-commits] proj/portage:master commit in: bin/

2025-11-12 Thread Zac Medico
commit: 2f5d29ad29f1926c887838ed8dbfb098a6e58015
Author: Zac Medico  gentoo  org>
AuthorDate: Thu Nov 13 05:25:13 2025 +
Commit: Zac Medico  gentoo  org>
CommitDate: Thu Nov 13 05:26:21 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=2f5d29ad

egencache: update changelogs atomically

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

 bin/egencache | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/egencache b/bin/egencache
index 7359a17125..a204b4b153 100755
--- a/bin/egencache
+++ b/bin/egencache
@@ -929,7 +929,7 @@ try:
 return
 
 try:
-output = open(
+output = atomic_ofstream(
 self._changelog_output,
 mode="w",
 encoding=_encodings["repo.content"],



[gentoo-commits] proj/portage:master commit in: bin/

2025-11-10 Thread Zac Medico
commit: bf8819eb6a578957741caaabe33e2f3b67265336
Author: Zac Medico  gentoo  org>
AuthorDate: Tue Nov 11 02:33:18 2025 +
Commit: Zac Medico  gentoo  org>
CommitDate: Tue Nov 11 04:58:32 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=bf8819eb

egencache: update use.local.desc atomically

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

 bin/egencache | 20 +++-
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/bin/egencache b/bin/egencache
index 6b131360d5..7359a17125 100755
--- a/bin/egencache
+++ b/bin/egencache
@@ -63,7 +63,7 @@ try:
 from portage.package.ebuild._parallel_manifest.ManifestScheduler import (
 manifest_scheduler_retry,
 )
-from portage.util import cmp_sort_key, writemsg_level, no_color
+from portage.util import atomic_ofstream, cmp_sort_key, writemsg_level, 
no_color
 from portage.util._async.AsyncFunction import AsyncFunction
 from portage.util._async.AsyncTaskFuture import AsyncTaskFuture
 from portage.util._async.run_main_scheduler import run_main_scheduler
@@ -669,7 +669,7 @@ try:
 "r+b",
 )
 else:
-output = open(
+output = atomic_ofstream(
 _unicode_encode(
 desc_path, encoding=_encodings["fs"], 
errors="strict"
 ),
@@ -698,7 +698,7 @@ try:
 )
 self._preserve_comments = False
 try:
-output = open(
+output = atomic_ofstream(
 _unicode_encode(
 desc_path, encoding=_encodings["fs"], 
errors="strict"
 ),
@@ -728,14 +728,24 @@ try:
 
 # Finished probing comments in binary mode, now append
 # in text mode.
-output = open(
+output = atomic_ofstream(
 _unicode_encode(
 desc_path, encoding=_encodings["fs"], errors="strict"
 ),
-mode="a",
+mode="w",
 encoding=_encodings["repo.content"],
 errors="backslashreplace",
 )
+# Copy previous content in order to simulate "append" with 
atomic_ofstream.
+with open(
+_unicode_encode(
+desc_path, encoding=_encodings["fs"], errors="strict"
+),
+encoding=_encodings["repo.content"],
+errors="backslashreplace",
+) as previous_content:
+for line in previous_content:
+output.write(line)
 output.write("\n")
 else:
 output.write(



[gentoo-commits] proj/portage:master commit in: bin/

2025-11-10 Thread Sam James
commit: e1d973f18e4836665eda914665c6d20c1c196b33
Author: Kerin Millar  plushkava  net>
AuthorDate: Mon Nov 10 17:24:03 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Mon Nov 10 18:09:15 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=e1d973f1

ecompress: enhance the diagnostics where PORTAGE_COMPRESS is set as "true"

Some define PORTAGE_COMPRESS as "true" or ":" to inhibit compression but
the correct way to go about it is to define the compressor as the empty
string. For such cases, refine the exception message so that users may
better understand its ramifications.

ecompress: failed to determine the suffix of archives created by 'true'
(to disable compression, set PORTAGE_COMPRESS="" instead)

See-also: please insert commit id for make.conf(5) update here
See-also: 3483b585a0d416ab345666b885e325bbfaf231bf
See-also: 3498e0f1c1fe6c7f23707d0e56462fbc8dfb487d
Closes: https://bugs.gentoo.org/965903
Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/ecompress | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/bin/ecompress b/bin/ecompress
index 4aa0363f26..81e4dfee6f 100755
--- a/bin/ecompress
+++ b/bin/ecompress
@@ -253,7 +253,11 @@ fi
 
 # figure out the new suffix
 if ! PORTAGE_COMPRESS_SUFFIX=$(guess_suffix); then
-   die "Failed to determine the suffix of archives created by 
${PORTAGE_COMPRESS@Q}"
+   error="${0##*/}: failed to determine the suffix of archives created by 
${PORTAGE_COMPRESS@Q}"
+   if [[ ${PORTAGE_COMPRESS##*/} == @(true|:) ]]; then
+   error+=' (to disable compression, set PORTAGE_COMPRESS="" 
instead)'
+   fi
+   die "${error}"
 fi
 
 export PORTAGE_COMPRESS_SUFFIX PORTAGE_COMPRESS_FLAGS PORTAGE_COMPRESS



[gentoo-commits] proj/portage:master commit in: bin/ebuild-helpers/

2025-11-08 Thread Zac Medico
commit: da7c15042191648cb21a886b8afcf739b55c66c3
Author: Zac Medico  gentoo  org>
AuthorDate: Sun Nov  9 00:11:57 2025 +
Commit: Zac Medico  gentoo  org>
CommitDate: Sun Nov  9 00:39:02 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=da7c1504

emake: ignore MAKEOPTS if MAKEFLAGS is set

The two variables are currently mutually exclusive because
MAKEOPTS resets the MAKEFLAGS jobserver mode like this:

make -j8 -l8
make: warning: -j8 forced in submake: resetting jobserver mode.

Since functions like ___makeopts_jobs currently support MAKEOPTS
and not MAKEFLAGS, it can still be useful to set MAKEOPTS in
addition to MAKEFLAGS.

Fixes: 6f958be3cfa5054541ab3db0bcff73a496ecd0be
Bug: https://bugs.gentoo.org/692576
Signed-off-by: Zac Medico  gentoo.org>

 bin/ebuild-helpers/emake | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/bin/ebuild-helpers/emake b/bin/ebuild-helpers/emake
index 33af49f831..d52adb5843 100755
--- a/bin/ebuild-helpers/emake
+++ b/bin/ebuild-helpers/emake
@@ -1,5 +1,5 @@
 #!/usr/bin/env bash
-# Copyright 1999-2015 Gentoo Foundation
+# Copyright 1999-2025 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 #
 # emake: Run make and automatically pass along flags set in the env.  We 
support
@@ -11,6 +11,9 @@
 
 source "${PORTAGE_BIN_PATH:?}"/isolated-functions.sh || exit
 
+# Prevent MAKEOPTS from resetting MAKEFLAGS jobserver mode for bug 692576.
+[[ -n ${MAKEFLAGS} ]] && unset MAKEOPTS
+
 cmd=(
${MAKE:-make} ${MAKEOPTS} "$@" ${EXTRA_EMAKE}
 )



[gentoo-commits] proj/portage:master commit in: bin/

2025-11-07 Thread Sam James
commit: 4d435c6d22ac2a270c64aaef3e39aac2f1ccf38e
Author: Kerin Millar  plushkava  net>
AuthorDate: Fri Nov  7 00:15:59 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Sat Nov  8 00:36:46 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=4d435c6d

ecompress: avoid losing track of find(1) in fix_symlinks()

Presently, the fix_symlinks() function is tasked with finding and
correcting symlinks that are dangling as a consequence of their targets
having been compressed. The routine that does so is structured in the
following way.

while IFS= read -rd '' link && IFS= read -rd '' target; do
# Repair the symlinks. May execute rm(1) and ln(1).
done < <(
# Find dangling symlinks.
find "$top" -type l -xtype l -printf '%p\0%l\0'
)

# Reap the exit status of find(1), returning false upon failure.
wait "$!" || return

For this, a user reported the following error.

ecompress: line 172: wait: pid 18991 is not a child of this shell

After some initial difficulty in reproducing it, I realised that bash
was losing track of find(1) in its capacity as a background job, owing
to PID reuse. The reasons for the user being able to consistently induce
this issue are as follows.

- both rm(1) and ln(1) are executed many times for openssl (5138 each)
- his kernel was subject to a limit of kernel.pid_max = 32768
- he has a large number of processes (or endures a high fork rate)

Here is a simple reproducer.

# sysctl -w kernel.pid_max=512
# while read -r; do /bin/true; done < <(seq 1 1024); wait "$!"
bash: wait: pid 320 is not a child of this shell

Interestingly, not all shells have this problem. Consider dash as a case
in point.

# dash -c 'mkfifo fifo
{ seq 1 1024; exit 123; } > fifo & pid=$!
while read -r line; do /bin/true; done < fifo; wait "$pid"
echo "$?"'
123

I found it odd that the ability to reap a single asynchronous command
would be affected by proceeding to issue any number of commands in the
foreground. I contacted Chet Ramey, upon which he acknowledged the
problem and explained that bash is only able to keep one record of a
single PID throughout its job control code. Further, this limitation
extends to both background and foreground jobs, so as to simplify the
internal bookkeeping. Consequently, he is considering whether it would
be practical to have bash retain the status of a terminated background
process in the event that a foreground process recycles its PID.

In the meantime, ecompress must operate in a manner that is immune to
this issue. To that end, eschew the use of a process substitution by the
fix_symlinks() function. Instead, employ a conventional pipeline and
determine the exit status of find(1) by examining the PIPESTATUS array.
Also, to compensate for this change, enable the lastpipe shell option,
so that the assignment to the 'something_changed' variable is not lost
to a subshell.

Reported-by: Dan Johansson  dmj.nu>
Fixes: 781732d87525469e311732d5418ffb0f3e419da8
Closes: https://bugs.gentoo.org/965423
Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/ecompress | 24 ++--
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/bin/ecompress b/bin/ecompress
index a59e699f07..4aa0363f26 100755
--- a/bin/ecompress
+++ b/bin/ecompress
@@ -144,14 +144,21 @@ guess_suffix() (
done
 )
 
-fix_symlinks() {
+fix_symlinks() (
local something_changed link target1 target2 i
 
+   # Run the last element of the ensuing pipeline in the current shell.
+   # This option shall not persist because the function is a forking list.
+   shopt -s lastpipe
+
# Repeat until nothing changes, in order to handle multiple
# levels of indirection (see bug #470916).
while true ; do
something_changed=0
-   while IFS= read -rd '' link && IFS= read -rd '' target1; do
+
+   printf '%s\0' "${ED}" \
+   | find0 -type l -xtype l -printf '%p\0%l\0' \
+   | while IFS= read -rd '' link && IFS= read -rd '' target1; do
target2=${target1}${PORTAGE_COMPRESS_SUFFIX}
 
if [[ ${target2} == /* ]]; then
@@ -166,10 +173,15 @@ fix_symlinks() {
rm -f -- "${link}" \
&& ln -snf -- "${target2}" 
"${link}${PORTAGE_COMPRESS_SUFFIX}" \
|| return
-   done < <(printf '%s\0' "${ED}" | find0 -type l -xtype l -printf 
'%p\0%l\0')
+   done
 
-   # Check whether the invocation of find(1) succeeded.
-   wait "$!" || return
+   # Check whether the invocation of find(1) succeeded. The use of
+   # the wait builtin is avoided here because the rm(1) and ln(1)
+   # utilities may be executed many times, with bash being prone
+   # to losing the status code of the last asynchronous command as
+   # a conseq

[gentoo-commits] proj/portage:master commit in: bin/, lib/_emerge/

2025-10-27 Thread Zac Medico
commit: 9c63c4541ffb891dcb6cbf94c8f5ad8d643c684f
Author: Zac Medico  gentoo  org>
AuthorDate: Mon Oct 27 22:28:38 2025 +
Commit: Zac Medico  gentoo  org>
CommitDate: Mon Oct 27 23:25:29 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=9c63c454

egencache: retry metadata process with unexpected returncode

Since MetadataRegen is not well suited for internal retry, create
a new MetadataRegen instance for each retry. Returns the returncode
from the last MetadataRegen instance, which will only be non-zero
if all retries failed.

Since we only observe bug 965132 in the python3.14 forkserver tests,
it seems like this must be some kind of forkserver bug that causes
our bash proccess to occasionally silently fail with returncode 255.

It may be very difficult to find the root cause of this forkserver
issue, and we can't predict how soon it will be fixed. Meanwhile,
I think we will appreciate the retry if it eliminates our
intermittent CI failures.

Another possible solution would be to force the multiprocessing
start method to spawn inside the egencache process (like
_EbuildFetcherProcess).

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

 bin/egencache| 29 +
 lib/_emerge/MetadataRegen.py | 51 +++-
 2 files changed, 70 insertions(+), 10 deletions(-)

diff --git a/bin/egencache b/bin/egencache
index 6ed455dd4c..d36ae5d32e 100755
--- a/bin/egencache
+++ b/bin/egencache
@@ -65,6 +65,7 @@ try:
 )
 from portage.util import cmp_sort_key, writemsg_level, no_color
 from portage.util._async.AsyncFunction import AsyncFunction
+from portage.util._async.AsyncTaskFuture import AsyncTaskFuture
 from portage.util._async.run_main_scheduler import run_main_scheduler
 from portage.util._async.TaskScheduler import TaskScheduler
 from portage.util._eventloop.global_event_loop import global_event_loop
@@ -72,7 +73,7 @@ try:
 from portage import cpv_getkey
 from portage.dep import Atom, isjustname
 from portage.versions import vercmp
-from _emerge.MetadataRegen import MetadataRegen
+from _emerge.MetadataRegen import metadata_regen_retry
 
 try:
 from xml.etree import ElementTree
@@ -320,15 +321,22 @@ try:
 write_auxdb = (
 external_cache_only or "metadata-transfer" in 
portdb.settings.features
 )
-self._regen = MetadataRegen(
-portdb,
-cp_iter=cp_iter,
-consumer=self._metadata_callback,
-max_jobs=max_jobs,
-max_load=max_load,
-write_auxdb=write_auxdb,
-main=True,
+self._regen_task = AsyncTaskFuture(
+future=metadata_regen_retry(
+portdb,
+cp_iter=cp_iter,
+consumer=self._metadata_callback,
+max_jobs=max_jobs,
+max_load=max_load,
+write_auxdb=write_auxdb,
+main=True,
+)
 )
+self._regen = TaskScheduler(
+iter([self._regen_task]),
+event_loop=global_event_loop(),
+)
+
 self.returncode = os.EX_OK
 conf = portdb.repositories.get_repo_for_location(tree)
 if external_cache_only:
@@ -446,6 +454,9 @@ try:
 
 self.returncode |= self._regen.returncode
 
+# Raise an unexpected exception if one occurred.
+self._regen_task.future.result()
+
 for trg_cache in self._trg_caches:
 self._cleanse_cache(trg_cache)
 

diff --git a/lib/_emerge/MetadataRegen.py b/lib/_emerge/MetadataRegen.py
index 496e6295c9..55eb690e78 100644
--- a/lib/_emerge/MetadataRegen.py
+++ b/lib/_emerge/MetadataRegen.py
@@ -10,6 +10,46 @@ from portage.dep import _repo_separator
 from portage.util._async.AsyncScheduler import AsyncScheduler
 
 
+async def metadata_regen_retry(*args, max_tries=3, **kwargs) -> int:
+"""
+Since MetadataRegen is not well suited for internal retry, create
+a new MetadataRegen instance for each retry. Returns the returncode
+from the last MetadataRegen instance, which will only be non-zero
+if all retries failed.
+"""
+tries = max_tries
+scheduler = MetadataRegen(*args, **kwargs)
+scheduler.start()
+try:
+await scheduler.async_wait()
+except asyncio.CancelledError:
+scheduler.terminate()
+await scheduler.async_wait()
+raise
+cpv_failed = scheduler.cpv_failed.copy()
+tries -= 1
+while scheduler.cp_retry and tries > 0:
+kwargs["cp_iter"] = iter(scheduler.cp_retry)
+scheduler = MetadataRegen(*args, **kwargs)
+scheduler.start()
+try:
+await scheduler.async_wait()
+except asyncio.CancelledError:
+sc

[gentoo-commits] proj/portage:master commit in: bin/

2025-10-25 Thread Sam James
commit: b876d9b1c9ce58b8ba2440cf61bca7555a0dfb9b
Author: Kerin Millar  plushkava  net>
AuthorDate: Sun Oct 26 02:46:02 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Sun Oct 26 03:28:08 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=b876d9b1

emerge-webrsync: restore the missing option-arg for curl --continue-at

The curl(1) user-agent supports a --continue-at option, which requires
an option-argument. Where the option-argument is , curl
will automatically try to determine how to resume a transfer. Further,
emerge-webrsync forcibly injects the option if it detects that the value
of FETCHCOMMAND specifies a curl command.

However, the option-argument was unintentionally removed during a bout
of re-factoring and (otherwise unrelated) bug fixing. This went
unnoticed until now because wget is more commonly used. Restore it.

Fixes: f3af8263ce544750a9e9a155b1264d07a86677d4
Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/emerge-webrsync | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/emerge-webrsync b/bin/emerge-webrsync
index 53a3a12715..cca63ebb35 100755
--- a/bin/emerge-webrsync
+++ b/bin/emerge-webrsync
@@ -217,7 +217,7 @@ get_fetchcommand() {
fi
;;
curl)
-   opts="--continue-at -f -S"
+   opts="--continue-at - -f -S"
if (( opt[quiet] )); then
opts+=" -s"
fi



[gentoo-commits] proj/portage:master commit in: bin/

2025-10-24 Thread Sam James
commit: 26cc6dd4a30019a58841518d667fef2c30db145e
Author: Sam James  gentoo  org>
AuthorDate: Fri Oct 24 14:31:29 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Fri Oct 24 14:32:52 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=26cc6dd4

bin: fix signal_raise call

Fixes: d628848bfa2734db71f56f671cb7e66bdf5c5638
Signed-off-by: Sam James  gentoo.org>

 bin/ebuild| 2 +-
 bin/ebuild-ipc.py | 2 +-
 bin/egencache | 2 +-
 bin/emaint| 2 +-
 bin/emerge| 2 +-
 bin/portageq  | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/bin/ebuild b/bin/ebuild
index 7ce9f27c75..0c6369e016 100755
--- a/bin/ebuild
+++ b/bin/ebuild
@@ -440,4 +440,4 @@ if __name__ == "__main__":
 # Prevent traceback on ^C
 signum = getattr(e, "signum", signal.SIGINT)
 signal.signal(signum, signal.SIG_DFL)
-raise_signal(signum)
+signal.raise_signal(signum)

diff --git a/bin/ebuild-ipc.py b/bin/ebuild-ipc.py
index 5d7200893f..7c1b75d57e 100755
--- a/bin/ebuild-ipc.py
+++ b/bin/ebuild-ipc.py
@@ -308,4 +308,4 @@ except KeyboardInterrupt as e:
 # Prevent traceback on ^C
 signum = getattr(e, "signum", signal.SIGINT)
 signal.signal(signum, signal.SIG_DFL)
-raise_signal(signum)
+signal.raise_signal(signum)

diff --git a/bin/egencache b/bin/egencache
index 04eef08d97..6ed455dd4c 100755
--- a/bin/egencache
+++ b/bin/egencache
@@ -1386,4 +1386,4 @@ except KeyboardInterrupt as e:
 # Prevent traceback on ^C
 signum = getattr(e, "signum", signal.SIGINT)
 signal.signal(signum, signal.SIG_DFL)
-raise_signal(signum)
+signal.raise_signal(signum)

diff --git a/bin/emaint b/bin/emaint
index d18dd38983..ab9a4bb5a6 100755
--- a/bin/emaint
+++ b/bin/emaint
@@ -67,4 +67,4 @@ except KeyboardInterrupt as e:
 # Prevent traceback on ^C
 signum = getattr(e, "signum", signal.SIGINT)
 signal.signal(signum, signal.SIG_DFL)
-raise_signal(signum)
+signal.raise_signal(signum)

diff --git a/bin/emerge b/bin/emerge
index e98096d7c5..9e5d59cb04 100755
--- a/bin/emerge
+++ b/bin/emerge
@@ -90,7 +90,7 @@ if __name__ == "__main__":
 signal.signal(signum, signal.SIG_DFL)
 sys.stderr.write(f"\n\nExiting on signal {signum}\n")
 sys.stderr.flush()
-raise_signal(signum)
+signal.raise_signal(signum)
 finally:
 # Only close the event loop for __main__,
 # since outside of __main__ it would close the

diff --git a/bin/portageq b/bin/portageq
index a1c824c6f0..d10cbd9475 100755
--- a/bin/portageq
+++ b/bin/portageq
@@ -1573,4 +1573,4 @@ except KeyboardInterrupt as e:
 # Prevent traceback on ^C
 signum = getattr(e, "signum", signal.SIGINT)
 signal.signal(signum, signal.SIG_DFL)
-raise_signal(signum)
+signal.raise_signal(signum)



[gentoo-commits] proj/portage:master commit in: /, bin/

2025-10-24 Thread Zac Medico
commit: ae7c1f0753a801a42d3bdea4f055872428b6f6bc
Author: Zac Medico  gentoo  org>
AuthorDate: Fri Oct 24 07:29:15 2025 +
Commit: Zac Medico  gentoo  org>
CommitDate: Fri Oct 24 07:45:41 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=ae7c1f07

pylint fixes

* Module /home/runner/work/portage/portage/pylintrc
pylintrc:1:0: E0015: Unrecognized option found: suggestion-mode 
(unrecognized-option)
* Module emerge
bin/emerge:5:0: W0611: Unused import os (unused-import)
* Module emaint
bin/emaint:8:0: W0611: Unused import os (unused-import)

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

 bin/emaint | 1 -
 bin/emerge | 1 -
 pylintrc   | 4 
 3 files changed, 6 deletions(-)

diff --git a/bin/emaint b/bin/emaint
index 7b3ec6d562..d18dd38983 100755
--- a/bin/emaint
+++ b/bin/emaint
@@ -5,7 +5,6 @@
 """System health checks and maintenance utilities.
 """
 
-import os
 import signal
 
 

diff --git a/bin/emerge b/bin/emerge
index 246c641b4f..e98096d7c5 100755
--- a/bin/emerge
+++ b/bin/emerge
@@ -2,7 +2,6 @@
 # Copyright 2006-2025 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
-import os
 import signal
 import sys
 

diff --git a/pylintrc b/pylintrc
index 612f967e22..c2ecd6a07e 100644
--- a/pylintrc
+++ b/pylintrc
@@ -60,10 +60,6 @@ limit-inference-results=100
 # Pickle collected data for later comparisons.
 persistent=no
 
-# When enabled, pylint would attempt to guess common misconfiguration and emit
-# user-friendly hints instead of false-positive error messages.
-suggestion-mode=yes
-
 # Allow loading of arbitrary C extensions. Extensions are imported into the
 # active Python interpreter and may run arbitrary code.
 unsafe-load-any-extension=no



[gentoo-commits] proj/portage:master commit in: bin/

2025-10-23 Thread Sam James
commit: d628848bfa2734db71f56f671cb7e66bdf5c5638
Author: Sam James  gentoo  org>
AuthorDate: Thu Oct 23 18:27:38 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Thu Oct 23 18:27:38 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=d628848b

bin: drop old Python compat shim

Signed-off-by: Sam James  gentoo.org>

 bin/ebuild| 7 +--
 bin/ebuild-ipc.py | 7 +--
 bin/egencache | 7 +--
 bin/emaint| 7 +--
 bin/emerge| 7 +--
 bin/portageq  | 7 +--
 6 files changed, 6 insertions(+), 36 deletions(-)

diff --git a/bin/ebuild b/bin/ebuild
index b313094942..7ce9f27c75 100755
--- a/bin/ebuild
+++ b/bin/ebuild
@@ -1,15 +1,10 @@
 #!/usr/bin/env python
-# Copyright 1999-2023 Gentoo Authors
+# Copyright 1999-2025 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 import os
 import signal
 
-# For compatibility with Python < 3.8
-raise_signal = getattr(
-signal, "raise_signal", lambda signum: os.kill(os.getpid(), signum)
-)
-
 
 # Inherit from KeyboardInterrupt to avoid a traceback from asyncio.
 class SignalInterrupt(KeyboardInterrupt):

diff --git a/bin/ebuild-ipc.py b/bin/ebuild-ipc.py
index 059732eaf7..5d7200893f 100755
--- a/bin/ebuild-ipc.py
+++ b/bin/ebuild-ipc.py
@@ -1,5 +1,5 @@
 #!/usr/bin/env python
-# Copyright 2010-2022 Gentoo Authors
+# Copyright 2010-2025 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 #
 # This is a helper which ebuild processes can use
@@ -8,11 +8,6 @@
 import os
 import signal
 
-# For compatibility with Python < 3.8
-raise_signal = getattr(
-signal, "raise_signal", lambda signum: os.kill(os.getpid(), signum)
-)
-
 
 # Inherit from KeyboardInterrupt to avoid a traceback from asyncio.
 class SignalInterrupt(KeyboardInterrupt):

diff --git a/bin/egencache b/bin/egencache
index 36477e1abf..04eef08d97 100755
--- a/bin/egencache
+++ b/bin/egencache
@@ -1,15 +1,10 @@
 #!/usr/bin/env python
-# Copyright 2009-2022 Gentoo Authors
+# Copyright 2009-2025 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 import os
 import signal
 
-# For compatibility with Python < 3.8
-raise_signal = getattr(
-signal, "raise_signal", lambda signum: os.kill(os.getpid(), signum)
-)
-
 
 # Inherit from KeyboardInterrupt to avoid a traceback from asyncio.
 class SignalInterrupt(KeyboardInterrupt):

diff --git a/bin/emaint b/bin/emaint
index da925e1dad..7b3ec6d562 100755
--- a/bin/emaint
+++ b/bin/emaint
@@ -1,5 +1,5 @@
 #!/usr/bin/env python
-# Copyright 2005-2023 Gentoo Authors
+# Copyright 2005-2025 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 """System health checks and maintenance utilities.
@@ -8,11 +8,6 @@
 import os
 import signal
 
-# For compatibility with Python < 3.8
-raise_signal = getattr(
-signal, "raise_signal", lambda signum: os.kill(os.getpid(), signum)
-)
-
 
 # Inherit from KeyboardInterrupt to avoid a traceback from asyncio.
 class SignalInterrupt(KeyboardInterrupt):

diff --git a/bin/emerge b/bin/emerge
index bdc587d37e..246c641b4f 100755
--- a/bin/emerge
+++ b/bin/emerge
@@ -1,16 +1,11 @@
 #!/usr/bin/env python
-# Copyright 2006-2023 Gentoo Authors
+# Copyright 2006-2025 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 import os
 import signal
 import sys
 
-# For compatibility with Python < 3.8
-raise_signal = getattr(
-signal, "raise_signal", lambda signum: os.kill(os.getpid(), signum)
-)
-
 
 # Inherit from KeyboardInterrupt to avoid a traceback from asyncio.
 class SignalInterrupt(KeyboardInterrupt):

diff --git a/bin/portageq b/bin/portageq
index 869ec111b1..a1c824c6f0 100755
--- a/bin/portageq
+++ b/bin/portageq
@@ -1,15 +1,10 @@
 #!/usr/bin/env python
-# Copyright 1999-2021 Gentoo Authors
+# Copyright 1999-2025 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 import os
 import signal
 
-# For compatibility with Python < 3.8
-raise_signal = getattr(
-signal, "raise_signal", lambda signum: os.kill(os.getpid(), signum)
-)
-
 
 # Inherit from KeyboardInterrupt to avoid a traceback from asyncio.
 class SignalInterrupt(KeyboardInterrupt):



[gentoo-commits] proj/portage:master commit in: bin/

2025-10-23 Thread Sam James
commit: 151e728352e535a7371aed566b6f3d34221cdca6
Author: Sam James  gentoo  org>
AuthorDate: Thu Oct 23 18:23:58 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Thu Oct 23 18:26:17 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=151e7283

portageq: simplify match_orphaned

Signed-off-by: Sam James  gentoo.org>

 bin/portageq | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/bin/portageq b/bin/portageq
index e89c453686..869ec111b1 100755
--- a/bin/portageq
+++ b/bin/portageq
@@ -1122,10 +1122,7 @@ try:
 
 # Match if metadata.xml contains no maintainer (orphaned package)
 def match_orphaned(metadata_xml):
-if not metadata_xml.maintainers():
-return True
-else:
-return False
+return not metadata_xml.maintainers()
 
 def pquery(parser, opts, args):
 portdb = portage.db[portage.root]["porttree"].dbapi



[gentoo-commits] proj/portage:master commit in: bin/

2025-10-18 Thread Sam James
commit: 93e2c90293a502cb6402218f2823dc22e0a28093
Author: Kerin Millar  plushkava  net>
AuthorDate: Fri Sep 26 23:25:08 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Mon Sep 29 20:49:46 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=93e2c902

emerge-webrsync: mark TZ as exportable in do_latest_snapshot()

As concerns the do_latest_snapshot() function, a recent commit modified
it so as to take advantage of the ability of the printf builtin to act
as a strftime(3) wrapper, rather than be beholden to the non-standard
date(1) utility. As such, it declares 'TZ' as a local variable, with the
intent of ensuring that the UTC timezone is in effect.

However, though printf is indeed a builtin, to assign a new value to the
'TZ' variable is insufficient, as is demonstrated beneath.

# cd /etc
# cp /usr/share/zoneinfo/America/New_York localtime
# TZ=UTC
# printf '%(%F)T\n' 1758758400
2025-09-24
# export TZ
# printf '%(%F)T\n' 1758758400
2025-09-25

Address this issue by setting the 'x' attribute for the 'TZ' variable at
the point of its declaration.

Reported-by: Hank Leininger  korelogic.com>
Closes: https://bugs.gentoo.org/963423
Fixes: caa8f296a5b3f5bdb8f36321a9334f8ff52d9d30
Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/emerge-webrsync | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/bin/emerge-webrsync b/bin/emerge-webrsync
index 8807c8e737..53a3a12715 100755
--- a/bin/emerge-webrsync
+++ b/bin/emerge-webrsync
@@ -537,7 +537,8 @@ is_snapshot_fresh() {
 
 do_latest_snapshot() {
local timestamp_{difference,problem} snapshot_{date,unixtime} 
approx_snapshot_time existing_timestamp start_{hour,time}
-   local min_time_diff attempts TZ=UTC
+   local min_time_diff attempts
+   local -x TZ=UTC
 
einfo "Fetching most recent snapshot ..."
 



[gentoo-commits] proj/portage:master commit in: bin/

2025-09-29 Thread Sam James
commit: 968df8172a30781408a60c974d60050098d36971
Author: Kerin Millar  plushkava  net>
AuthorDate: Sun Sep 28 20:15:42 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Mon Sep 29 20:49:46 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=968df817

phase-helpers.sh: unpack(): handle "--" in accordance with PMS

As concerns the unpack() function, a recent commit cleaned up its
option parsing routine. However, the revised code fails to account for
the fact that PMS mandates that the "--" argument be treated in a
somewhat unconventional way. Consider the following invocation.

  eapply -d "${S}/subdir" -- "${FILESDIR}/${PN}-some-necessary.patch"

Those familiar with getopt(3) conventions will immediately understand
that "--" is used to separate options and option-arguments from operands
(non-options). But the specification for eapply() goes further by
mandating that, if "--" is encountered, all arguments to its left are to
be conveyed to the patch(1) utility, irrespective of their values.
Further, in that event, the specification mandates that the rule of
options only being able to precede operands shall not be enforced.

Such an approach confers the benefit of being able to convey
option-arguments following short options to patch(1), without eapply()
needing to be aware of how the utility parses them. Therein lies the
rub, since the revised code fails to handle "--" in the prescribed way.
Instead, the "${S}/subdir" argument is considered as an eapply() operand
on account of not leading with a .

Address this issue by once again permitting for the positional
parameters to be iterated over up to two times, and handling the
presence of the "--" argument as a special case. Yet, do so without
unduly impacting on the simplicity of the code that is a consequence of
its original refactoring.

Reported-by: Pavel Sobolev  paveloom.dev>
Closes: https://bugs.gentoo.org/963536
Fixes: d594f7a2779aa644c30a85a25c9811f02970
Link: https://projects.gentoo.org/pms/8/pms.html#x1-127001r1
Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/phase-helpers.sh | 42 --
 1 file changed, 32 insertions(+), 10 deletions(-)

diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index aa9f6af8be..e1f301a5f5 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -1024,26 +1024,48 @@ if ___eapi_has_eapply; then
local LC_ALL LC_COLLATE=C f i path
local -a operands options
 
+   # PMS mandates an unconventional option parsing scheme whereby
+   # the rule that options must precede non-option arguments is
+   # only enforced in the case that no "--" argument is found.
+   # https://projects.gentoo.org/pms/8/pms.html#x1-127001r1
while (( $# )); do
case $1 in
--)
-   shift
-   operands+=("$@")
break
;;
-   -*)
-   if (( ! ${#operands[@]} )); then
-   options+=("$1")
-   else
-   die "eapply: options must 
precede non-option arguments"
-   fi
-   ;;
*)
-   operands+=("$1")
+   options+=("$1")
esac
shift
done
 
+   if (( $# )); then
+   # The "--" argument was encountered. Forward those to
+   # its left to the patch(1) utility, while considering
+   # those to its right as eapply operands.
+   shift
+   operands=("$@")
+   else
+   # Restore the positional parameters and parse normally.
+   set -- "${options[@]}"
+   options=()
+
+   while (( $# )); do
+   case $1 in
+   -*)
+   if (( ! ${#operands[@]} )); then
+   options+=("$1")
+   else
+   die "eapply: options 
must precede non-option arguments"
+   fi
+   ;;
+   *)
+   operands+=("$1")
+   esac
+   

[gentoo-commits] proj/portage:master commit in: bin/

2025-09-25 Thread Sam James
commit: 44adc055f62ccb3f6c6191513805438fd4b81ead
Author: Kerin Millar  plushkava  net>
AuthorDate: Mon Sep 22 04:04:49 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Mon Sep 22 11:28:20 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=44adc055

isolated-functions.sh: drop the find0() fallback implementation

Presently, there are two implementations of find0(), one of which serves
to cover situations where the -files0-from option is unavailable,
thereby retaining compatibility with CI environments based on Ubuntu
22.04. As of the 11th September, said environments are based on Ubuntu
24.04. Therefore, the fallback implementation is no longer required.

See-also: ff6b048dfc3cbee134cda0cfdc1dada43d21d961
Bug: https://bugs.gentoo.org/957550
Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/isolated-functions.sh | 28 
 1 file changed, 4 insertions(+), 24 deletions(-)

diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index fdca233323..393a36ed64 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -681,30 +681,10 @@ contains_word() {
 # Invoke GNU find(1) in such a way that the paths to be searched are consumed
 # as a list of one or more null-terminated records from STDIN. The positional
 # parameters shall be conveyed verbatim and are guaranteed to be treated as
-# options and/or primaries, provided that the version of GNU findutils is 4.9.0
-# or greater. For older versions, no such guarantee is made.
-if printf '/\0' | find -files0-from - -maxdepth 0 &>/dev/null; then
-   find0() {
-   find -files0-from - "$@"
-   }
-else
-   # This is a temporary workaround for the GitHub CI runner, which
-   # suffers from an outdated version of findutils, per bug 957550.
-   find0() {
-   local -a opts paths
-
-   # All of -H, -L and -P are options. If specified, they must
-   # precede pathnames and primaries alike.
-   while [[ $1 == -[HLP] ]]; do
-   opts+=("$1")
-   shift
-   done
-   mapfile -td '' paths
-   if (( ${#paths[@]} )); then
-   find "${opts[@]}" "${paths[@]}" "$@"
-   fi
-   }
-fi
+# options and/or primaries. This requires GNU findutils >=4.9.0.
+find0() {
+   find -files0-from - "$@"
+}
 
 # Consumes the standard input and attempts to parse it as the "configparser"
 # configuration file format that is native to python. Each key/value entry



[gentoo-commits] proj/portage:master commit in: bin/

2025-09-19 Thread Sam James
commit: 297c50c0369dca15b109f81a9c5f35df870412de
Author: Kerin Millar  plushkava  net>
AuthorDate: Sat Aug 30 12:13:42 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Mon Sep 15 10:37:55 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=297c50c0

phase-helpers.sh: order case patterns alphabetically in unpack()

As concerns the unpack() function, order the patterns specified by the
second of its case statements alphabetically. This is in advance of a
refactoring that shall incorporate a bug fix.

Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/phase-helpers.sh | 62 ++--
 1 file changed, 31 insertions(+), 31 deletions(-)

diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index 68009fcc0e..fa33090dec 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -414,44 +414,19 @@ unpack() {
fi
 
case ${suffix,,} in
-   tar)
-   tar xof "${srcdir}${f}"
-   ;;
-   tgz)
-   tar xozf "${srcdir}${f}"
-   ;;
-   tbz|tbz2)
-   (( ${#bzip2_cmd[@]} )) || __compose_bzip2_cmd
-   "${bzip2_cmd[@]}" -c -- "${srcdir}${f}" | tar 
xof -
-   ;;
-   zip|jar)
-   # unzip will interactively prompt under some 
error conditions,
-   # as reported in bug #336285. Inducing EOF on 
STDIN makes for
-   # an adequate countermeasure.
-   unzip -qo "${srcdir}${f}" &2
false
fi
;;
-   rar)
-   unrar x -idq -o+ "${srcdir}${f}"
-   ;;
-   lha|lzh)
-   lha xfq "${srcdir}${f}"
-   ;;
a)
ar x "${srcdir}${f}"
;;
+   bz|bz2)
+   (( ${#bzip2_cmd[@]} )) || __compose_bzip2_cmd
+   __unpack_tar "${bzip2_cmd[@]}"
+   ;;
deb)
# Unpacking .deb archives can not always be 
done with
# `ar`.  For instance on AIX this doesn't work 
out.
@@ -475,15 +450,40 @@ unpack() {
ar x "${srcdir}${f}"
fi
;;
+   gz|z)
+   __unpack_tar gzip -d
+   ;;
+   jar|zip)
+   # unzip will interactively prompt under some 
error conditions,
+   # as reported in bug #336285. Inducing EOF on 
STDIN makes for
+   # an adequate countermeasure.
+   unzip -qo "${srcdir}${f}" 

[gentoo-commits] proj/portage:master commit in: bin/

2025-09-16 Thread Sam James
commit: 5ee2d40e97c2aa21a3d322f486fe6783a150bbda
Author: Kerin Millar  plushkava  net>
AuthorDate: Tue Sep 16 12:53:53 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Sep 16 15:40:42 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=5ee2d40e

phase-helpers.sh: install default docs where DOCS is undeclared, not unset

EAPI 6 introduced the einstalldocs() function. A recent commit altered
the behaviour of the function in such a way that, if the 'DOCS' variable
is found to be unset, a default set of documentation files shall be
installed. The prior behaviour was to do so in the event that the
variable is undeclared.

It transpires that there is a disagreement between the implementation
and the specification. Below is an excerpt of the pseudocode presented
by PMS, with some redactions made for the purpose of legibility.

 7: else if the DOCS variable is unset then
 8:   for all d matching the filename expansion of README* ChangeLog AUTHORS ...
 9: if file d exists and has a size greater than zero then
10:   call dodoc with d as argument
11: end if
12:   end for
13: end if

Note the use of the term, unset. In bash, it is quite possible to
declare a variable that remains in an unset state.

# ( DOCS=(); test -v DOCS || echo unset )
unset
# ( f() { local -a DOCS; test -v DOCS || echo unset; }; f )
unset

Effectively, PMS is in the wrong. By focusing unduly on the
specification, I inadvertently introduced a regression whereby, if
'DOCS' is set as an empty array, the function proceeds to install the
default documentation.

Address this issue by restoring the prior behaviour of checking whether
'DOCS' is undeclared. Further, perform the test by taking advantage of
the ${param@A} form of expansion, rather than parse the output of the
declare builtin as the prior implementation did. Not only does this
approach avoid an unnecessary subshell but it addresses an adjacent bug.
Imagine that 'DOCS' is declared as a function-local array that is empty.

src_install() {
# This declares a local array that is unset and empty
local -a DOCS
# Imagine that einstalldocs() continues to parse declare -p.
# Here, it will proceed to install the default documentation.
einstalldocs
}

This long-standing bug was caused by testing in the fashion of
[[ $(declare -p DOCS) != *=* ]], which falsely assumes that the
 character is present for a declared variable.

# ( DOCS=(); declare -p DOCS; )
declare -a DOCS=()
# ( f() { local -a DOCS; declare -p DOCS; }; f ) # no 
declare -a DOCS

Fixes: 7ff579ccb92b2f2512933a41e9a0a204b0601201
Closes: https://bugs.gentoo.org/962934
Link: https://projects.gentoo.org/pms/6/pms.html#x1-145003r4
Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/phase-helpers.sh | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index 47c6f8167c..aa9f6af8be 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -962,7 +962,11 @@ if ___eapi_has_einstalldocs; then
einstalldocs() (
local f
 
-   if [[ ! -v DOCS ]]; then
+   # The implementation deviates from PMS, which purports to be
+   # concerned with whether the "DOCS variable is unset". In fact,
+   # the implementation checks whether the variable is undeclared.
+   # However, it is PMS that is in the wrong. See bug #962934.
+   if [[ ! ${DOCS@A} ]]; then
for f in README* ChangeLog AUTHORS NEWS TODO CHANGES \
THANKS BUGS FAQ CREDITS CHANGELOG
do



[gentoo-commits] proj/portage:master commit in: bin/

2025-09-16 Thread Sam James
commit: 3e89139fae34c9bd2e2b4c0490512f71d1d78546
Author: Kerin Millar  plushkava  net>
AuthorDate: Tue Sep  2 10:07:57 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Mon Sep 15 10:37:56 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=3e89139f

phase-helpers.sh: refactor unpack() and have tar execute its decompressors

This commit subjects the unpack() function to an overall refactoring
while incorporating a fix for a regression that I was aware of and which
has since been independently identified and filed as bug #962874. The
changes are described herewith.

Declare all of the supported archive suffixes in a fashion that mirrors
the language of PMS. To wit, all documented suffixes are initially
declared as elements of the 'suffixes' array, case-sensitively. In turn,
that means that the following suffixes are now considered as first class
entities, as opposed to being supported as a consequence of the
machinations of the __unpack_tar() function.

- tar.bz
- tar.bz2
- tar.gz
- tar.lzma
- tar.Z

After having composed the 'suffixes' array, declare an associative array
by the name of 'suffix_by', where each key of the latter is an element
of the former. In the case that the effective EAPI is found not to be
case-sensitive, exploit the 'l' attribute of the declare/typeset
builtin, by which bash is able to induce a lowercase conversion upon
assignment. The latter array is prepared before the main loop begins and
makes it easy to determine whether a given suffix is recognised, whilst
doing away with the code pertaining to the now defunct 'suffix_known'
variable (which was not particularly digestible).

Declare and localise the 'XZ_OPT' variable in such a way that it is
rendered exportable. Do so before the main loop begins, duly
guaranteeing that the __makeopts_jobs() function shall be called just
once and obviating the need to incorporate the -T option of the xz(1)
utility at a later juncture.

Employ a regular expression to extract the suffix of each filename that
is considered. The pattern matches what is commonly referred to as an
extension whilst permitting for it to be preceded by "tar.". Once the
suffix has been extracted, employ a trivial -v test so as to determine
whether it exists as a key in the 'suffix_by' array.

Jettison the __unpack_tar() function. Not only was it responsible for
operating on files that are _not_ tarballs but it was also responsible
for further scrutinising the nature of the suffix. Long had I considered
it to be in poor taste. Instead, have each case pattern be accompanied
by the appropriate command.

To compensate for the aforementioned change, introduce the following
case patterns.

- tar.bz|tar.bz2|tbz|tbz2)
- tar|tar.*|tgz)

Further, jettison the following case patterns.

- tar)
- tbz|tbz2)
- tgz)

Jettison the __compose_bzip2_cmd() function. Instead, determine which
command may be employed to handle bzip2-compressed streams before the
main loop begins, unconditionally. Further, refrain from throwing an
exception in the event that both the 'PORTAGE_BUNZIP2_COMMAND' and
'PORTAGE_BZIP2_COMMAND' variables are defined as blank values.

Refrain entirely from employing shell pipelines to combine the tar(1)
utility with any particular decompression utility. Instead, delegate the
responsibility of executing the decompressor entirely to tar(1). The
rationale for this is twofold.

Firstly, GNU tar is already perfectly capable of recognising a
considerable number of file suffixes in the case that the -f option is
specified. No fewer than 16, in fact. Based on these suffixes, it is
further capable of determining whether to execute any of 8 distinct
decompression utilities: compress(1), bzip2(1), gzip(1), lzip(1),
lzma(1), lzop(1), xz(1) and zstd(1). Ergo, there is no sense in
maintaining equivalnt bash code that amounts merely to busywork.

Secondly, there have been several portage bugs concerning the use of
shell pipelines over the years. Some pertain to the matter of knowing
the exit status of the decompressor, while others pertain to the
consumption of malformed streams that cause tar(1) to close its end of
the pipe while the decompressor is still writing. By shifting the burden
of responsibility to tar(1), this entire class of problem is obviated.

It is worth noting that bzip2-compressed tarballs are handled as a
special case. The reason for this is straightforward: there is the
continued need to support the 'PORTAGE_BUNZIP2_COMMAND' and
'PORTAGE_BZIP2_COMMAND' portage variables. To accommodate these, the -I
option is used to convey a suitable decompression command. For instance,
to specify -I "lbzip2 -c" would imply to tar(1) that it must execute
lbzip2(1) with both the -c and -d options in effect. Though the -I
option-argument is not conveyed to a shell, it is parsed in a manner
that somewhat resembles that of a shell. Therefore, the values of the
aforementioned portage variables shall only be accepted if they consist
entirely of one 

[gentoo-commits] proj/portage:master commit in: bin/

2025-09-10 Thread Sam James
commit: f7c6de5c2e5dfcf6a04a29c6f3d798d29a2e8aa0
Author: Haelwenn (lanodan) Monnier  hacktivis  me>
AuthorDate: Fri Jul 18 20:54:24 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Thu Sep 11 00:53:17 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=f7c6de5c

etc-update: put -- before uid:gid operand of chown

POSIX-conforming getopt(3) stops parsing at first non-option,
so `--` after uid:gid is an argument rather than end-of-options.

Signed-off-by: Haelwenn (lanodan) Monnier  hacktivis.me>
Part-of: https://github.com/gentoo/portage/pull/1449
Closes: https://github.com/gentoo/portage/pull/1449
Signed-off-by: Sam James  gentoo.org>

 bin/etc-update | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/etc-update b/bin/etc-update
index a73076a6cc..fff5d99550 100755
--- a/bin/etc-update
+++ b/bin/etc-update
@@ -822,7 +822,7 @@ SCAN_PATHS=${*:-${CONFIG_PROTECT}}
 TMP=
 trap 'rm -rf -- "${TMP}"' EXIT
 TMP=$(mktemp -d -- "${PORTAGE_TMPDIR}/etc-update.XX") \
-&& chown "${PORTAGE_INST_UID:-0}:${PORTAGE_INST_GID:-0}" -- "${TMP}" \
+&& chown -- "${PORTAGE_INST_UID:-0}:${PORTAGE_INST_GID:-0}" "${TMP}" \
 || exit
 
 trap "die terminated" SIGTERM



[gentoo-commits] proj/portage:master commit in: bin/

2025-08-25 Thread Sam James
commit: 2157e76866dc90a3946b912caa34a511c6b17e60
Author: Kerin Millar  plushkava  net>
AuthorDate: Mon Jul 28 07:30:17 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Mon Aug 25 09:51:34 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=2157e768

Don't strip SHELL while saving and restoring environments

The 'SHELL' variable is set by whatever is responsible for handling the
procedure of logging in, be it login(1), sshd(8) or a display manager.
Its value is taken from the user's password entry and specifies their
choice of login shell. Additionally, bash(1) sets the variable, albeit
only in the (irregular) case that it is missing in its environment at
the time of execution. Ideally, it should not be set by other programs,
nor should any other meaning or purpose be ascribed to it.

Unfortunately, some packages define and export the 'SHELL' variable
during the src_configure phase. Among them are the following:

- app-admin/entr
- dev-lang/spidermonkey
- mail-client/thunderbird
- www-client/firefox
- www-client/seamonkey

While there is a reason for their doing so, it is not immediately clear
as to whether there is an actual need for the variable to persist
between ebuild phases. That is, it may be that the variable only needs
to be present in the environment of the configure program. Still, until
such time as this can be established with absolute certainty, it would
be prudent to avoid the risk of incurring a regression.

For now, refrain from filtering out the 'SHELL' variable in both the
__save_ebuild_env() function of the "save-ebuild-env.sh" unit, and the
__filter_readonly_variables() function of the "phase-functions.sh" unit.

See-also: 8a607ed23beb4995627f9c4e2c7580469ace56bb
See-also: 1df2556c3aeebc64f64c5e6a2f92d9f4a68eb9da
Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/phase-functions.sh | 5 +++--
 bin/save-ebuild-env.sh | 1 -
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh
index 5c9f488a90..98b2784c96 100644
--- a/bin/phase-functions.sh
+++ b/bin/phase-functions.sh
@@ -50,7 +50,7 @@ portage_mutable_filtered_vars=( AA HOSTNAME )
 # Read an environment from stdin and echo to stdout while filtering variables
 # with names that are known to cause interference:
 #
-#   * all variables that can be set by or that affect bash (except EMACS & 
PATH)
+#   * variables that can be set by or that affect bash (with several 
exceptions)
 #   * some specific variables that affect portage or sandbox behavior
 #   * variable names that begin with a digit or that contain any
 # non-alphanumeric characters that are not be supported by bash
@@ -94,10 +94,11 @@ __filter_readonly_variables() {
mapfile -t bash_vars < <(
# Like compgen -A variable but doesn't require readline support.
env -i -- "${BASH}" -c "printf %s\\\n $(printf '${!%s*} ' 
{A..Z} {a..z} _)" \
-   | grep -vx PATH
+   | grep -vx -e PATH -e SHELL
)
# Incorporate other variables that are known to either be set by or be
# able to influence bash. This list was last updated for bash-5.3.
+   # EMACS is omitted, so as not to break the "elisp-common" eclass.
bash_vars+=(
BASH_LOADABLES_PATH BASH_XTRACEFD BASH_REMATCH BASH_TRAPSIG
BASH_COMPAT BASH_ENV COMP_CWORD COMP_POINT COMP_WORDS CHILD_MAX

diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
index 77d3852d48..b520a94858 100644
--- a/bin/save-ebuild-env.sh
+++ b/bin/save-ebuild-env.sh
@@ -56,7 +56,6 @@ __save_ebuild_env() (
POSIXLY_CORRECT
PWD
QUOTING_STYLE
-   SHELL
TABSIZE
TERM
TIME_STYLE



[gentoo-commits] proj/portage:master commit in: bin/

2025-08-25 Thread Sam James
commit: 9b16b9b5e4ce8c8aa2d2f55376daae50b27c8d69
Author: Kerin Millar  plushkava  net>
AuthorDate: Mon Jul 28 10:10:03 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Mon Aug 25 09:51:33 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=9b16b9b5

save-ebuild-env.sh: don't filter out the TZ variable

The 'TZ' environment variable may be set in order to define the
effective timezone. As of a recent commit, it is filtered out by the
__save_ebuild_env() function. However, some packages set and export the
variable during various phases, as shown by the following table.

┌┬───┐
│ Package│ Phase │
├┼───┤
│ dev-build/automake │ src_prepare   │
│ dev-build/automake-vanilla │ src_prepare   │
│ dev-java/jackcess  │ src_test  │
│ dev-libs/glib  │ multilib_src_test │
│ dev-perl/Time-Format   │ src_configure │
│ media-tv/xmltv │ pkg_setup │
│ net-libs/gnutls│ src_prepare   │
│ www-apps/rt│ src_configure │
└┴───┘

In some instances, such as where running a test suite, there won't be a
need for the variable to persist across consecutive ebuild phases. Yet,
in other instances, there might be. For the time being, it would be
prudent to avoid the risk of incurring a regression. Hence, prevent the
__save_ebuild_env() function from filtering out the 'TZ' variable.

See-also: 5b643fb9e8179b77f4e7cb13fc6e871cc4f5eda0
See-also: 1df2556c3aeebc64f64c5e6a2f92d9f4a68eb9da
Link: https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html
Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/save-ebuild-env.sh | 1 -
 1 file changed, 1 deletion(-)

diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
index b48aa3d120..77d3852d48 100644
--- a/bin/save-ebuild-env.sh
+++ b/bin/save-ebuild-env.sh
@@ -61,7 +61,6 @@ __save_ebuild_env() (
TERM
TIME_STYLE
TMPDIR
-   TZ
 
# Miscellaneous variables inherited from the operating 
environment.
DISPLAY



[gentoo-commits] proj/portage:master commit in: bin/

2025-08-25 Thread Sam James
commit: 13d7b83a2ecf1afb07be78c22bee27d794199793
Author: Kerin Millar  plushkava  net>
AuthorDate: Sun Aug 24 22:28:51 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Mon Aug 25 09:51:31 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=13d7b83a

save-ebuild-env.sh: reformat identifier lists, one per line

On the 15th July, the "save-ebuild-env.sh" unit was modified so as to
declare the lists of identifiers that require unsetting as arrays,
obviating the need for escaped  characters as an awkward line
continuation device. Additionally, these lists were reordered with a
custom sorting algorithm, in an attempt to improve their legibility.

Reformat these lists once again, such that there is only ever one
identifier per line. I am now of the view that this is what I ought to
have done in the first place, for the reasons described herewith.

Firstly, humans are quite adept at reading columnated lists that are in
an alphabetical order.

Secondly, having there be only one identifier per line results in
unified diffs that are much easier for humans to fathom in the case that
identifiers are added, renamed and/or removed.

Thirdly, merge conflicts become less likely to occur. Indeed, I found
this change to be immediately beneficial in the course of rebasing my
patch queue.

Fourthly, contributors are duly relieved of the implied burden of
maintaining the layout of the lists, above and beyond their contents.

It should be noted that each group of identifiers has been sorted in a
manner that is equivalent to LC_ALL=C sort.

See-also: fd01f441afa9053cdbbf47252255d19693d299c9
Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/save-ebuild-env.sh | 306 ++---
 1 file changed, 238 insertions(+), 68 deletions(-)

diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
index f2249c041d..c1e6858e64 100644
--- a/bin/save-ebuild-env.sh
+++ b/bin/save-ebuild-env.sh
@@ -19,13 +19,19 @@ __save_ebuild_env() (
 
if has --exclude-init-phases "$@"; then
REPLY+=(
-   PORTAGE_DOCOMPRESS_SIZE_LIMIT PORTAGE_DOCOMPRESS_SKIP
-   PORTAGE_DOSTRIP_SKIP PORTAGE_DOCOMPRESS PORTAGE_DOSTRIP
-   S __E_DOCDESTTREE __E_EXEDESTTREE __E_INSDESTTREE
-   __E_DESTTREE
-
# Discard stale GNU Make POSIX Jobserver flags.
MAKEFLAGS
+
+   PORTAGE_DOCOMPRESS
+   PORTAGE_DOCOMPRESS_SIZE_LIMIT
+   PORTAGE_DOCOMPRESS_SKIP
+   PORTAGE_DOSTRIP
+   PORTAGE_DOSTRIP_SKIP
+   S
+   __E_DESTTREE
+   __E_DOCDESTTREE
+   __E_EXEDESTTREE
+   __E_INSDESTTREE
)
if [[ -n ${PYTHONPATH} &&
${PYTHONPATH%%:*} -ef ${PORTAGE_PYM_PATH} ]] ; then
@@ -38,78 +44,242 @@ __save_ebuild_env() (
fi
 
REPLY+=(
-   # variables that can influence the behaviour of GNU coreutils
-   BLOCK_SIZE COLORTERM COLUMNS DF_BLOCK_SIZE DU_BLOCK_SIZE HOME
-   LS_BLOCK_SIZE LS_COLORS POSIXLY_CORRECT PWD QUOTING_STYLE
-   SHELL TIME_STYLE TABSIZE TMPDIR TERM TZ
-
-   # misc variables inherited from the calling environment
-   DISPLAY EDITOR LESSOPEN LOGNAME LESS PAGER TERMCAP USER
-   ftp_proxy https_proxy http_proxy no_proxy
-
-   # other variables inherited from the calling environment
-   "${!SSH_@}" "${!XDG_CURRENT_@}" "${!XDG_RUNTIME_@}"
-   "${!XDG_SESSION_@}" "${!XDG_CONFIG_@}" "${!XDG_DATA_@}"
-   "${!XDG_MENU_@}" "${!XDG_SEAT_@}" CVS_RSH ECHANGELOG_USER
-   GPG_AGENT_INFO STY WINDOW XAUTHORITY XDG_VTNR
-
-   # portage config variables and variables set directly by portage
-   ACCEPT_LICENSE BUILD_PREFIX COLS DOC_SYMLINKS_DIR DISTDIR
-   EBUILD_FORCE_TEST EBUILD_MASTER_PID ECLASS_DEPTH ENDCOL
-   FAKEROOTKEY HOME LAST_E_CMD LAST_E_LEN LD_PRELOAD
-   MISC_FUNCTIONS_ARGS MOPREFIX NO_COLOR NOCOLOR
+   # Variables that can influence the behaviour of GNU coreutils.
+   BLOCK_SIZE
+   COLORTERM
+   COLUMNS
+   DF_BLOCK_SIZE
+   DU_BLOCK_SIZE
+   HOME
+   LS_BLOCK_SIZE
+   LS_COLORS
+   POSIXLY_CORRECT
+   PWD
+   QUOTING_STYLE
+   SHELL
+   TABSIZE
+   TERM
+   TIME_STYLE
+   TMPDIR
+   TZ
+
+   # Miscellaneous variables inherited from the operating 
environment.
+   DISPLAY
+   EDITOR
+   LESS
+

[gentoo-commits] proj/portage:master commit in: bin/

2025-08-25 Thread Sam James
commit: 060ac9e10d210d7813e48701fa266d204f177c9c
Author: Kerin Millar  plushkava  net>
AuthorDate: Wed Jul 23 03:53:45 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Mon Aug 25 09:51:33 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=060ac9e1

save-ebuild-env.sh: disambiguate variables set following ebuild.sh execution

Presently, the __save_ebuild_env() filters out a number of variable and
variable prefixes that are introduced by a comment describing them as
"portage config variables and variables set directly by portage". Of
these, some are environment variables, as propagated by "doebuild.py" at
the point that it executes the "ebuild.sh" utility, whereas others are
set in bash once said utility is up and running.

Present the variables falling into these two categories as two distinct
groups, making it easier to determine their provenance. This is merely a
cosmetic change (although separating them took some effort).

Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/save-ebuild-env.sh | 52 ++
 1 file changed, 27 insertions(+), 25 deletions(-)

diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
index d35b27baf2..b48aa3d120 100644
--- a/bin/save-ebuild-env.sh
+++ b/bin/save-ebuild-env.sh
@@ -98,44 +98,23 @@ __save_ebuild_env() (
# Portage config variables and variables set directly by 
portage.
ACCEPT_LICENSE
BUILD_PREFIX
-   COLS
DISTDIR
DOC_SYMLINKS_DIR
EBUILD_FORCE_TEST
-   EBUILD_MASTER_PID
-   ECLASS_DEPTH
-   ENDCOL
FAKEROOTKEY
-   HOME
-   LAST_E_CMD
-   LAST_E_LEN
LD_PRELOAD
-   MISC_FUNCTIONS_ARGS
-   MOPREFIX
NOCOLOR
NO_COLOR
PKGDIR
PKGUSE
PKG_LOGDIR
PKG_TMPDIR
-   PORTAGE_BASHRCS_SOURCED
PORTAGE_BASHRC_FILES
-   PORTAGE_COLOR_BAD
-   PORTAGE_COLOR_BRACKET
-   PORTAGE_COLOR_ERR
-   PORTAGE_COLOR_GOOD
-   PORTAGE_COLOR_HILITE
-   PORTAGE_COLOR_INFO
-   PORTAGE_COLOR_LOG
-   PORTAGE_COLOR_NORMAL
-   PORTAGE_COLOR_QAWARN
-   PORTAGE_COLOR_WARN
PORTAGE_COMPRESS
PORTAGE_COMPRESS_EXCLUDE_SUFFIXES
PORTAGE_DOHTML_UNWARNED_SKIPPED_EXTENSIONS
PORTAGE_DOHTML_UNWARNED_SKIPPED_FILES
PORTAGE_DOHTML_WARN_ON_SKIPPED_FILES
-   PORTAGE_NONFATAL
PORTAGE_QUIET
PORTAGE_SANDBOX_DENY
PORTAGE_SANDBOX_PREDICT
@@ -143,17 +122,40 @@ __save_ebuild_env() (
PORTAGE_SANDBOX_WRITE
PORTAGE_SOCKS5_PROXY
PREROOTPATH
+   ROOT
+   ROOTPATH
+   RPMDIR
+   USE_EXPAND
+
+   # Variables set directly in bash following ebuild.sh execution.
+   COLS
+   EBUILD_MASTER_PID
+   ECLASS_DEPTH
+   ENDCOL
+   HOME
+   LAST_E_CMD
+   LAST_E_LEN
+   MISC_FUNCTIONS_ARGS
+   MOPREFIX
+   PORTAGE_BASHRCS_SOURCED
+   PORTAGE_COLOR_BAD
+   PORTAGE_COLOR_BRACKET
+   PORTAGE_COLOR_ERR
+   PORTAGE_COLOR_GOOD
+   PORTAGE_COLOR_HILITE
+   PORTAGE_COLOR_INFO
+   PORTAGE_COLOR_LOG
+   PORTAGE_COLOR_NORMAL
+   PORTAGE_COLOR_QAWARN
+   PORTAGE_COLOR_WARN
+   PORTAGE_NONFATAL
QA_INTERCEPTORS
RC_DOT_PATTERN
RC_ENDCOL
RC_INDENTATION
-   ROOT
-   ROOTPATH
-   RPMDIR
TEMP
TMP
TMPDIR
-   USE_EXPAND
XARGS
_RC_GET_KV_CACHE
 



[gentoo-commits] proj/portage:master commit in: bin/

2025-08-25 Thread Sam James
commit: 508e5cc483674fa810c923de17130c8f7f238273
Author: Kerin Millar  plushkava  net>
AuthorDate: Sat Jul 26 15:24:02 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Mon Aug 25 09:51:32 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=508e5cc4

save-ebuild-env.sh: filter out the SHELL_SETS_TITLE variable

The 'SHELL_SETS_TITLE' variable is potentially set for interactive
instances of bash by "/etc/bash/bashrc.d/10-gentoo-title.bash". Ensure
that it is filtered out by the __save_ebuild_env() function.

Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/save-ebuild-env.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
index f195729232..d35b27baf2 100644
--- a/bin/save-ebuild-env.sh
+++ b/bin/save-ebuild-env.sh
@@ -89,6 +89,7 @@ __save_ebuild_env() (
CVS_RSH
ECHANGELOG_USER
GPG_AGENT_INFO
+   SHELL_SETS_TITLE
STY
WINDOW
XAUTHORITY



[gentoo-commits] proj/portage:master commit in: bin/

2025-08-25 Thread Sam James
commit: caf3e5dcb3960e2eb80a90ee5b91ddafb0220914
Author: Kerin Millar  plushkava  net>
AuthorDate: Sun Aug 24 23:11:29 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Mon Aug 25 09:51:32 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=caf3e5dc

save-ebuild-env.sh: use MAPFILE to hold identifiers instead of REPLY

Presently, the __save_ebuild_env() function purposes the 'REPLY'
variable as an array for temporarily holding lists of identifiers that
are to be unset. The 'REPLY' variable was chosen on the basis that it
its value is normally controlled by the read builtin. That is, by using
it, the probability of a namespace conflict is reduced.

However, 'REPLY' is not normally an array variable. While this
observation is of no significance in and as of itself, some might find
it strange to see that particular variable be used as an array. In view
of this, purpose 'MAPFILE' as an array instead. For those that don't
know, that is the variable populated by the mapfile/readarray builtin,
provided that no name is specified.

See-also: fd01f441afa9053cdbbf47252255d19693d299c9
Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/save-ebuild-env.sh | 44 ++--
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
index c1e6858e64..f195729232 100644
--- a/bin/save-ebuild-env.sh
+++ b/bin/save-ebuild-env.sh
@@ -11,14 +11,14 @@
 # or removal of the packages, and can therefore be safely excluded.
 #
 __save_ebuild_env() (
-   # REPLY is purposed as an array that undergoes two phases of assembly.
+   # MAPFILE is purposed as an array that undergoes two phases of assembly.
# The first entails gathering the names of variables that are to be
# unset. The second entails gathering the names of functions that are
-   # to be unset. The REPLY variable is eventually unset in its own right.
-   REPLY=()
+   # to be unset.
+   MAPFILE=()
 
if has --exclude-init-phases "$@"; then
-   REPLY+=(
+   MAPFILE+=(
# Discard stale GNU Make POSIX Jobserver flags.
MAKEFLAGS
 
@@ -38,12 +38,12 @@ __save_ebuild_env() (
if [[ ${PYTHONPATH} == *:* ]] ; then
export PYTHONPATH=${PYTHONPATH#*:}
else
-   REPLY+=( PYTHONPATH )
+   MAPFILE+=( PYTHONPATH )
fi
fi
fi
 
-   REPLY+=(
+   MAPFILE+=(
# Variables that can influence the behaviour of GNU coreutils.
BLOCK_SIZE
COLORTERM
@@ -167,9 +167,9 @@ __save_ebuild_env() (
)
 
# Unset the collected variables before moving on to functions.
-   unset -v "${REPLY[@]}"
+   unset -v "${MAPFILE[@]}"
 
-   REPLY=(
+   MAPFILE=(
EXPORT_FUNCTIONS
KV_major
KV_micro
@@ -285,26 +285,26 @@ __save_ebuild_env() (
${QA_INTERCEPTORS}
)
 
-   for _ in \
+   for REPLY in \

pkg_{config,info,nofetch,postinst,preinst,pretend,postrm,prerm,setup} \
src_{configure,compile,install,prepare,test,unpack}
do
-   REPLY+=( default_"${_}" __eapi{0,1,2,4,6,8}_"${_}" )
+   MAPFILE+=( default_"${REPLY}" __eapi{0,1,2,4,6,8}_"${REPLY}" )
done
 
-   ___eapi_has_version_functions && REPLY+=( ver_test ver_cut ver_rs )
-   ___eapi_has_einstalldocs && REPLY+=( einstalldocs )
-   ___eapi_has_eapply_user && REPLY+=( __readdir eapply_user )
-   ___eapi_has_get_libdir && REPLY+=( get_libdir )
-   ___eapi_has_in_iuse && REPLY+=( in_iuse )
-   ___eapi_has_eapply && REPLY+=( __eapply_patch eapply patch )
-   ___eapi_has_usex && REPLY+=( usex )
-   ___eapi_has_pipestatus && REPLY+=( pipestatus )
-   ___eapi_has_ver_replacing && REPLY+=( ver_replacing )
-   ___eapi_has_edo && REPLY+=( edo )
+   ___eapi_has_version_functions && MAPFILE+=( ver_test ver_cut ver_rs )
+   ___eapi_has_einstalldocs && MAPFILE+=( einstalldocs )
+   ___eapi_has_eapply_user && MAPFILE+=( __readdir eapply_user )
+   ___eapi_has_get_libdir && MAPFILE+=( get_libdir )
+   ___eapi_has_in_iuse && MAPFILE+=( in_iuse )
+   ___eapi_has_eapply && MAPFILE+=( __eapply_patch eapply patch )
+   ___eapi_has_usex && MAPFILE+=( usex )
+   ___eapi_has_pipestatus && MAPFILE+=( pipestatus )
+   ___eapi_has_ver_replacing && MAPFILE+=( ver_replacing )
+   ___eapi_has_edo && MAPFILE+=( edo )
 
# Destroy the collected functions.
-   unset -f "${REPLY[@]}"
+   unset -f "${MAPFILE[@]}"
 
# Clear out the triple underscore namespace as it is reserved by the PM.
while IFS=' ' read -r _ _ REPLY

[gentoo-commits] proj/portage:master commit in: bin/

2025-08-25 Thread Sam James
commit: 5f37c8f1fa5261c6ac81ef89bd1276ac0e77f5c6
Author: Kerin Millar  plushkava  net>
AuthorDate: Fri Jul 25 14:22:09 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Mon Aug 25 09:51:31 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=5f37c8f1

ebuild.sh: require bash-4.4 and improve __check_bash_version()

As of the time of writing, portage makes use of features that were
introduced by bash-4.4 and, therefore, cannot run correctly with any
older version. However, the __check_bash_version() function does not
currently enforce this requirement.

Address this issue by specifying the minimum required version
independently of the shell compatibility level. The minimum required
version is initially defined as 4.4 but is raised to 5.0 in the event
that the currently effective EAPI requires it (as EAPI 8 does). As is
depicted beneath, the diagnostic messages make this distinction clear.

 * ERROR: sys-apps/portage-::gentoo failed (pretend phase):
 *   Portage requires >=bash-4.4 but only 4.3 was found

 * ERROR: sys-apps/portage-::gentoo failed (pretend phase):
 *   EAPI 8 requires >=bash-5.0 but only 4.4 was found

Further, apply some minor improvements to the function at large. These
improvements are described herewith.

Remove the comment preceding the function declaration, for it does not
describe its behaviour accurately and is of questionable value.

Clean up the version test by employing an explicit arithmetic context.

Refrain from using the shopt builtin to set the compatibility level.
There is no longer any need to set the compatibility level other than by
assigning to the 'BASH_COMPAT' variable.

Rewrite the remaining commentary so as to employ a more formal tone and
be more informative, without being unduly verbose. Incorporate links to
supporting documentation and associated bug reports, where appropriate.

Attempt to disable the 'patsub_replacement' and 'globskipdots' shell
options on an unconditional basis while simply muting STDERR for the
benefit of bash releases prior to 5.2. As the preceding comment states,
it may become necessary to disable these options on a conditional basis
for a future EAPI. For now, no such logic is required.

See-also: 59b81ecda599e9fbf4084e4595f1fa96c32a9fc1
Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/ebuild.sh | 95 +++
 1 file changed, 50 insertions(+), 45 deletions(-)

diff --git a/bin/ebuild.sh b/bin/ebuild.sh
index 593c18ef5a..12adee68b4 100755
--- a/bin/ebuild.sh
+++ b/bin/ebuild.sh
@@ -12,60 +12,65 @@ declare -F ___in_portage_iuse >/dev/null && export -n -f 
___in_portage_iuse
 
 source "${PORTAGE_BIN_PATH:?}/isolated-functions.sh" || exit
 
-# Set up the bash version compatibility level.  This does not disable
-# features when running with a newer version, but makes it so that when
-# bash changes behavior in an incompatible way, the older behavior is
-# used instead.
 __check_bash_version() {
-   # Figure out which min version of bash we require.
-   # Adjust patsub_replacement/globskipdots logic below on new EAPI!
-   local maj min
-   if ___eapi_bash_3_2 ; then
-   maj=3 min=2
-   elif ___eapi_bash_4_2 ; then
-   maj=4 min=2
-   elif ___eapi_bash_5_0 ; then
-   maj=5 min=0
-   elif ___eapi_bash_5_2 ; then
-   maj=5 min=2
-   else
-   return
-   fi
+   local IFS compat_maj compat_min dependent maj min
+
+   # Portage uses features that are only available in >=bash-4.4.
+   dependent="Portage"
+   maj=4
+   min=4
 
-   # Make sure the active bash is sane.
-   if [[ ${BASH_VERSINFO[0]} -lt ${maj} ]] ||
-  [[ ${BASH_VERSINFO[0]} -eq ${maj} && ${BASH_VERSINFO[1]} -lt ${min} 
]] ; then
-   die "EAPI=\"${EAPI}\" requires >=bash-${maj}.${min}, but 
bash-${BASH_VERSION} found"
+   # Based on the value of EAPI, determine which shell compatibility level
+   # to activate. Further, raise the minimum required version if needs be.
+   #
+   # https://projects.gentoo.org/pms/8/pms.html#x1-580006
+   if ___eapi_bash_3_2; then
+   compat_maj=3
+   compat_min=2
+   elif ___eapi_bash_4_2; then
+   compat_maj=4
+   compat_min=2
+   elif ___eapi_bash_5_0; then
+   dependent="EAPI ${EAPI}"
+   (( compat_maj = maj = 5 ))
+   (( compat_min = min = 0 ))
+   elif ___eapi_bash_5_2; then
+   dependent="EAPI ${EAPI}"
+   (( compat_maj = maj = 5 ))
+   (( compat_min = min = 2 ))
fi
 
-   # Set the compat level in case things change with newer ones.  We must 
not
-   # export this into the env otherwise we might break  other shell 
scripts we
-   # execute (e.g. ones in /usr/bin).
-   BASH_COMPAT="${maj}.${min}"
-
-   #

[gentoo-commits] proj/portage:master commit in: bin/

2025-08-17 Thread Ulrich Müller
commit: f8cbb84a4f47ea5d61788025b88206b35a21b015
Author: Ulrich Müller  gentoo  org>
AuthorDate: Mon Jun  9 08:18:40 2025 +
Commit: Ulrich Müller  gentoo  org>
CommitDate: Sun Aug 17 19:00:38 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=f8cbb84a

EAPI 9 has edo

Signed-off-by: Ulrich Müller  gentoo.org>

 bin/eapi.sh|  1 +
 bin/phase-helpers.sh   | 20 
 bin/save-ebuild-env.sh |  1 +
 3 files changed, 22 insertions(+)

diff --git a/bin/eapi.sh b/bin/eapi.sh
index 97eb19d036..7babdf62e0 100644
--- a/bin/eapi.sh
+++ b/bin/eapi.sh
@@ -35,6 +35,7 @@ ___eapi_has_dosed()  [[ ${1-${EAPI-0}} == [0-3] ]]
 ___eapi_has_dostrip()[[ ${1-${EAPI-0}} != [0-6] ]]
 ___eapi_has_eapply() [[ ${1-${EAPI-0}} != [0-5] ]]
 ___eapi_has_eapply_user()[[ ${1-${EAPI-0}} != [0-5] ]]
+___eapi_has_edo()[[ ${1-${EAPI-0}} != [0-8] ]]
 ___eapi_has_einstall()   [[ ${1-${EAPI-0}} == [0-5] ]]
 ___eapi_has_einstalldocs()   [[ ${1-${EAPI-0}} != [0-5] ]]
 ___eapi_has_get_libdir() [[ ${1-${EAPI-0}} != [0-5] ]]

diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index e97ebc7169..68009fcc0e 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -1179,3 +1179,23 @@ if ___eapi_has_pipestatus; then
return "${ret}"
}
 fi
+
+if ___eapi_has_edo; then
+   edo() {
+   # list of special characters taken from sh_contains_shell_metas
+   # in shquote.c (bash-5.2)
+   local a out regex='[] '\''"\|&;()<>!{}*[?^$`]|^[#~]|[=:]~'
+
+   [[ $# -ge 1 ]] || die "edo: at least one argument needed"
+
+   for a; do
+   # quote if (and only if) necessary
+   [[ ${a} =~ ${regex} || ! ${a} =~ ^[[:print:]]+$ ]] && 
a=${a@Q}
+   out+=" ${a}"
+   done
+
+   einfon
+   printf '%s\n' "${out:1}" >&2
+   "$@" || __helpers_die "edo: failed to run command: ${1}"
+   }
+fi

diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
index 1cddf6370a..f2249c041d 100644
--- a/bin/save-ebuild-env.sh
+++ b/bin/save-ebuild-env.sh
@@ -131,6 +131,7 @@ __save_ebuild_env() (
___eapi_has_usex && REPLY+=( usex )
___eapi_has_pipestatus && REPLY+=( pipestatus )
___eapi_has_ver_replacing && REPLY+=( ver_replacing )
+   ___eapi_has_edo && REPLY+=( edo )
 
# Destroy the collected functions.
unset -f "${REPLY[@]}"



[gentoo-commits] proj/portage:master commit in: bin/

2025-08-17 Thread Ulrich Müller
commit: 5d7567783a27dd52fa8dff1096f4d9a6b077b191
Author: Ulrich Müller  gentoo  org>
AuthorDate: Mon Jun  9 08:18:04 2025 +
Commit: Ulrich Müller  gentoo  org>
CommitDate: Sun Aug 17 19:00:37 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=5d756778

EAPI 9 has ver_replacing

Signed-off-by: Ulrich Müller  gentoo.org>

 bin/eapi.sh  |  1 +
 bin/save-ebuild-env.sh   |  1 +
 bin/version-functions.sh | 21 -
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/bin/eapi.sh b/bin/eapi.sh
index 8e51a8ac54..97eb19d036 100644
--- a/bin/eapi.sh
+++ b/bin/eapi.sh
@@ -45,6 +45,7 @@ ___eapi_has_nonfatal()   [[ ${1-${EAPI-0}} != [0-3] ]]
 ___eapi_has_pipestatus() [[ ${1-${EAPI-0}} != [0-8] ]]
 ___eapi_has_useq()   [[ ${1-${EAPI-0}} == [0-7] ]]
 ___eapi_has_usex()   [[ ${1-${EAPI-0}} != [0-4] ]]
+___eapi_has_ver_replacing()  [[ ${1-${EAPI-0}} != [0-8] ]]
 ___eapi_has_version_functions()  [[ ${1-${EAPI-0}} != [0-6] ]]
 
 # HELPERS BEHAVIOR

diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
index 01bdcdd994..1cddf6370a 100644
--- a/bin/save-ebuild-env.sh
+++ b/bin/save-ebuild-env.sh
@@ -130,6 +130,7 @@ __save_ebuild_env() (
___eapi_has_eapply && REPLY+=( __eapply_patch eapply patch )
___eapi_has_usex && REPLY+=( usex )
___eapi_has_pipestatus && REPLY+=( pipestatus )
+   ___eapi_has_ver_replacing && REPLY+=( ver_replacing )
 
# Destroy the collected functions.
unset -f "${REPLY[@]}"

diff --git a/bin/version-functions.sh b/bin/version-functions.sh
index f07b03192c..11f0ffe0e5 100644
--- a/bin/version-functions.sh
+++ b/bin/version-functions.sh
@@ -1,5 +1,5 @@
 #!/usr/bin/env bash
-# Copyright 1999-2018 Gentoo Foundation
+# Copyright 1999-2025 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 # shellcheck disable=SC2128
 
@@ -190,3 +190,22 @@ ver_test() {
__ver_compare "${va}" "${vb}"
test $? "${op}" 2
 }
+
+if ___eapi_has_ver_replacing; then
+   ver_replacing() {
+   case ${EBUILD_PHASE} in
+   pretend|setup|preinst|postinst) ;;
+   *)
+   die "ver_replacing is meaningless in the 
${EBUILD_PHASE} phase"
+   ;;
+   esac
+
+   [[ $# -eq 2 ]] || die "Usage: ver_replacing  "
+
+   local v
+   for v in ${REPLACING_VERSIONS}; do
+   ver_test "${v}" "$@" && return 0
+   done
+   return 1
+   }
+fi



[gentoo-commits] proj/portage:master commit in: bin/

2025-08-17 Thread Ulrich Müller
commit: afaf72e840d910c17e23335c8069c5bd40faf4f7
Author: Ulrich Müller  gentoo  org>
AuthorDate: Mon Jun  9 08:01:24 2025 +
Commit: Ulrich Müller  gentoo  org>
CommitDate: Sun Aug 17 19:00:35 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=afaf72e8

EAPI 9 bans assert

When rebasing, I had to partially revert commit 6f9971e54d, because
the value of PIPESTATUS must be saved before the feature test call

Signed-off-by: Ulrich Müller  gentoo.org>

 bin/eapi.sh   | 1 +
 bin/isolated-functions.sh | 8 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/bin/eapi.sh b/bin/eapi.sh
index 8618815b8d..892742c5d1 100644
--- a/bin/eapi.sh
+++ b/bin/eapi.sh
@@ -24,6 +24,7 @@ ___eapi_has_prefix_variables() [[ ${1-${EAPI-0}} != 
[0-2] ]]
 
 # HELPERS PRESENCE
 
+___eapi_has_assert() [[ ${1-${EAPI-0}} == [0-8] ]]
 ___eapi_has_docompress() [[ ${1-${EAPI-0}} != [0-3] ]]
 ___eapi_has_dohard() [[ ${1-${EAPI-0}} == [0-3] ]]
 ___eapi_has_doheader()   [[ ${1-${EAPI-0}} != [0-4] ]]

diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index a1c431694e..0fd9c8bd99 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -1,5 +1,5 @@
 #!/usr/bin/env bash
-# Copyright 1999-2024 Gentoo Authors
+# Copyright 1999-2025 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 # shellcheck disable=2128,2185,2219
 
@@ -23,7 +23,11 @@ fi
 shopt -s expand_aliases
 
 assert() {
-   IFS='|' expression=${PIPESTATUS[*]} let '! expression' || die "$@"
+   local x pipestatus=( "${PIPESTATUS[@]}" )
+   ___eapi_has_assert || die "'${FUNCNAME}' banned in EAPI ${EAPI}"
+   for x in "${pipestatus[@]}"; do
+   [[ ${x} -eq 0 ]] || die "$@"
+   done
 }
 
 shopt -s extdebug



[gentoo-commits] proj/portage:master commit in: bin/

2025-08-17 Thread Ulrich Müller
commit: 4917a7da16ac5450451f54d4685be1d8b403f9ad
Author: Ulrich Müller  gentoo  org>
AuthorDate: Mon Jun  9 08:04:21 2025 +
Commit: Ulrich Müller  gentoo  org>
CommitDate: Sun Aug 17 19:00:36 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=4917a7da

EAPI 9 has pipestatus

Signed-off-by: Ulrich Müller  gentoo.org>

 bin/eapi.sh|  1 +
 bin/phase-helpers.sh   | 17 +
 bin/save-ebuild-env.sh |  3 ++-
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/bin/eapi.sh b/bin/eapi.sh
index 272d9e4a74..8e51a8ac54 100644
--- a/bin/eapi.sh
+++ b/bin/eapi.sh
@@ -42,6 +42,7 @@ ___eapi_has_hasq()   [[ ${1-${EAPI-0}} == [0-7] ]]
 ___eapi_has_hasv()   [[ ${1-${EAPI-0}} == [0-7] ]]
 ___eapi_has_in_iuse()[[ ${1-${EAPI-0}} != [0-5] ]]
 ___eapi_has_nonfatal()   [[ ${1-${EAPI-0}} != [0-3] ]]
+___eapi_has_pipestatus() [[ ${1-${EAPI-0}} != [0-8] ]]
 ___eapi_has_useq()   [[ ${1-${EAPI-0}} == [0-7] ]]
 ___eapi_has_usex()   [[ ${1-${EAPI-0}} != [0-4] ]]
 ___eapi_has_version_functions()  [[ ${1-${EAPI-0}} != [0-6] ]]

diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index 89f1f6f2f8..e97ebc7169 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -1162,3 +1162,20 @@ if ___eapi_has_in_iuse; then
contains_word "$1" "${IUSE_EFFECTIVE}"
}
 fi
+
+if ___eapi_has_pipestatus; then
+   pipestatus() {
+   local status=( "${PIPESTATUS[@]}" )
+   local s ret=0 verbose=""
+
+   [[ ${1} == -v ]] && { verbose=1; shift; }
+   [[ $# -ne 0 ]] && die "usage: pipestatus [-v]"
+
+   for s in "${status[@]}"; do
+   [[ ${s} -ne 0 ]] && ret=${s}
+   done
+
+   [[ ${verbose} ]] && echo "${status[@]}"
+   return "${ret}"
+   }
+fi

diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
index 32837e8950..242b58b70f 100644
--- a/bin/save-ebuild-env.sh
+++ b/bin/save-ebuild-env.sh
@@ -1,5 +1,5 @@
 #!/usr/bin/env bash
-# Copyright 1999-2024 Gentoo Authors
+# Copyright 1999-2025 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 # @FUNCTION: __save_ebuild_env
@@ -130,6 +130,7 @@ __save_ebuild_env() (
___eapi_has_in_iuse && REPLY+=( in_iuse )
___eapi_has_eapply && REPLY+=( __eapply_patch eapply patch )
___eapi_has_usex && REPLY+=( usex )
+   ___eapi_has_pipestatus && REPLY+=( pipestatus )
 
# Destroy the collected functions.
unset -f "${REPLY[@]}"



[gentoo-commits] proj/portage:master commit in: bin/, bin/install-qa-check.d/, lib/portage/tests/bin/

2025-08-17 Thread Ulrich Müller
commit: d98555dd2f50fee9140f210a1f8eebd09c0b300e
Author: Ulrich Müller  gentoo  org>
AuthorDate: Mon Jun  9 08:13:13 2025 +
Commit: Ulrich Müller  gentoo  org>
CommitDate: Sun Aug 17 19:00:37 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=d98555dd

version-functions.sh: Renamed from eapi7-ver-funcs.sh

Signed-off-by: Ulrich Müller  gentoo.org>

 bin/install-qa-check.d/60pkgconfig |  2 +-
 bin/isolated-functions.sh  |  2 +-
 bin/save-ebuild-env.sh | 17 +++---
 bin/{eapi7-ver-funcs.sh => version-functions.sh}   | 26 +++---
 lib/portage/tests/bin/meson.build  |  2 +-
 .../{test_eapi7_ver_funcs.py => test_ver_funcs.py} |  8 +++
 6 files changed, 28 insertions(+), 29 deletions(-)

diff --git a/bin/install-qa-check.d/60pkgconfig 
b/bin/install-qa-check.d/60pkgconfig
index 10484dce92..27df0fb877 100644
--- a/bin/install-qa-check.d/60pkgconfig
+++ b/bin/install-qa-check.d/60pkgconfig
@@ -4,7 +4,7 @@
 
 # Ensure that ver_test is available.
 if ! ___eapi_has_version_functions; then
-   source "${PORTAGE_BIN_PATH:?}/eapi7-ver-funcs.sh" || exit
+   source "${PORTAGE_BIN_PATH:?}/version-functions.sh" || exit
 fi
 
 pkgconfig_check() {

diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index 0fd9c8bd99..fdca233323 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -6,7 +6,7 @@
 source "${PORTAGE_BIN_PATH:?}/eapi.sh" || exit
 
 if ___eapi_has_version_functions; then
-   source "${PORTAGE_BIN_PATH}/eapi7-ver-funcs.sh" || exit 1
+   source "${PORTAGE_BIN_PATH}/version-functions.sh" || exit 1
 fi
 
 if [[ -v PORTAGE_EBUILD_EXTRA_SOURCE ]]; then

diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
index 242b58b70f..01bdcdd994 100644
--- a/bin/save-ebuild-env.sh
+++ b/bin/save-ebuild-env.sh
@@ -91,17 +91,16 @@ __save_ebuild_env() (
__check_bash_version __compose_bzip2_cmd __dyn_configure
__dyn_compile __dyn_install __dyn_prepare __dyn_pretend
__dump_trace __dyn_unpack __dyn_clean __dyn_setup __dyn_help
-   __dyn_test __ebuild_phase_with_hooks __eapi7_ver_compare_int
-   __eapi7_ver_parse_range __ebuild_arg_to_phase
-   __ebuild_phase_funcs __eapi7_ver_compare __eapi7_ver_split
-   __ebuild_phase __ebuild_main __elog_base __eqaquote __eqatag
-   __eend __filter_readonly_variables __has_phase_defined_up_to
-   __helpers_die __hasgq __hasg __preprocess_ebuild_env
-   __quiet_mode __qa_source __qa_call __repo_attr
-   __strip_duplicate_slashes __source_all_bashrcs
+   __dyn_test __ebuild_phase_with_hooks __ebuild_arg_to_phase
+   __ebuild_phase_funcs __ebuild_phase __ebuild_main __elog_base
+   __eqaquote __eqatag __eend __filter_readonly_variables
+   __has_phase_defined_up_to __helpers_die __hasgq __hasg
+   __preprocess_ebuild_env __quiet_mode __qa_source __qa_call
+   __repo_attr __strip_duplicate_slashes __source_all_bashrcs
__source_env_files __save_ebuild_env __sb_append_var
__start_distcc __set_colors __try_source __unset_colors
-   __unpack_tar __vecho
+   __unpack_tar __vecho __ver_compare __ver_compare_int
+   __ver_parse_range __ver_split
 
addpredict addwrite adddeny addread assert best_version
contains_word configparser debug-print-function

diff --git a/bin/eapi7-ver-funcs.sh b/bin/version-functions.sh
similarity index 88%
rename from bin/eapi7-ver-funcs.sh
rename to bin/version-functions.sh
index 45a8285b70..f07b03192c 100644
--- a/bin/eapi7-ver-funcs.sh
+++ b/bin/version-functions.sh
@@ -3,7 +3,7 @@
 # Distributed under the terms of the GNU General Public License v2
 # shellcheck disable=SC2128
 
-__eapi7_ver_parse_range() {
+__ver_parse_range() {
local range=${1}
local max=${2}
 
@@ -20,7 +20,7 @@ __eapi7_ver_parse_range() {
fi
 }
 
-__eapi7_ver_split() {
+__ver_split() {
local v=${1} LC_ALL=C
 
comp=()
@@ -45,9 +45,9 @@ ver_cut() {
local start end
local -a comp
 
-   __eapi7_ver_split "${v}"
+   __ver_split "${v}"
local max=$((${#comp[@]}/2))
-   __eapi7_ver_parse_range "${range}" "${max}"
+   __ver_parse_range "${range}" "${max}"
 
local IFS=
if [[ ${start} -gt 0 ]]; then
@@ -62,11 +62,11 @@ ver_rs() {
local start end i
local -a comp
 
-   __eapi7_ver_split "${v}"
+   __ver_split "${v}"
local max=$((${#comp[@]}/2 - 1))
 
while [[ ${#} -ge 2 ]]; do
-   __eapi7_ver_parse_range "${1}" "${max}"
+   __ver_parse_range "${1}" "${max}"
for (( i = start*2; i <= end*2; i+=2 )); do
[[ ${i} -eq 0 

[gentoo-commits] proj/portage:master commit in: bin/

2025-08-17 Thread Ulrich Müller
commit: 1ca082e48f5e80acf0962f6c5759f62e99fef4a5
Author: Ulrich Müller  gentoo  org>
AuthorDate: Mon Jun  9 07:59:46 2025 +
Commit: Ulrich Müller  gentoo  org>
CommitDate: Sun Aug 17 19:00:35 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=1ca082e4

EAPI 9: Bash version is 5.2

Signed-off-by: Ulrich Müller  gentoo.org>

 bin/eapi.sh   | 3 ++-
 bin/ebuild.sh | 4 +++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/bin/eapi.sh b/bin/eapi.sh
index 6a7927f8b4..8618815b8d 100644
--- a/bin/eapi.sh
+++ b/bin/eapi.sh
@@ -80,7 +80,8 @@ ___eapi_usev_has_second_arg() 
  [[ ${1-${EAPI-0}
 
 ___eapi_bash_3_2()  [[ ${1-${EAPI-0}} == [0-5] ]]
 ___eapi_bash_4_2()  [[ ${1-${EAPI-0}} == [67]  ]]
-___eapi_bash_5_0()  [[ ${1-${EAPI-0}} != [0-7] ]]
+___eapi_bash_5_0()  [[ ${1-${EAPI-0}} == 8 ]]
+___eapi_bash_5_2()  [[ ${1-${EAPI-0}} != [0-8] ]]
 ___eapi_enables_failglob_in_global_scope()  [[ ${1-${EAPI-0}} != [0-5] ]]
 ___eapi_has_ENV_UNSET() [[ ${1-${EAPI-0}} != [0-6] ]]
 ___eapi_has_strict_keepdir()[[ ${1-${EAPI-0}} != [0-7] ]]

diff --git a/bin/ebuild.sh b/bin/ebuild.sh
index 6a12d65a7c..593c18ef5a 100755
--- a/bin/ebuild.sh
+++ b/bin/ebuild.sh
@@ -1,5 +1,5 @@
 #!/usr/bin/env bash
-# Copyright 1999-2024 Gentoo Authors
+# Copyright 1999-2025 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 # Prevent aliases from causing portage to act inappropriately.
@@ -26,6 +26,8 @@ __check_bash_version() {
maj=4 min=2
elif ___eapi_bash_5_0 ; then
maj=5 min=0
+   elif ___eapi_bash_5_2 ; then
+   maj=5 min=2
else
return
fi



[gentoo-commits] proj/portage:master commit in: bin/, bin/ebuild-helpers/

2025-08-17 Thread Ulrich Müller
commit: c74fc9aee7ab5777cf3fd2f2c3ed744dc79c0be8
Author: Ulrich Müller  gentoo  org>
AuthorDate: Mon Jun  9 08:02:11 2025 +
Commit: Ulrich Müller  gentoo  org>
CommitDate: Sun Aug 17 19:00:36 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=c74fc9ae

EAPI 9 bans domo

Signed-off-by: Ulrich Müller  gentoo.org>

 bin/eapi.sh | 1 +
 bin/ebuild-helpers/domo | 7 ++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/bin/eapi.sh b/bin/eapi.sh
index 892742c5d1..272d9e4a74 100644
--- a/bin/eapi.sh
+++ b/bin/eapi.sh
@@ -30,6 +30,7 @@ ___eapi_has_dohard() [[ ${1-${EAPI-0}} == [0-3] ]]
 ___eapi_has_doheader()   [[ ${1-${EAPI-0}} != [0-4] ]]
 ___eapi_has_dohtml() [[ ${1-${EAPI-0}} == [0-6] ]]
 ___eapi_has_dolib_libopts()  [[ ${1-${EAPI-0}} == [0-6] ]]
+___eapi_has_domo()   [[ ${1-${EAPI-0}} == [0-8] ]]
 ___eapi_has_dosed()  [[ ${1-${EAPI-0}} == [0-3] ]]
 ___eapi_has_dostrip()[[ ${1-${EAPI-0}} != [0-6] ]]
 ___eapi_has_eapply() [[ ${1-${EAPI-0}} != [0-5] ]]

diff --git a/bin/ebuild-helpers/domo b/bin/ebuild-helpers/domo
index e261da955e..c95fc38009 100755
--- a/bin/ebuild-helpers/domo
+++ b/bin/ebuild-helpers/domo
@@ -1,9 +1,14 @@
 #!/usr/bin/env bash
-# Copyright 1999-2023 Gentoo Authors
+# Copyright 1999-2025 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 source "${PORTAGE_BIN_PATH:?}"/isolated-functions.sh || exit
 
+if ! ___eapi_has_domo; then
+   die "'${0##*/}' has been banned for EAPI '${EAPI}'"
+   exit 1
+fi
+
 mynum=${#}
 if [ ${mynum} -lt 1 ] ; then
__helpers_die "${0}: at least one argument needed"



[gentoo-commits] proj/portage:master commit in: bin/

2025-08-02 Thread Sam James
commit: 3868d097a576275641d55c9fb32bfe4976385e02
Author: Kerin Millar  plushkava  net>
AuthorDate: Thu Jul 24 21:22:08 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Sat Aug  2 16:31:28 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=3868d097

isolated-functions.sh: add and integrate the configparser() function

Presently, the __repo_attr() function acts as a crude parser for the
value of the 'PORTAGE_REPOSITORIES' environment variable, which contains
the contents of files beneath the "/etc/portage/repos.conf" directory.
Its implementation is substandard, to say the least. Firstly, it suffers
from several amateurish bugs. Secondly, it is unable to detect errors in
syntax. Thirdly, it is an incomplete, incorrect implementation of a
parser for the file format that it is supposed to handle.

This commit incorporates a new function by the name of configparser().
It consumes the standard input and - as its name suggests - attempts to
parse it as the "configparser" configuration file format that is native
to python. It has been tested against the sample file provided by the
python documentation and fully supports multiline values and key/value
pairs that are separated by the  character. Each key/value entry
that is encountered shall be printed in the following format:

  "%s\0%s\0%s\0", , , 

It is capable of detecting syntax errors. Upon encountering any such
error, a diagnostic message shall be printed to standard error and the
function shall immediately return a non-zero status.

This commit also revises the __repo_attr() function so as to call the
configparser() function and interpret its output.

Fixes: e72b8b90542d1ed2bf53c2b9a0491795c12e63c2
Link: https://docs.python.org/3/library/configparser.html
Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/isolated-functions.sh | 118 +-
 bin/save-ebuild-env.sh|  14 +++---
 2 files changed, 112 insertions(+), 20 deletions(-)

diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index 546efa0190..a1c431694e 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -539,23 +539,22 @@ has() {
 }
 
 __repo_attr() {
-   local in_section exit_status=1 line saved_extglob_shopt=$(shopt -p 
extglob)
-   shopt -s extglob
+   local section key val i
+   local -a records
+
+   mapfile -td '' records < <(configparser <<<"${PORTAGE_REPOSITORIES}")
 
-   while read -r line; do
-   if (( ! in_section )) && [[ ${line} == "[$1]" ]]; then
-   in_section=1
-   elif (( in_section )) && [[ ${line} == "["*"]" ]]; then
-   in_section=0
-   elif (( in_section )) && [[ ${line} =~ ^${2}[[:space:]]*= ]]; 
then
-   echo "${line##$2*( )=*( )}"
-   exit_status=0
+   for (( i = 0; i < ${#records[@]}; i += 3 )); do
+   section=${records[i]}
+   key=${records[i + 1]}
+   if [[ ${section} == "$1" && ${key} == "$2" ]]; then
+   val=${records[i + 2]}
break
fi
-   done <<< "${PORTAGE_REPOSITORIES}"
+   done
 
-   eval "${saved_extglob_shopt}"
-   return ${exit_status}
+   # Only print the found value in the case that configparser succeeded.
+   wait "$!" && [[ -v val ]] && printf '%s\n' "${val}"
 }
 
 # eqaquote 
@@ -703,4 +702,97 @@ else
}
 fi
 
+# Consumes the standard input and attempts to parse it as the "configparser"
+# configuration file format that is native to python. Each key/value entry
+# shall be printed in the format of "%s\0%s\0%s\0", , , .
+# If the entirety of the input can be successfully parsed, the return value
+# shall be 0. Otherwise, a diagnostic message shall be printed to standard
+# error and the return value shall be greater than 0. Upon encountering the
+# first error of syntax, no further key/value entries shall be printed.
+configparser() {
+   local IFS next_{section,key} reset_extglob scalar_val section flush 
key_i line key nr i
+   local -a next_val lines val
+   local -A seen
+
+   reset_extglob=$(shopt -p extglob)
+   shopt -s extglob
+   IFS=$'\n'
+
+   # 
https://docs.python.org/3/library/configparser.html#supported-ini-file-structure
+   mapfile -t lines
+   for nr in "${!lines[@]}"; do
+   # Trim trailing whitespace characters.
+   line=${lines[nr++]%%+([[:space:]])}
+
+   # Count and trim leading whitespace characters.
+   [[ ${line} =~ ^[[:space:]]* ]]
+   if (( i = ${#BASH_REMATCH} )); then
+   line=${line:i}
+   fi
+
+   if [[ ${line} == [#\;]* ]]; then
+   # Encountered a comment.
+   false
+   elif (( ${#val[@]} && (${#line} == 0 || i > key

[gentoo-commits] proj/portage:master commit in: bin/

2025-08-02 Thread Sam James
commit: a9f83f17feb24cb1ba9ab364aee16be7ef4dd834
Author: Kerin Millar  plushkava  net>
AuthorDate: Thu Jul 24 21:18:33 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Sat Aug  2 16:31:28 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=a9f83f17

isolated-functions.sh: suppress the SC2219 notice throughout

As a matter of style, shellcheck recommends that the (( … )) compound
command be preferred over the let builtin for arithmetic. Presently,
this recommendation is being suppressed for the body of the assert()
function. Instead, suppress it for the "isolated-functions.sh" unit in
its entirety. The reason for this change is that a forthcoming commit
will introduce an additional function that uses the let builtin.

See-also: 91283cf5b59a482061bf4cf440e774a0826c664b
Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/isolated-functions.sh | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index b2f4b93628..546efa0190 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -1,7 +1,7 @@
 #!/usr/bin/env bash
 # Copyright 1999-2024 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
-# shellcheck disable=2128,2185
+# shellcheck disable=2128,2185,2219
 
 source "${PORTAGE_BIN_PATH:?}/eapi.sh" || exit
 
@@ -23,7 +23,6 @@ fi
 shopt -s expand_aliases
 
 assert() {
-   # shellcheck disable=2219
IFS='|' expression=${PIPESTATUS[*]} let '! expression' || die "$@"
 }
 



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-25 Thread Sam James
commit: 5b643fb9e8179b77f4e7cb13fc6e871cc4f5eda0
Author: Sam James  gentoo  org>
AuthorDate: Sat Jul 26 06:23:38 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Sat Jul 26 06:23:38 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=5b643fb9

save-ebuild-env.sh: don't strip PATH

A recent commit added PATH to the list of variables we strip out when
environment saving, but this defeats e.g. llvm-r{1,2}.eclass's mangling
of PATH, showing up when building dev-lang/python[jit]. But it's pretty
common to set PATH somewhere in the ebuild and expect it to persist into
other phases.

Instances of SHELL and TZ could do with checking in ::gentoo to see if
we need to change that too.

Fixes: 1df2556c3aeebc64f64c5e6a2f92d9f4a68eb9da
Signed-off-by: Sam James  gentoo.org>

 bin/save-ebuild-env.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
index a11f7a0147..3197e3c297 100644
--- a/bin/save-ebuild-env.sh
+++ b/bin/save-ebuild-env.sh
@@ -40,7 +40,7 @@ __save_ebuild_env() (
REPLY+=(
# variables that can influence the behaviour of GNU coreutils
BLOCK_SIZE COLORTERM COLUMNS DF_BLOCK_SIZE DU_BLOCK_SIZE HOME
-   LS_BLOCK_SIZE LS_COLORS POSIXLY_CORRECT PATH PWD QUOTING_STYLE
+   LS_BLOCK_SIZE LS_COLORS POSIXLY_CORRECT PWD QUOTING_STYLE
SHELL TIME_STYLE TABSIZE TMPDIR TERM TZ
 
# misc variables inherited from the calling environment



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-22 Thread Sam James
commit: 213454a448e5cd8794042a49930a37b27a4d2bbd
Author: Kerin Millar  plushkava  net>
AuthorDate: Sun Jul 20 06:09:17 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jul 22 22:30:54 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=213454a4

isolated-functions.sh: refrain from using the integer attribute in 
__dump_trace()

The only discernible purpose of the integer attribute is to entice
inexperienced bash programmers into improving their bug yield.

Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/isolated-functions.sh | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index eda6ccd3ad..9270a344d4 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -32,9 +32,8 @@ shopt -s extdebug
 #[whitespacing for filenames],
 #[whitespacing for line numbers])
 __dump_trace() {
+   local strip=${1:-1} filespacing=$2 linespacing=$3
local sourcefile funcname lineno n p
-   declare -i strip=${1:-1}
-   local filespacing=$2 linespacing=$3
 
# The __qa_call() function and anything before it are portage internals
# that the user will not be interested in. Therefore, the stack trace



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-22 Thread Sam James
commit: 91283cf5b59a482061bf4cf440e774a0826c664b
Author: Kerin Millar  plushkava  net>
AuthorDate: Sun Jul 20 07:05:12 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jul 22 22:30:56 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=91283cf5

isolated-functions.sh: address two cases where shellcheck advises against let

As a matter of style, shellcheck recommends that the (( … )) compound
command be preferred over the let builtin for arithmetic. Presently, it
does so for two instances in which the let builtin is being used.

The first concerns the assert() function, where the builtin is used out
of necessity. Mute the recommendation there.

The second concerns the ebegin() function, where there is no need to use
the builtin. Have it use the (( … )) command instead.

See-also: 6f9971e54dab95c86f0eced52574a586916a5e4b
Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/isolated-functions.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index 806df45237..55053f5d32 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -23,6 +23,7 @@ fi
 shopt -s expand_aliases
 
 assert() {
+   # shellcheck disable=2219
IFS='|' expression=${PIPESTATUS[*]} let '! expression' || die "$@"
 }
 
@@ -317,7 +318,7 @@ ebegin() {
[[ ${RC_ENDCOL} == "yes" ]] && echo >&2
LAST_E_LEN=$(( 3 + ${#RC_INDENTATION} + ${#msg} ))
LAST_E_CMD="ebegin"
-   let ++__EBEGIN_EEND_COUNT
+   (( ++__EBEGIN_EEND_COUNT ))
return 0
 }
 



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-22 Thread Sam James
commit: 8e51c60b9a95bf566390852a64f2e9b9c1e1efcc
Author: Kerin Millar  plushkava  net>
AuthorDate: Sun Jul 20 08:09:20 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jul 22 22:30:57 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=8e51c60b

isolated-functions.sh: rename the appropriate_section variable to in_section

As regards the __repo_attr() function, rename its 'appropriate_section'
variable to 'in_section'.

Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/isolated-functions.sh | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index d429e83feb..b2f4b93628 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -540,15 +540,15 @@ has() {
 }
 
 __repo_attr() {
-   local appropriate_section exit_status=1 line 
saved_extglob_shopt=$(shopt -p extglob)
+   local in_section exit_status=1 line saved_extglob_shopt=$(shopt -p 
extglob)
shopt -s extglob
 
while read -r line; do
-   if (( ! appropriate_section )) && [[ ${line} == "[$1]" ]]; then
-   appropriate_section=1
-   elif (( appropriate_section )) && [[ ${line} == "["*"]" ]]; then
-   appropriate_section=0
-   elif (( appropriate_section )) && [[ ${line} =~ 
^${2}[[:space:]]*= ]]; then
+   if (( ! in_section )) && [[ ${line} == "[$1]" ]]; then
+   in_section=1
+   elif (( in_section )) && [[ ${line} == "["*"]" ]]; then
+   in_section=0
+   elif (( in_section )) && [[ ${line} =~ ^${2}[[:space:]]*= ]]; 
then
echo "${line##$2*( )=*( )}"
exit_status=0
break



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-22 Thread Sam James
commit: 8f8afbe9a11ca7a57e5ac4d847fb2ba4ca51f338
Author: Kerin Millar  plushkava  net>
AuthorDate: Sun Jul 20 06:18:49 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jul 22 22:30:55 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=8f8afbe9

isolated-functions.sh: specify commands for standalone redirections

This is just to satisfy the SC2188 policy of shellcheck.

Link: https://www.shellcheck.net/wiki/SC2188
Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/isolated-functions.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index fbb4c6ced4..08e7a326fb 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -183,7 +183,7 @@ die() {
for x in ${EBUILD_DEATH_HOOKS}; do
${x} "$@"
done >&2
-   > "${PORTAGE_BUILDDIR}/.die_hooks"
+   : > "${PORTAGE_BUILDDIR}/.die_hooks"
fi
 
if [[ -n ${PORTAGE_LOG_FILE} ]] ; then
@@ -209,7 +209,7 @@ die() {
eerror "Working directory: '$(pwd)'"
[[ -n ${S} ]] && eerror "S: '${S}'"
 
-   [[ -n ${PORTAGE_EBUILD_EXIT_FILE} ]] && > "${PORTAGE_EBUILD_EXIT_FILE}"
+   [[ -n ${PORTAGE_EBUILD_EXIT_FILE} ]] && : > 
"${PORTAGE_EBUILD_EXIT_FILE}"
[[ -n ${PORTAGE_IPC_DAEMON} ]] && "${PORTAGE_BIN_PATH}"/ebuild-ipc exit 
1
 
# subshell die support



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-22 Thread Sam James
commit: 3eeff52eda750df5fc75b5e9b460a3786c968c7c
Author: Kerin Millar  plushkava  net>
AuthorDate: Fri Jul 18 19:14:01 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jul 22 22:29:36 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=3eeff52e

phase-helpers.sh: rename _eapply_patch() to __eapply_patch()

Presently, the "phase-helpers.sh" unit defines the _eapply_patch()
helper function, provided that the targeted EAPI is confirmed to support
eapply(). Unlike other functions that portage declares as ostensibly
being for internal use, its name contains only a single leading
, rendering it an outlier. Rename the function so that its
name contains two leading  characters.

Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/phase-helpers.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index f01ef09467..89f1f6f2f8 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -981,7 +981,7 @@ if ___eapi_has_eapply; then
patch() { gpatch "$@"; }
fi
 
-   _eapply_patch() {
+   __eapply_patch() {
local prefix=$1 patch=$2 output IFS
shift 2
 
@@ -1041,14 +1041,14 @@ if ___eapi_has_eapply; then
if (( i++ == 0 )); then
einfo "Applying patches 
from ${path} ..."
fi
-   _eapply_patch '  ' "${f}" 
"${options[@]}" || return
+   __eapply_patch '  ' "${f}" 
"${options[@]}" || return
fi
done
if (( i == 0 )); then
die "No *.{patch,diff} files in 
directory ${path}"
fi
else
-   _eapply_patch '' "${path}" "${options[@]}" || 
return
+   __eapply_patch '' "${path}" "${options[@]}" || 
return
fi
done
}



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-22 Thread Sam James
commit: d631e3e833aca4f35e86029dc564743c3e3aed0f
Author: Kerin Millar  plushkava  net>
AuthorDate: Sun Jul 20 07:48:28 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jul 22 22:30:57 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=d631e3e8

isolated-functions.sh: render the control flow of __repo_attr() clear

Presently, the way in which the __repo_attr() function is written
renders its control flow obscure. Address this issue by employing a
nicely structured if command and treating the 'appropriate_section'
variable as a quasi-boolean that is evaluated in the arithmetic context.

Further, remove a comment pointing out that bash-3.2 may not handle
extended globs in conditional expressions, if presented in their raw
form. While such is true of 3.2 - and all versions of bash prior to 4.1
- it is irrelevant at this juncture.

Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/isolated-functions.sh | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index 55053f5d32..d429e83feb 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -540,21 +540,21 @@ has() {
 }
 
 __repo_attr() {
-   local appropriate_section=0 exit_status=1 line 
saved_extglob_shopt=$(shopt -p extglob)
+   local appropriate_section exit_status=1 line 
saved_extglob_shopt=$(shopt -p extglob)
shopt -s extglob
+
while read -r line; do
-   [[ ${appropriate_section} == 0 && ${line} == "[$1]" ]] && 
appropriate_section=1 && continue
-   [[ ${appropriate_section} == 1 && ${line} == "["*"]" ]] && 
appropriate_section=0 && continue
-   # If a conditional expression like [[ ${line} == $2*( )=* ]] is 
used
-   # then bash-3.2 produces an error like the following when the 
file is
-   # sourced: syntax error in conditional expression: unexpected 
token `('
-   # Therefore, use a regular expression for compatibility.
-   if [[ ${appropriate_section} == 1 && ${line} =~ 
^${2}[[:space:]]*= ]]; then
+   if (( ! appropriate_section )) && [[ ${line} == "[$1]" ]]; then
+   appropriate_section=1
+   elif (( appropriate_section )) && [[ ${line} == "["*"]" ]]; then
+   appropriate_section=0
+   elif (( appropriate_section )) && [[ ${line} =~ 
^${2}[[:space:]]*= ]]; then
echo "${line##$2*( )=*( )}"
exit_status=0
break
fi
done <<< "${PORTAGE_REPOSITORIES}"
+
eval "${saved_extglob_shopt}"
return ${exit_status}
 }



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-22 Thread Sam James
commit: 8d02d2de89b8af6ca4da9f2e8b7cc989822bbf3f
Author: Kerin Millar  plushkava  net>
AuthorDate: Sun Jul 20 06:25:07 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jul 22 22:30:55 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=8d02d2de

isolated-functions.sh: mute an SC2034 warning regarding PORTAGE_COLOR_HILITE

Presently, shellcheck warns that the 'PORTAGE_COLOR_HILITE' variable
appears to be unused. Prevent it from doing so.

Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/isolated-functions.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index 08e7a326fb..bd701ad011 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -391,6 +391,7 @@ __set_colors() {
# Now, ${ENDCOL} will move us to the end of the
# column; regardless of character width
ENDCOL=$'\e[A\e['$(( COLS - 8 ))'C'
+   # shellcheck disable=2034
if [[ ${PORTAGE_COLORMAP} ]]; then
# The PORTAGE_COLORMAP environment variable is defined by the
# doebuild.py unit and is intended to be evaluated as code.



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-22 Thread Sam James
commit: eb1a32ed5698621dd41ebb88bfc88f5ed39cc38c
Author: Kerin Millar  plushkava  net>
AuthorDate: Sun Jul 20 06:33:19 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jul 22 22:30:56 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=eb1a32ed

isolated-functions.sh: drop the unused RC_DEFAULT_INDENT variable

Portage makes no use of the 'RC_DEFAULT_INDENT' variable. The
gentoo-functions project used to make use of this variable, albeit only
for the eindent() and eoutdent() functions, neither of which are
implemented by the "isolated-functions.sh" unit. Drop it.

Link: 
https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=4f3b38f5c910980352c76de3f99b3bd4d6534cbc
Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/isolated-functions.sh | 1 -
 bin/save-ebuild-env.sh| 6 +++---
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index bd701ad011..806df45237 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -412,7 +412,6 @@ __set_colors() {
 
 RC_ENDCOL="yes"
 RC_INDENTATION=''
-RC_DEFAULT_INDENT=2
 RC_DOT_PATTERN=''
 
 

diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
index 6c14f59d10..a11f7a0147 100644
--- a/bin/save-ebuild-env.sh
+++ b/bin/save-ebuild-env.sh
@@ -69,9 +69,9 @@ __save_ebuild_env() (
PORTAGE_COLOR_INFO PORTAGE_COLOR_WARN PORTAGE_COLOR_BAD
PORTAGE_COLOR_ERR PORTAGE_COLOR_LOG PORTAGE_COMPRESS
PORTAGE_NONFATAL PORTAGE_QUIET PREROOTPATH PKG_LOGDIR
-   PKG_TMPDIR PKGDIR PKGUSE QA_INTERCEPTORS RC_DEFAULT_INDENT
-   RC_DOT_PATTERN RC_INDENTATION RC_ENDCOL ROOTPATH RPMDIR ROOT
-   TMPDIR TEMP TMP USE_EXPAND XARGS _RC_GET_KV_CACHE
+   PKG_TMPDIR PKGDIR PKGUSE QA_INTERCEPTORS RC_DOT_PATTERN
+   RC_INDENTATION RC_ENDCOL ROOTPATH RPMDIR ROOT TMPDIR TEMP TMP
+   USE_EXPAND XARGS _RC_GET_KV_CACHE
 
# user config variables
DOC_SYMLINKS_DIR INSTALL_MASK PKG_INSTALL_MASK



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-22 Thread Sam James
commit: 1a4e951b7166b62d7e82b38f35f406b7033854c8
Author: Kerin Millar  plushkava  net>
AuthorDate: Fri Jul 18 04:08:35 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jul 22 22:29:34 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=1a4e951b

save-ebuild-env.sh: filter out variables with the SSH_ prefix

Presently, the __save_ebuild_env() function filters out the
'SSH_AGENT_PID' variable. Instead, filter out all variables bearing a
prefix of "SSH_". With this change, I was immediately able to observe an
improvement in "environment.bz2" hygiene. In particular, the
'SSH_CLIENT' and 'SSH_CONNECTION' variables are now excluded.

declare -x SSH_CLIENT="10.0.0.3 56240 22"
declare -x SSH_CONNECTION="10.0.0.3 56240 10.0.0.2 22"
declare -x SSH_TTY="/dev/pts/0"

These variables clearly impact upon the privacy of the user and portage
has no business whatsoever in dumping them into world-readable files
beneath the "/var/db/pkg" directory, nor in incorporating them into
binary packages.

Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/save-ebuild-env.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
index 5198f6f9e7..71c4c2e672 100644
--- a/bin/save-ebuild-env.sh
+++ b/bin/save-ebuild-env.sh
@@ -48,8 +48,8 @@ __save_ebuild_env() (
ftp_proxy https_proxy http_proxy no_proxy
 
# other variables inherited from the calling environment
-   CVS_RSH ECHANGELOG_USER GPG_AGENT_INFO SSH_AGENT_PID
-   SSH_AUTH_SOCK STY WINDOW XAUTHORITY
+   "${!SSH_@}" CVS_RSH ECHANGELOG_USER GPG_AGENT_INFO STY WINDOW
+   XAUTHORITY
 
# portage config variables and variables set directly by portage
ACCEPT_LICENSE BUILD_PREFIX COLS DOC_SYMLINKS_DIR DISTDIR



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-22 Thread Sam James
commit: 079586e7a0d89ba1050567549e954bcf2b5d0976
Author: Kerin Millar  plushkava  net>
AuthorDate: Fri Jul 18 20:20:51 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jul 22 22:29:36 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=079586e7

isolated-functions.sh: don't define find0() as a self-redeclaring function

Presently, find0() is implemented as a self-redeclaring function. Upon
first being called, if chooses one of two implementations, one of which
serves to cover situations where the -files0-from option is unavailable,
thereby retaining compatibility with the outdated GitHub CI environment.
However, the "isolated-functions.sh" unit calls find0() at the time of
being sourced, for reasons that are explained by commit 3fa9f4d6aa.

Instead, hoist the test for the -files0-from option so that an
implementation is chosen without having to explicitly call the function.
This serves both as a micro-optimisation and as a minor code cleanup.

See-also: 3fa9f4d6aa646553a45cd0118fe46adb64bafd13
See-also: b381d3533901b03ca50329d020c51c82757cdb5e
Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/isolated-functions.sh | 51 ---
 1 file changed, 22 insertions(+), 29 deletions(-)

diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index 109c1cd9c6..6db0340926 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -691,34 +691,27 @@ contains_word() {
 # parameters shall be conveyed verbatim and are guaranteed to be treated as
 # options and/or primaries, provided that the version of GNU findutils is 4.9.0
 # or greater. For older versions, no such guarantee is made.
-find0() {
-   if printf '/\0' | find -files0-from - -maxdepth 0 &>/dev/null; then
-   find0() {
-   find -files0-from - "$@"
-   }
-   else
-   # This is a temporary workaround for the GitHub CI runner, which
-   # suffers from an outdated version of findutils, per bug 957550.
-   find0() {
-   local -a opts paths
-
-   # All of -H, -L and -P are options. If specified, they
-   # must precede pathnames and primaries alike.
-   while [[ $1 == -[HLP] ]]; do
-   opts+=("$1")
-   shift
-   done
-   mapfile -td '' paths
-   if (( ${#paths[@]} )); then
-   find "${opts[@]}" "${paths[@]}" "$@"
-   fi
-   }
-   fi
-
-   find0 "$@"
-}
-
-# Initialise the function now because find0() is normally called after forking.
-find0 < /dev/null
+if printf '/\0' | find -files0-from - -maxdepth 0 &>/dev/null; then
+   find0() {
+   find -files0-from - "$@"
+   }
+else
+   # This is a temporary workaround for the GitHub CI runner, which
+   # suffers from an outdated version of findutils, per bug 957550.
+   find0() {
+   local -a opts paths
+
+   # All of -H, -L and -P are options. If specified, they must
+   # precede pathnames and primaries alike.
+   while [[ $1 == -[HLP] ]]; do
+   opts+=("$1")
+   shift
+   done
+   mapfile -td '' paths
+   if (( ${#paths[@]} )); then
+   find "${opts[@]}" "${paths[@]}" "$@"
+   fi
+   }
+fi
 
 true



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-22 Thread Sam James
commit: d5e2aac1af233909571fb6c2f4c8ffd4e67fbea8
Author: Kerin Millar  plushkava  net>
AuthorDate: Sun Jul 20 05:38:17 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jul 22 22:30:53 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=d5e2aac1

isolated-functions.sh: mute two instances of SC2185 that are false-positives

Presently, there are two implementations of find0(), one of which serves
to cover situations where the -files0-from option is unavailable,
thereby retaining compatibility with the outdated GitHub CI environment.

Presently, both the preferred implementation and the test that
determines which implementation to use raise spurious SC2185 warnings,
because shellcheck is unaware of the option and its purpose. Mute this
warning code for the entirety of the "isolated-functions.sh" unit.

Link: https://www.shellcheck.net/wiki/SC2185
Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/isolated-functions.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index ed66dcbe48..54b86687a5 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -1,7 +1,7 @@
 #!/usr/bin/env bash
 # Copyright 1999-2024 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
-# shellcheck disable=SC2128
+# shellcheck disable=2128,2185
 
 source "${PORTAGE_BIN_PATH:?}/eapi.sh" || exit
 



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-22 Thread Sam James
commit: d887c8af4c90e7237167fd09459b373fa0791fbd
Author: Kerin Millar  plushkava  net>
AuthorDate: Fri Jul 18 19:06:02 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jul 22 22:29:35 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=d887c8af

phase-helpers.sh: don't repeatedly declare the _eapply_patch() function

Presently, the _eapply_patch() function is declared upon each occasion
that the eapply() function is called. Hoist it upwards so that it is
declared exactly once, once the targeted EAPI has been confirmed to
support eapply (meaning that it must be greater than 5).

See-also: 51ad398621e668920c46916c9a90768e27c2df62
Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/phase-helpers.sh | 48 
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index a350d073a3..f01ef09467 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -981,34 +981,34 @@ if ___eapi_has_eapply; then
patch() { gpatch "$@"; }
fi
 
+   _eapply_patch() {
+   local prefix=$1 patch=$2 output IFS
+   shift 2
+
+   ebegin "${prefix:-Applying }${patch##*/}"
+   # -p1 as a sane default
+   # -f to avoid interactivity
+   # -g0 to guarantee no VCS interaction
+   # --no-backup-if-mismatch not to pollute the sources
+   set -- -p1 -f -g0 --no-backup-if-mismatch "$@"
+   if output=$(LC_ALL= LC_MESSAGES=C patch "$@" < "${patch}" 
2>&1); then
+   # The patch was successfully applied. Maintain silence
+   # unless applied with fuzz.
+   if [[ ${output} == *[0-9]' with fuzz '[0-9]* ]]; then
+   printf '%s\n' "${output}"
+   fi
+   eend 0
+   else
+   printf '%s\n' "${output}" >&2
+   eend 1
+   __helpers_die "patch ${*@Q} failed with ${patch@Q}"
+   fi
+   }
+
eapply() {
local LC_ALL LC_COLLATE=C f i path
local -a operands options
 
-   _eapply_patch() {
-   local prefix=$1 patch=$2 output IFS
-   shift 2
-
-   ebegin "${prefix:-Applying }${patch##*/}"
-   # -p1 as a sane default
-   # -f to avoid interactivity
-   # -g0 to guarantee no VCS interaction
-   # --no-backup-if-mismatch not to pollute the sources
-   set -- -p1 -f -g0 --no-backup-if-mismatch "$@"
-   if output=$(LC_ALL= LC_MESSAGES=C patch "$@" < 
"${patch}" 2>&1); then
-   # The patch was successfully applied. Maintain
-   # silence unless applied with fuzz.
-   if [[ ${output} == *[0-9]' with fuzz '[0-9]* 
]]; then
-   printf '%s\n' "${output}"
-   fi
-   eend 0
-   else
-   printf '%s\n' "${output}" >&2
-   eend 1
-   __helpers_die "patch ${*@Q} failed with 
${patch@Q}"
-   fi
-   }
-
while (( $# )); do
case $1 in
--)



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-22 Thread Sam James
commit: c1f8fabbb944c55cc69a4038750cd58b4a822108
Author: Kerin Millar  plushkava  net>
AuthorDate: Sun Jul 20 06:08:05 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jul 22 22:30:54 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=c1f8fabb

isolated-functions.sh: drop an unused variable from  __dump_trace()

The local 's' variable goes unused. Drop it.

Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/isolated-functions.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index e1e0bc10be..eda6ccd3ad 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -32,7 +32,7 @@ shopt -s extdebug
 #[whitespacing for filenames],
 #[whitespacing for line numbers])
 __dump_trace() {
-   local funcname="" sourcefile="" lineno="" s="yes" n p
+   local sourcefile funcname lineno n p
declare -i strip=${1:-1}
local filespacing=$2 linespacing=$3
 



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-22 Thread Sam James
commit: 85d8343bf0dcc5e9aeab3a54b1b83db4dd3ec89f
Author: Kerin Millar  plushkava  net>
AuthorDate: Sun Jul 20 05:29:36 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jul 22 22:30:52 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=85d8343b

isolated-functions.sh: don't validate the first parameter in __elog_base()

Presently, the __elog_base() helper function validates the first
positional parameter, which is expected to be any of "INFO", "WARN",
"ERROR", "LOG" or "QA". To do so is futile because there are only six
instances in which the function is invoked, all of which hard-code one
of these expected values. Drop the validation code.

Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/isolated-functions.sh | 14 +++---
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index 23348b918c..ed66dcbe48 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -230,7 +230,9 @@ __vecho() {
 
 # Internal logging function, don't use this in ebuilds
 __elog_base() {
-   local messagetype
+   local messagetype=$1
+   shift
+
if [[ ${EBUILD_PHASE} == depend && -z ${__PORTAGE_ELOG_BANNER_OUTPUT} 
]]; then
# in depend phase, we want to output a banner indicating which
# package emitted the message
@@ -239,16 +241,6 @@ __elog_base() {
__PORTAGE_ELOG_BANNER_OUTPUT=1
fi
[[ -z "${1}" || -z "${T}" || ! -d "${T}/logging" ]] && return 1
-   case "${1}" in
-   INFO|WARN|ERROR|LOG|QA)
-   messagetype="${1}"
-   shift
-   ;;
-   *)
-   __vecho -e " 
${PORTAGE_COLOR_BAD}*${PORTAGE_COLOR_NORMAL} Invalid use of internal function 
__elog_base(), next message will not be logged"
-   return 1
-   ;;
-   esac
echo -e "$@" | while read -r ; do
echo "${messagetype} ${REPLY}"
done >> "${T}/logging/${EBUILD_PHASE:-other}"



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-22 Thread Sam James
commit: 277a5b46dc0cfa7c0e6aaa680d9cc5f7b989ee41
Author: Kerin Millar  plushkava  net>
AuthorDate: Sun Jul 20 06:16:39 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jul 22 22:30:55 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=277a5b46

isolated-functions.sh: rectify six unquoted parameter expansions

Rectify six instances in which unquoted parameter expansions are
performed (SC2086). Three of these concern the die() function, two
concern the eend() function, and one concerns the __set_colors()
function.

Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/isolated-functions.sh | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index 9270a344d4..fbb4c6ced4 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -141,7 +141,7 @@ die() {
local main_index
(( main_index = ${#BASH_SOURCE[@]} - 1 ))
if [[ ${BASH_SOURCE[main_index]##*/} == @(ebuild|misc-functions).sh ]]; 
then
-   __dump_trace 2 ${filespacing} ${linespacing}
+   __dump_trace 2 "${filespacing}" "${linespacing}"
eerror "  $(printf "%${filespacing}s" "${BASH_SOURCE[1]##*/}"), line 
$(printf "%${linespacing}s" "${BASH_LINENO[0]}"):  Called die"
eerror "The specific snippet of code:"
# This scans the file that called die and prints out the logic that
@@ -341,7 +341,7 @@ __eend() {
printf "%$(( COLS - LAST_E_LEN - 7 ))s%b\n" '' "${msg}" >&2
fi
 
-   return ${retval}
+   return "${retval}"
 }
 
 eend() {
@@ -353,10 +353,10 @@ eend() {
eqawarn "QA Notice: eend called without preceding ebegin in 
${FUNCNAME[1]}"
fi
 
-   __eend ${retval} eerror "$*"
+   __eend "${retval}" eerror "$*"
 
LAST_E_CMD="eend"
-   return ${retval}
+   return "${retval}"
 }
 
 __unset_colors() {
@@ -391,8 +391,10 @@ __set_colors() {
# Now, ${ENDCOL} will move us to the end of the
# column; regardless of character width
ENDCOL=$'\e[A\e['$(( COLS - 8 ))'C'
-   if [[ -n "${PORTAGE_COLORMAP}" ]]; then
-   eval ${PORTAGE_COLORMAP}
+   if [[ ${PORTAGE_COLORMAP} ]]; then
+   # The PORTAGE_COLORMAP environment variable is defined by the
+   # doebuild.py unit and is intended to be evaluated as code.
+   eval "${PORTAGE_COLORMAP}"
else
PORTAGE_COLOR_BAD=$'\e[31;01m'
PORTAGE_COLOR_BRACKET=$'\e[34;01m'



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-22 Thread Sam James
commit: 7a03e610d63b42ca42c05135427d807e76b21f01
Author: Kerin Millar  plushkava  net>
AuthorDate: Sun Jul 20 06:01:02 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jul 22 22:30:53 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=7a03e610

isolated-functions.sh: specify the -r option to read in __repo_attr()

Presently, the __repo_attr() function acts as a crude parser for the
value of the 'PORTAGE_REPOSITORIES' variable, which contains the
contents of files beneath the "/etc/portage/repos.conf" directory. It
makes 'PORTAGE_REPOSITORIES' the subject of a herestring, and uses the
read builtin to obtain each embedded line. However, if fails to specify
the -r option. Have it do so, duly rectifying an instance of SC2162.

Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/isolated-functions.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index 54b86687a5..e1e0bc10be 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -540,7 +540,7 @@ has() {
 __repo_attr() {
local appropriate_section=0 exit_status=1 line 
saved_extglob_shopt=$(shopt -p extglob)
shopt -s extglob
-   while read line; do
+   while read -r line; do
[[ ${appropriate_section} == 0 && ${line} == "[$1]" ]] && 
appropriate_section=1 && continue
[[ ${appropriate_section} == 1 && ${line} == "["*"]" ]] && 
appropriate_section=0 && continue
# If a conditional expression like [[ ${line} == $2*( )=* ]] is 
used



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-22 Thread Sam James
commit: 6f9971e54dab95c86f0eced52574a586916a5e4b
Author: Kerin Millar  plushkava  net>
AuthorDate: Fri Jul 18 21:01:08 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jul 22 22:29:37 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=6f9971e5

isolated-functions.sh: render assert() insensitive to the value of IFS

The purpose of the assert() function is to forward the positional
parameters to the die() function, provided that any of the elements of
the 'PIPESTATUS' array variable are non-zero. However, the function is
defective because it is beholden to the prevailing value of IFS.

Consider the following.

$ IFS=1
$ set -x; true | false | true; assert
+ true
+ false
+ true
+ assert
+ local x pipestatus=01110
+ for x in ${pipestatus}
+ [[ 0 -eq 0 ]]
+ for x in ${pipestatus}
+ [[ '' -eq 0 ]]
+ for x in ${pipestatus}
+ [[ '' -eq 0 ]]
+ for x in ${pipestatus}
+ [[ 0 -eq 0 ]]

It can be seen that the elements of 'PIPESTATUS' are joined by "1",
forming the string, "01110", which is assigned to the 'pipestatus'
variable. Next, the for command is tasked with iterating over the words
produced by an unquoted expansion of this variable. Since "1" is acting
as a field terminator, the for loop iterates over two instances of "0",
and two instances of the null string, all of which are arithmetically
equal to 0. Consequently, die() is never called, though it ought to be.

Address this issue by forming an arithmetic expression from the elements
of 'PIPESTATUS' and having a single invocation of the let builtin
evaluate it.

$ IFS=1
$ set -x; true | false | true; assert
+ true
+ false
+ true
+ assert
+ IFS='|'
+ expression='0|1|0'
+ let '! expression'
+ die

Bug: https://bugs.gentoo.org/25929
Fixes: c86c1391904231287824676cc663d7e3eddd8954
See-also: 038146623c0cdca0ba2038ee7837c3a2170b35de
Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/isolated-functions.sh | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index 6db0340926..0c83e5d963 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -23,10 +23,7 @@ fi
 shopt -s expand_aliases
 
 assert() {
-   local x pipestatus=${PIPESTATUS[*]}
-   for x in ${pipestatus} ; do
-   [[ ${x} -eq 0 ]] || die "$@"
-   done
+   IFS='|' expression=${PIPESTATUS[*]} let '! expression' || die "$@"
 }
 
 shopt -s extdebug



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-22 Thread Sam James
commit: dbff78a1c6ce9f08b25a7c9978a177cc37f1b1bd
Author: Kerin Millar  plushkava  net>
AuthorDate: Fri Jul 18 05:36:28 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jul 22 22:29:35 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=dbff78a1

phase-helpers.sh: hoist the my_output local to the top of unpack()

Presently, all of the variables that are local to the unpack() function
are declared at the top of its body, with the exception of the
'my_output' variable. Hoist it upwards so that it is declared at the
same time as the others. Further, rename the variable to 'output'.

Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/phase-helpers.sh | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index 609d763915..a350d073a3 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -322,7 +322,7 @@ use_enable() {
 }
 
 unpack() {
-   local created_symlink suffix_known basename srcdir suffix f -
+   local created_symlink suffix_known basename output srcdir suffix f -
local -a bzip2_cmd
 
if (( $# == 0 )); then
@@ -438,9 +438,8 @@ unpack() {
__unpack_tar "${bzip2_cmd[@]}"
;;
7z)
-   local my_output
-   if ! my_output=$(7z x -y "${srcdir}${f}"); then
-   printf '%s\n' "${my_output}" >&2
+   if ! output=$(7z x -y "${srcdir}${f}"); then
+   printf '%s\n' "${output}" >&2
false
fi
;;



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-22 Thread Sam James
commit: 9f354763d2cd8ef0f3390aee1dfd46a571c5d4f1
Author: Kerin Millar  plushkava  net>
AuthorDate: Sun Jul 20 05:14:02 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jul 22 22:30:52 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=9f354763

isolated-functions.sh: don't open/close/dup file descriptors so frequently

As regards the die() function, refrain from duplicating file descriptor
#2 to file descriptor #1 for each invocation of the functions whose
names comprise the value of the 'EBUILD_DEATH_HOOKS' variable, twice.
Instead, duplicate once and maintain the state of file descriptor #1 for
the duration of the containing loop.

As regards the __elog_base() function, refrain from duplicating file
descriptor #2 to file descriptor #1 twice in the course of printing the
banner message. Instead, do so only once. Further, refrain from opening
and closing a log file for each and every line that is destined to it.
Instead, open the file once and keep it open for the duration of the
containing loop.

As regards the eqawarn(), eerror(), einfo(), ewarn() and elog()
functions, refrain from duplicating file descriptor #2 to file
descriptor #1 for each and every line that is to be printed. Instead,
duplicate once and maintain the state of file descriptor #1 for the
duration of the containing loop.

Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/isolated-functions.sh | 33 -
 1 file changed, 16 insertions(+), 17 deletions(-)

diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index 0c83e5d963..23348b918c 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -182,8 +182,8 @@ die() {
then
local x
for x in ${EBUILD_DEATH_HOOKS}; do
-   ${x} "$@" >&2 1>&2
-   done
+   ${x} "$@"
+   done >&2
> "${PORTAGE_BUILDDIR}/.die_hooks"
fi
 
@@ -234,8 +234,8 @@ __elog_base() {
if [[ ${EBUILD_PHASE} == depend && -z ${__PORTAGE_ELOG_BANNER_OUTPUT} 
]]; then
# in depend phase, we want to output a banner indicating which
# package emitted the message
-   echo >&2
-   echo "Messages for package 
${PORTAGE_COLOR_INFO}${CATEGORY}/${PF}::${PORTAGE_REPO_NAME}${PORTAGE_COLOR_NORMAL}:"
 >&2
+   printf >&2 '\nMessages for package %s%s%s:\n' \
+   "${PORTAGE_COLOR_INFO}" 
"${CATEGORY}/${PF}::${PORTAGE_REPO_NAME}" "${PORTAGE_COLOR_NORMAL}"
__PORTAGE_ELOG_BANNER_OUTPUT=1
fi
[[ -z "${1}" || -z "${T}" || ! -d "${T}/logging" ]] && return 1
@@ -250,9 +250,8 @@ __elog_base() {
;;
esac
echo -e "$@" | while read -r ; do
-   echo "${messagetype} ${REPLY}" >> \
-   "${T}/logging/${EBUILD_PHASE:-other}"
-   done
+   echo "${messagetype} ${REPLY}"
+   done >> "${T}/logging/${EBUILD_PHASE:-other}"
return 0
 }
 
@@ -260,8 +259,8 @@ eqawarn() {
__elog_base QA "$*"
[[ ${RC_ENDCOL} != "yes" && ${LAST_E_CMD} == "ebegin" ]] && echo >&2
echo -e "$@" | while read -r ; do
-   echo " ${PORTAGE_COLOR_QAWARN}*${PORTAGE_COLOR_NORMAL} 
${REPLY}" >&2
-   done
+   echo " ${PORTAGE_COLOR_QAWARN}*${PORTAGE_COLOR_NORMAL} ${REPLY}"
+   done >&2
LAST_E_CMD="eqawarn"
return 0
 }
@@ -270,8 +269,8 @@ elog() {
__elog_base LOG "$*"
[[ ${RC_ENDCOL} != "yes" && ${LAST_E_CMD} == "ebegin" ]] && echo >&2
echo -e "$@" | while read -r ; do
-   echo " ${PORTAGE_COLOR_LOG}*${PORTAGE_COLOR_NORMAL} ${REPLY}" 
>&2
-   done
+   echo " ${PORTAGE_COLOR_LOG}*${PORTAGE_COLOR_NORMAL} ${REPLY}"
+   done >&2
LAST_E_CMD="elog"
return 0
 }
@@ -280,8 +279,8 @@ einfo() {
__elog_base INFO "$*"
[[ ${RC_ENDCOL} != "yes" && ${LAST_E_CMD} == "ebegin" ]] && echo >&2
echo -e "$@" | while read -r ; do
-   echo " ${PORTAGE_COLOR_INFO}*${PORTAGE_COLOR_NORMAL} ${REPLY}" 
>&2
-   done
+   echo " ${PORTAGE_COLOR_INFO}*${PORTAGE_COLOR_NORMAL} ${REPLY}"
+   done >&2
LAST_E_CMD="einfo"
return 0
 }
@@ -298,8 +297,8 @@ ewarn() {
__elog_base WARN "$*"
[[ ${RC_ENDCOL} != "yes" && ${LAST_E_CMD} == "ebegin" ]] && echo >&2
echo -e "$@" | while read -r ; do
-   echo " ${PORTAGE_COLOR_WARN}*${PORTAGE_COLOR_NORMAL} 
${RC_INDENTATION}${REPLY}" >&2
-   done
+   echo " ${PORTAGE_COLOR_WARN}*${PORTAGE_COLOR_NORMAL} 
${RC_INDENTATION}${REPLY}"
+   done >&2
LAST_E_CMD="ewarn"
return 0
 }
@@ -308,8 +307,8 @@ eerror() {
__elog_base ERROR "$*"
[[ ${RC_ENDCOL} != "yes" && ${LAST_E_CMD} == "ebegin" ]] && echo >&2
echo -e "$@" | while 

[gentoo-commits] proj/portage:master commit in: bin/

2025-07-22 Thread Sam James
commit: 30777940190e2a4f807ac114bc33bb123555fd5c
Author: Kerin Millar  plushkava  net>
AuthorDate: Fri Jul 18 19:19:30 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jul 22 22:29:36 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=30777940

save-ebuild-env.sh: filter out the __eapply_patch() function

Presently, the "phase-helpers.sh" unit defines the __eapply_patch()
helper function, provided that the targeted EAPI is confirmed to support
eapply(). Surprisingly, the __save_ebuild_env() function does not filter
out __eapply_patch() but it ought to. Make it so.

Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/save-ebuild-env.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
index 1590d28b1c..6c14f59d10 100644
--- a/bin/save-ebuild-env.sh
+++ b/bin/save-ebuild-env.sh
@@ -128,7 +128,7 @@ __save_ebuild_env() (
___eapi_has_eapply_user && REPLY+=( __readdir eapply_user )
___eapi_has_get_libdir && REPLY+=( get_libdir )
___eapi_has_in_iuse && REPLY+=( in_iuse )
-   ___eapi_has_eapply && REPLY+=( eapply patch )
+   ___eapi_has_eapply && REPLY+=( __eapply_patch eapply patch )
___eapi_has_usex && REPLY+=( usex )
 
# Destroy the collected functions.



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-22 Thread Sam James
commit: ad499b1f906472967881350c51e4571d833aeb79
Author: Kerin Millar  plushkava  net>
AuthorDate: Fri Jul 18 04:42:42 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jul 22 22:29:34 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=ad499b1f

save-ebuild-env.sh: filter out a subset of variables with the XDG_ prefix

Have the __save_ebuild_env() function filter out the 'XDG_VTNR'
variable, in addition to all variables bearing the following prefixes.

- XDG_CONFIG_
- XDG_CURRENT_
- XDG_DATA_
- XDG_MENU_
- XDG_RUNTIME_
- XDG_SEAT_
- XDG_SESSION_

With this change, I was able to observe a marked improvement in
"environment.bz2" hygiene for scenarios in with the effective UID is
elevated to 0 (root) without simulating a full login. In particular, all
of the following variables are now excluded.

- XDG_CONFIG_DIRS
- XDG_CURRENT_DESKTOP
- XDG_DATA_DIRS
- XDG_MENU_PREFIX
- XDG_RUNTIME_DIR
- XDG_SEAT
- XDG_SEAT_PATH
- XDG_SESSION_CLASS
- XDG_SESSION_DESKTOP
- XDG_SESSION_ID
- XDG_SESSION_PATH
- XDG_SESSION_TYPE
- XDG_VTNR

Some of these variables moderately impact upon the privacy of the user
and portage has no business dumping them into world-readable files
beneath the "/var/db/pkg" directory, nor in incorporating them into
binary packages. The 'XDG_DATA_DIRS' variable is notable among these,
for it may remain set even when simulating a full login e.g. by running
su(1) with the -l option.

The reason for being selective with the prefixes is that the "xdg"
eclass conflicts with the "XDG_" namespace by declaring several
variables bearing the "XDG_ECLASS_" prefix; none of which are
environment variables, mind. I have not yet ascertained that those are
safe to exclude and am therefore erring on the side of caution.

Finally, it should be noted that the 'XDG_CONFIG_HOME', 'XDG_DATA_HOME',
'XDG_STATE_HOME' and 'XDG_RUNTIME_DIR' variables were already being
excluded for EAPI 7 and 8, owing to the definition of 'ENV_UNSET' in the
base profile.

Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/save-ebuild-env.sh | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
index 71c4c2e672..1590d28b1c 100644
--- a/bin/save-ebuild-env.sh
+++ b/bin/save-ebuild-env.sh
@@ -48,8 +48,10 @@ __save_ebuild_env() (
ftp_proxy https_proxy http_proxy no_proxy
 
# other variables inherited from the calling environment
-   "${!SSH_@}" CVS_RSH ECHANGELOG_USER GPG_AGENT_INFO STY WINDOW
-   XAUTHORITY
+   "${!SSH_@}" "${!XDG_CURRENT_@}" "${!XDG_RUNTIME_@}"
+   "${!XDG_SESSION_@}" "${!XDG_CONFIG_@}" "${!XDG_DATA_@}"
+   "${!XDG_MENU_@}" "${!XDG_SEAT_@}" CVS_RSH ECHANGELOG_USER
+   GPG_AGENT_INFO STY WINDOW XAUTHORITY XDG_VTNR
 
# portage config variables and variables set directly by portage
ACCEPT_LICENSE BUILD_PREFIX COLS DOC_SYMLINKS_DIR DISTDIR



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

2025-07-22 Thread Sam James
commit: 502bd866c85a44852bf1b214c3504d00ca50add5
Author: Kerin Millar  plushkava  net>
AuthorDate: Wed Jul 16 03:40:36 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jul 22 22:29:33 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=502bd866

isolated-functions.sh: drop the __assert_sigpipe_ok() function

The __assert_sigpipe_ok() function was introduced in 2010 as a means of
helping to handle the processing of malformed tarballs being distributed
for various sub-projects of GNOME. Among them were the tarballs for
glibmm and evolution-data-server, both of which were found to be the
improper concatenations of two tar archives of the archaic "v7" format.

As things stand now, fifteen years later, I believe it to be a hack that
has run its course. Nowadays, it is conventional for both GNU tar and
bsdtar to produce archives that are of the "pax" format, as defined by
POSIX.1-2001. This is a format unencumbered by the limitations that were
indirectly responsible for the aforesaid defective tarballs. Besides
which, the unpack() function of the "phase-helpers.sh" unit no longer
calls __assert_sigpipe_ok() (since commit 6a3cd41450).

Hence, jettison the __assert_sigpipe_ok() function. Further, jettison
the 'PORTAGE_SIGPIPE_STATUS' environment variable that had hitherto been
defined by the "doebuild.py" unit. The purpose of this variable was to
render the function aware of the numerical value of SIGPIPE. Yet, the
shell requires no assistance in determining this information.

$ read -ra sigs < <(set -o posix; kill -l)
$ for i in "${!sigs[@]}"; do [[ ${sigs[i++]} == PIPE ]] && break; done
$ echo "$i"
13

Link: https://bugs.gentoo.org/309001
Link: https://bugzilla.gnome.org/show_bug.cgi?id=613808#c9
See-also: 6a3cd41450a78422248f10e1272fdd529bd8bc98
See-also: 0ab6f83070c9a32a24454053319c99559c2654ca
Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/isolated-functions.sh  | 26 -
 bin/phase-functions.sh | 27 +++---
 bin/save-ebuild-env.sh |  4 ++--
 .../package/ebuild/_config/special_env_vars.py |  1 -
 lib/portage/package/ebuild/doebuild.py |  5 
 5 files changed, 15 insertions(+), 48 deletions(-)

diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index c6ce52928c..109c1cd9c6 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -29,32 +29,6 @@ assert() {
done
 }
 
-__assert_sigpipe_ok() {
-   # When extracting a tar file like this:
-   #
-   # bzip2 -dc foo.tar.bz2 | tar xof -
-   #
-   # For some tar files (see bug #309001), tar will
-   # close its stdin pipe when the decompressor still has
-   # remaining data to be written to its stdout pipe. This
-   # causes the decompressor to be killed by SIGPIPE. In
-   # this case, we want to ignore pipe writers killed by
-   # SIGPIPE, and trust the exit status of tar. We refer
-   # to the bash manual section "3.7.5 Exit Status"
-   # which says, "When a command terminates on a fatal
-   # signal whose number is N, Bash uses the value 128+N
-   # as the exit status."
-
-   local x pipestatus=${PIPESTATUS[*]}
-   for x in ${pipestatus} ; do
-   # Allow SIGPIPE through (128 + 13)
-   [[ ${x} -ne 0 && ${x} -ne ${PORTAGE_SIGPIPE_STATUS:-141} ]] && 
die "$@"
-   done
-
-   # Require normal success for the last process (tar).
-   [[ ${x} -eq 0 ]] || die "$@"
-}
-
 shopt -s extdebug
 
 # __dump_trace([number of funcs on stack to skip],

diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh
index 74771edf52..5c9f488a90 100644
--- a/bin/phase-functions.sh
+++ b/bin/phase-functions.sh
@@ -20,20 +20,19 @@ portage_readonly_vars=(
PORTAGE_EBUILD_EXIT_FILE PORTAGE_ECLASS_LOCATIONS
PORTAGE_EXPLICIT_INHERIT PORTAGE_OVERRIDE_EPREFIX
PORTAGE_BINPKG_TAR_OPTS PORTAGE_INTERNAL_CALLER PORTAGE_ACTUAL_DISTDIR
-   PORTAGE_BINPKG_TMPFILE PORTAGE_SIGPIPE_STATUS PORTAGE_XATTR_EXCLUDE
-   PORTAGE_REPOSITORIES PORTAGE_WORKDIR_MODE PORTAGE_BINPKG_FILE
-   PORTAGE_BUILD_GROUP PORTAGE_DEPCACHEDIR PM_EBUILD_HOOK_DIR
-   PORTAGE_BUILD_USER PORTAGE_CONFIGROOT PORTAGE_IPC_DAEMON
-   PORTAGE_PROPERTIES PORTAGE_PYTHONPATH PORTAGE_UPDATE_ENV
-   PORTAGE_REPO_NAME PORTAGE_ARCHLIST PORTAGE_BIN_PATH PORTAGE_BUILDDIR
-   PORTAGE_COLORMAP PORTAGE_INST_GID PORTAGE_INST_UID PORTAGE_LOG_FILE
-   PORTAGE_PYM_PATH PORTAGE_RESTRICT PORTAGE_USERNAME PORTAGE_GRPNAME
-   PORTAGE_VERBOSE PORTAGE_BASHRC PORTAGE_PYTHON PORTAGE_TMPDIR
-   PORTAGE_DEBUG PORTAGE_IUSE PORTAGE_GID REPLACED_BY_VERSION
-   REPLACING_VERSIONS T WORKDIR __PORTAGE_TEST_HARDLINK_LOCKS
-   __PORTAGE_HELPER portage_mutable_filtered_vars
-   portage_saved_readonly_vars portage_readonly_metadata
-   portage_r

[gentoo-commits] proj/portage:master commit in: bin/

2025-07-22 Thread Sam James
commit: 1df2556c3aeebc64f64c5e6a2f92d9f4a68eb9da
Author: Kerin Millar  plushkava  net>
AuthorDate: Tue Jul 15 16:09:50 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jul 22 22:28:40 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=1df2556c

save-ebuild-env.sh: filter out variables that can influence coreutils

As of the time of writing, there are 18 variables that may influence the
behaviour of the utilities comprising the GNU coreutils project. Ensure
that they are filtered out by the __save_ebuild_env() function. Some,
such as 'HOME' and 'TMPDIR', continue to be specified elsewhere. Such is
harmless. I would sooner be thorough in the course of listing variables
that can be directly attributed to a given source.

Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/save-ebuild-env.sh | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
index 480854ad84..b71de06ed1 100644
--- a/bin/save-ebuild-env.sh
+++ b/bin/save-ebuild-env.sh
@@ -38,9 +38,14 @@ __save_ebuild_env() (
fi
 
REPLY+=(
+   # variables that can influence the behaviour of GNU coreutils
+   BLOCK_SIZE COLORTERM COLUMNS DF_BLOCK_SIZE DU_BLOCK_SIZE HOME
+   LS_BLOCK_SIZE LS_COLORS POSIXLY_CORRECT PATH PWD QUOTING_STYLE
+   SHELL TIME_STYLE TABSIZE TMPDIR TERM TZ
+
# misc variables inherited from the calling environment
-   COLORTERM DISPLAY EDITOR LS_COLORS LESSOPEN LOGNAME LESS PAGER
-   TERMCAP TERM USER ftp_proxy https_proxy http_proxy no_proxy
+   DISPLAY EDITOR LESSOPEN LOGNAME LESS PAGER TERMCAP USER
+   ftp_proxy https_proxy http_proxy no_proxy
 
# other variables inherited from the calling environment
CVS_RSH ECHANGELOG_USER GPG_AGENT_INFO SSH_AGENT_PID



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-22 Thread Sam James
commit: 46ac22cc29505fa573e4266e9f28aba10b271019
Author: Kerin Millar  plushkava  net>
AuthorDate: Tue Jul 15 00:58:41 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jul 22 22:28:39 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=46ac22cc

save-ebuild-env.sh: filter out the patch() function

The patch() function was added to the "phase-helpers.sh" unit by the
referenced commit. It serves as a wrapper for the gpatch binary, where
available. Ensure that it is filtered out by the __save_ebuild_env()
function.

See-also: 495d920b6c2dc735cde163ca58df7fafa6f76fae
Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/save-ebuild-env.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
index 6a305a71d4..480854ad84 100644
--- a/bin/save-ebuild-env.sh
+++ b/bin/save-ebuild-env.sh
@@ -121,7 +121,7 @@ __save_ebuild_env() (
___eapi_has_eapply_user && REPLY+=( __readdir eapply_user )
___eapi_has_get_libdir && REPLY+=( get_libdir )
___eapi_has_in_iuse && REPLY+=( in_iuse )
-   ___eapi_has_eapply && REPLY+=( eapply )
+   ___eapi_has_eapply && REPLY+=( eapply patch )
___eapi_has_usex && REPLY+=( usex )
 
# Destroy the collected functions.



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-22 Thread Sam James
commit: d04859f632112e7995ed3cf8327252f961c480b8
Author: Kerin Millar  plushkava  net>
AuthorDate: Tue Jul 15 01:02:37 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jul 22 22:28:39 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=d04859f6

save-ebuild-env.sh: filter out the __compose_bzip2() function

The __compose_bzip2() function was added to the "phase-helpers.sh" unit
by the referenced commit. Ensure that it is filtered out by the
__save_ebuild_env() function.

See-also: 1b20070166fdb08b28bebd7db66171329f760f77
Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/save-ebuild-env.sh | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
index 473addc23d..6a305a71d4 100644
--- a/bin/save-ebuild-env.sh
+++ b/bin/save-ebuild-env.sh
@@ -81,10 +81,10 @@ __save_ebuild_env() (
 
__assert_sigpipe_ok __abort_configure __abort_compile
__abort_handler __abort_install __abort_prepare __abort_test
-   __check_bash_version __dyn_configure __dyn_compile
-   __dyn_install __dyn_prepare __dyn_pretend __dump_trace
-   __dyn_unpack __dyn_clean __dyn_setup __dyn_help __dyn_test
-   __ebuild_phase_with_hooks __eapi7_ver_compare_int
+   __check_bash_version __compose_bzip2_cmd __dyn_configure
+   __dyn_compile __dyn_install __dyn_prepare __dyn_pretend
+   __dump_trace __dyn_unpack __dyn_clean __dyn_setup __dyn_help
+   __dyn_test __ebuild_phase_with_hooks __eapi7_ver_compare_int
__eapi7_ver_parse_range __ebuild_arg_to_phase
__ebuild_phase_funcs __eapi7_ver_compare __eapi7_ver_split
__ebuild_phase __ebuild_main __elog_base __eqaquote __eqatag



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-22 Thread Sam James
commit: bd2a990e3a686882d418faf38e8bd4262f3c276b
Author: Kerin Millar  plushkava  net>
AuthorDate: Tue Jul 15 00:45:21 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jul 22 22:28:39 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=bd2a990e

save-ebuild-env.sh: filter out the __readdir() function

The __readdir() function was added to the "phase-helpers.sh"
unit by the referenced commit. Ensure that it is filtered out by the
__save_ebuild_env() function.

See-also: 4521e440ba1760165e6fae3b3ef2d0b7673689a0
Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/save-ebuild-env.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
index 03a9954ad7..473addc23d 100644
--- a/bin/save-ebuild-env.sh
+++ b/bin/save-ebuild-env.sh
@@ -118,9 +118,10 @@ __save_ebuild_env() (
 
___eapi_has_version_functions && REPLY+=( ver_test ver_cut ver_rs )
___eapi_has_einstalldocs && REPLY+=( einstalldocs )
+   ___eapi_has_eapply_user && REPLY+=( __readdir eapply_user )
___eapi_has_get_libdir && REPLY+=( get_libdir )
___eapi_has_in_iuse && REPLY+=( in_iuse )
-   ___eapi_has_eapply && REPLY+=( eapply_user eapply )
+   ___eapi_has_eapply && REPLY+=( eapply )
___eapi_has_usex && REPLY+=( usex )
 
# Destroy the collected functions.



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-22 Thread Sam James
commit: 46faf7d832ac91bb5b4cfd002be854f359a829db
Author: Kerin Millar  plushkava  net>
AuthorDate: Tue Jul 15 00:42:21 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jul 22 22:28:38 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=46faf7d8

save-ebuild-env.sh: filter out the find0() function

The find0() function was added to the "isolated-functions.sh" unit by
the referenced commit. Ensure that it is filtered out by the
__save_ebuild_env() function.

See-also: a0210b3c49ea346b1e999f92a7ed89802e8d6849
Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/save-ebuild-env.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
index 0050f3d0de..03a9954ad7 100644
--- a/bin/save-ebuild-env.sh
+++ b/bin/save-ebuild-env.sh
@@ -100,8 +100,8 @@ __save_ebuild_env() (
contains_word debug-print-function debug-print-section
debug-print docompress default diropts docinto dostrip die
einstall eqawarn exeinto exeopts ebegin eerror einfon econf
-   einfo ewarn eend elog get_KV has_version hasq hasv has inherit
-   insinto insopts into libopts nonfatal portageq
+   einfo ewarn eend elog find0 get_KV has_version hasq hasv has
+   inherit insinto insopts into libopts nonfatal portageq
register_success_hook register_die_hook use_enable use_with
unpack useq usev use
 



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-22 Thread Sam James
commit: fd01f441afa9053cdbbf47252255d19693d299c9
Author: Kerin Millar  plushkava  net>
AuthorDate: Tue Jul 15 00:17:13 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jul 22 22:28:37 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=fd01f441

save-ebuild-env.sh: refactor the __save_ebuild_env() function

The "save-ebuild-env.sh" unit implements a function by the name of
__save_ebuild_env(), the purpose of which is to dump a subset of the
functions and variables that belong to the current shell's operating
environment. The resulting declarations are used to populate the
"environment.bz2" files that are a component of Portage's internal
database, known as the VDB. This function suffers from several minor
issues, which are described and addressed herewith.

The function calls upon the has() function to determine whether the
--exclude-init-phases option has been specified. However, it expands the
positional parameters as $*, potentially resulting in word splitting and
unwanted pathname expansion. Address this issue by properly expanding
them as "$@", duly rectifying instances of SC2048 and SC2086.

The function consists of 18 invocations of the unset builtin, some of
which are given a large number of parameters. These are neither sorted
nor wrapped in a consistent manner. Further, quoted  characters
are used as a line continuation device, rendering some of the commands
unpleasant to read and difficult to rearrange. Address these issues in a
manner twofold. Firstly, by purposing the REPLY variable as an array
that is used to contain the parameters, thereby allowing for the
arbitrary use of whitespace to separate each. Secondly, by using a
specialised sorting algorithm - described by one of the referenced
commits - to reorder the elements, while rewrapping to 80 columns.

The unset builtin is presently invoked without options. Consequently, it
shall consider each operand as the name of a variable to be unset. In
the event that no variable by the given name exists, it shall instead
attempt to destroy a function by that name. Address this issue by always
specifying the -v option in the case that variables are to be unset, and
the -f option in the case that functions are to be destroyed.

See-also: 93275ac104ad6999f9c4551ceb150c047fca1979
See-also: 44cc0ab2caf13a18cbb99580b91a8afe61ce9cc4
Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/save-ebuild-env.sh | 188 +
 1 file changed, 97 insertions(+), 91 deletions(-)

diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
index a162334374..233e4b6e85 100644
--- a/bin/save-ebuild-env.sh
+++ b/bin/save-ebuild-env.sh
@@ -11,113 +11,119 @@
 # or removal of the packages, and can therefore be safely excluded.
 #
 __save_ebuild_env() (
-   if has --exclude-init-phases $* ; then
-   unset S __E_DESTTREE __E_INSDESTTREE __E_DOCDESTTREE 
__E_EXEDESTTREE \
-   PORTAGE_DOCOMPRESS_SIZE_LIMIT PORTAGE_DOCOMPRESS \
-   PORTAGE_DOCOMPRESS_SKIP PORTAGE_DOSTRIP 
PORTAGE_DOSTRIP_SKIP
+   # REPLY is purposed as an array that undergoes two phases of assembly.
+   # The first entails gathering the names of variables that are to be
+   # unset. The second entails gathering the names of functions that are
+   # to be unset. The REPLY variable is eventually unset in its own right.
+   REPLY=()
+
+   if has --exclude-init-phases "$@"; then
+   REPLY+=(
+   PORTAGE_DOCOMPRESS_SIZE_LIMIT PORTAGE_DOCOMPRESS_SKIP
+   PORTAGE_DOSTRIP_SKIP PORTAGE_DOCOMPRESS PORTAGE_DOSTRIP
+   S __E_DOCDESTTREE __E_EXEDESTTREE __E_INSDESTTREE
+   __E_DESTTREE
+
+   # Discard stale GNU Make POSIX Jobserver flags.
+   MAKEFLAGS
+   )
if [[ -n ${PYTHONPATH} &&
${PYTHONPATH%%:*} -ef ${PORTAGE_PYM_PATH} ]] ; then
if [[ ${PYTHONPATH} == *:* ]] ; then
export PYTHONPATH=${PYTHONPATH#*:}
else
-   unset PYTHONPATH
+   REPLY+=( PYTHONPATH )
fi
fi
-
-   # Discard stale GNU Make POSIX Jobserver flags.
-   unset MAKEFLAGS
fi
 
-   # misc variables inherited from the calling environment
-   unset COLORTERM DISPLAY EDITOR LESS LESSOPEN LOGNAME LS_COLORS PAGER \
-   TERM TERMCAP USER ftp_proxy http_proxy https_proxy no_proxy
+   REPLY+=(
+   # misc variables inherited from the calling environment
+   COLORTERM DISPLAY EDITOR LS_COLORS LESSOPEN LOGNAME LESS PAGER
+   TERMCAP TERM USER ftp_proxy https_proxy http_proxy no_proxy
 
-   # other variables inherited from the 

[gentoo-commits] proj/portage:master commit in: bin/

2025-07-22 Thread Sam James
commit: 929567bd3d085f454070f33cbac29d2cfc747f74
Author: Kerin Millar  plushkava  net>
AuthorDate: Tue Jul 15 00:39:58 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jul 22 22:28:38 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=929567bd

save-ebuild-env.sh: filter out the contains_word() function

The contains_word() function was added to the "isolated-functions.sh"
unit by the referenced commit. Ensure that it is filtered out by the
__save_ebuild_env() function.

See-also: 4a4631eef7186c29668a8c049d988b61469940fd
Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/save-ebuild-env.sh | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
index 233e4b6e85..0050f3d0de 100644
--- a/bin/save-ebuild-env.sh
+++ b/bin/save-ebuild-env.sh
@@ -97,12 +97,13 @@ __save_ebuild_env() (
__unpack_tar __vecho
 
addpredict addwrite adddeny addread assert best_version
-   debug-print-function debug-print-section debug-print docompress
-   default diropts docinto dostrip die einstall eqawarn exeinto
-   exeopts ebegin eerror einfon econf einfo ewarn eend elog get_KV
-   has_version hasq hasv has inherit insinto insopts into libopts
-   nonfatal portageq register_success_hook register_die_hook
-   use_enable use_with unpack useq usev use
+   contains_word debug-print-function debug-print-section
+   debug-print docompress default diropts docinto dostrip die
+   einstall eqawarn exeinto exeopts ebegin eerror einfon econf
+   einfo ewarn eend elog get_KV has_version hasq hasv has inherit
+   insinto insopts into libopts nonfatal portageq
+   register_success_hook register_die_hook use_enable use_with
+   unpack useq usev use
 
# Defined by the "ebuild.sh" utility.
${QA_INTERCEPTORS}



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-22 Thread Sam James
commit: 93275ac104ad6999f9c4551ceb150c047fca1979
Author: Kerin Millar  plushkava  net>
AuthorDate: Sat Jul 12 04:53:01 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jul 22 22:25:40 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=93275ac1

phase-functions.sh: reorder hard-coded array elements to optimise for legibility

Presently, the "phase-functions.sh" unit defines the following four
array variables in the global scope.

- PORTAGE_MUTABLE_FILTERED_VARS
- PORTAGE_SAVED_READONLY_VARS
- PORTAGE_READONLY_METADATA
- PORTAGE_READONLY_VARS

It also defines the following three array variables as local to the
__filter_readonly_variables() function.

- binpkg_untrusted_vars
- filtered_sandbox_vars
- bash_vars

The elements contained by all of these arrays are hard-coded and are
presented in ascending lexicographical order. However, I have found that
sequences of identifiers can be rendered more legible by being in
descending order of length. At the same time, maintaining an
alphabetical order makes it easier to identify a particular element
while perusing longer sequences. With both of these considerations in
mind, I devised a simple algorithm that sorts in a manner threefold:

1) by ascending lexicographical order of that which matches ^_*[[:alpha:]]
2) by descending order or element length, in characters
3) by asending lexicographical order

I found the results to be quite satisfactory. As such, this commit
reorders the elements of the aforementioned array variables in
accordance with this algorithm. The improvement in legibility is most
notable in the case of the 'portage_readonly_vars' variable. For
reference, a perl implementation of this algorithm is shown beneath.

#!/usr/bin/perl
while (readline *STDIN) {
push @words, m/\S+/g;
}
@words = sort {
($c1, $c2) = map { m/^(_*\p{PosixAlpha})/ ? $1 : '' } $a, $b;
$c1 cmp $c2 || length $b <=> length $a || $a cmp $b;
} @words;
print "@words\n";

Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/phase-functions.sh | 74 +-
 1 file changed, 37 insertions(+), 37 deletions(-)

diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh
index ed64024da5..d2de289996 100644
--- a/bin/phase-functions.sh
+++ b/bin/phase-functions.sh
@@ -9,35 +9,35 @@
 # when portage is upgrading itself.
 
 portage_readonly_metadata=(
-   BDEPEND DEFINED_PHASES DEPEND DESCRIPTION EAPI HOMEPAGE IDEPEND
-   INHERITED IUSE REQUIRED_USE KEYWORDS LICENSE PDEPEND RDEPEND REPOSITORY
-   RESTRICT SLOT SRC_URI
+   BDEPEND DEFINED_PHASES DESCRIPTION DEPEND EAPI HOMEPAGE INHERITED
+   IDEPEND IUSE KEYWORDS LICENSE PDEPEND REQUIRED_USE REPOSITORY RESTRICT
+   RDEPEND SRC_URI SLOT
 )
 
 portage_readonly_vars=(
-   D EBUILD EBUILD_PHASE EBUILD_PHASE_FUNC EBUILD_SH_ARGS ED EMERGE_FROM
-   EROOT FILESDIR MERGE_TYPE PM_EBUILD_HOOK_DIR PORTAGE_ACTUAL_DISTDIR
-   PORTAGE_ARCHLIST PORTAGE_BASHRC PORTAGE_BINPKG_FILE
-   PORTAGE_BINPKG_TAR_OPTS PORTAGE_BINPKG_TMPFILE PORTAGE_BIN_PATH
-   PORTAGE_BUILDDIR PORTAGE_BUILD_GROUP PORTAGE_BUILD_USER
-   PORTAGE_COLORMAP PORTAGE_CONFIGROOT PORTAGE_DEBUG PORTAGE_DEPCACHEDIR
-   PORTAGE_EBUILD_EXIT_FILE PORTAGE_EBUILD_EXTRA_SOURCE
-   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_OVERRIDE_EPREFIX PORTAGE_PROPERTIES
-   PORTAGE_PYM_PATH PORTAGE_PYTHON PORTAGE_PYTHONPATH PORTAGE_REPO_NAME
-   PORTAGE_REPOSITORIES PORTAGE_RESTRICT PORTAGE_SIGPIPE_STATUS
-   PORTAGE_TMPDIR PORTAGE_UPDATE_ENV PORTAGE_USERNAME PORTAGE_VERBOSE
-   PORTAGE_WORKDIR_MODE PORTAGE_XATTR_EXCLUDE REPLACING_VERSIONS
-   REPLACED_BY_VERSION T WORKDIR __PORTAGE_HELPER
-   __PORTAGE_TEST_HARDLINK_LOCKS portage_mutable_filtered_vars
+   D EBUILD_PHASE_FUNC EBUILD_SH_ARGS EBUILD_PHASE EMERGE_FROM EBUILD
+   EROOT ED FILESDIR MERGE_TYPE PORTAGE_EBUILD_EXTRA_SOURCE
+   PORTAGE_EBUILD_EXIT_FILE PORTAGE_ECLASS_LOCATIONS
+   PORTAGE_EXPLICIT_INHERIT PORTAGE_OVERRIDE_EPREFIX
+   PORTAGE_BINPKG_TAR_OPTS PORTAGE_INTERNAL_CALLER PORTAGE_ACTUAL_DISTDIR
+   PORTAGE_BINPKG_TMPFILE PORTAGE_SIGPIPE_STATUS PORTAGE_XATTR_EXCLUDE
+   PORTAGE_REPOSITORIES PORTAGE_WORKDIR_MODE PORTAGE_BINPKG_FILE
+   PORTAGE_BUILD_GROUP PORTAGE_DEPCACHEDIR PM_EBUILD_HOOK_DIR
+   PORTAGE_BUILD_USER PORTAGE_CONFIGROOT PORTAGE_IPC_DAEMON
+   PORTAGE_PROPERTIES PORTAGE_PYTHONPATH PORTAGE_UPDATE_ENV
+   PORTAGE_REPO_NAME PORTAGE_ARCHLIST PORTAGE_BIN_PATH PORTAGE_BUILDDIR
+   PORTAGE_COLORMAP PORTAGE_INST_GID PORTAGE_INST_UID PORTAGE_LOG_FILE
+   PORTAGE_PYM_PATH PORTAGE_RESTRICT PORTAGE_USERNAME PORTAGE_GRPNAME
+   PORTAGE_VERBOSE PORTAGE_BASHRC PORTAGE_PYTHON PORTAGE_TMPDIR
+   PORTA

[gentoo-commits] proj/portage:master commit in: bin/

2025-07-22 Thread Sam James
commit: 03fca8121a03ef8b5f859a8aeef76b921a83ea15
Author: Kerin Millar  plushkava  net>
AuthorDate: Sun Jul 13 23:28:58 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jul 22 22:25:40 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=03fca812

phase-functions.sh: drop the 
{binpkg_untrusted,filtered_sandbox,misc_garbage}_vars variables

As concerns the __filter_readonly_variables() function, it defines three
local array variables whose elements undergo no modification after
having been declared.

- binpkg_untrusted_vars
- filtered_sandbox_vars
- misc_garbage_vars

They do nothing whatsoever to improve the legibility of the function at
large. Jettison these variables.

Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/phase-functions.sh | 26 ++
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh
index d2de289996..74771edf52 100644
--- a/bin/phase-functions.sh
+++ b/bin/phase-functions.sh
@@ -87,7 +87,7 @@ portage_mutable_filtered_vars=( AA HOSTNAME )
 # is to preserve various variables as they were at the time that the binary
 # package was built while protecting against the application of package 
renames.
 __filter_readonly_variables() {
-   local -a {binpkg_untrusted,filtered_sandbox,misc_garbage,bash}_vars
+   local -a filtered_vars bash_vars
local IFS
 
# Collect an initial list of special bash variables by instructing a
@@ -115,20 +115,9 @@ __filter_readonly_variables() {
# Exported functions bear this prefix.
"BASH_FUNC_.*"
)
-   filtered_sandbox_vars=(
-   SANDBOX_DEBUG_LOG SANDBOX_DISABLED SANDBOX_ACTIVE
-   SANDBOX_BASHRC SANDBOX_LIB SANDBOX_LOG SANDBOX_ON
-   )
-   # Untrusted due to possible application of package renames to binpkgs
-   binpkg_untrusted_vars=(
-   CATEGORY PVR PF PN PR PV P
-   )
-   misc_garbage_vars=(
-   _portage_filter_opts
-   )
filtered_vars+=(
"${portage_readonly_vars[@]}"
-   "${misc_garbage_vars[@]}"
+   _portage_filter_opts
"${bash_vars[@]}"
"___.*"
)
@@ -155,7 +144,10 @@ __filter_readonly_variables() {
if has --filter-sandbox "$@"; then
filtered_vars+=( "SANDBOX_.*" )
else
-   filtered_vars+=( "${filtered_sandbox_vars[@]}" )
+   filtered_vars+=(
+   SANDBOX_DEBUG_LOG SANDBOX_DISABLED SANDBOX_ACTIVE
+   SANDBOX_BASHRC SANDBOX_LIB SANDBOX_LOG SANDBOX_ON
+   )
fi
if has --filter-features "$@"; then
filtered_vars+=( FEATURES PORTAGE_FEATURES )
@@ -173,9 +165,11 @@ __filter_readonly_variables() {
:
elif [[ "${EMERGE_FROM}" = binary ]]; then
# Preserve additional variables from build time, while
-   # excluding untrusted variables.
-   filtered_vars+=( "${binpkg_untrusted_vars[@]}" )
+   # excluding some variables that are untrusted, due to the
+   # possible application of package renames to binpkgs.
+   filtered_vars+=( CATEGORY PVR PF PN PR PV P )
else
+   # Allow for the option to have its full effect.
filtered_vars+=(
"${portage_mutable_filtered_vars[@]}"
"${portage_saved_readonly_vars[@]}"



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-22 Thread Sam James
commit: 93b5c17d2efab24c9535a563986aa757a4cc830b
Author: Kerin Millar  plushkava  net>
AuthorDate: Sat Jul 12 03:58:21 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jul 22 22:25:39 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=93b5c17d

Define four variables in the PORTAGE_ namespace as lowercase arrays

Presently, the "phase-functions.sh" unit defines the following four
scalar variables.

- PORTAGE_MUTABLE_FILTERED_VARS
- PORTAGE_SAVED_READONLY_VARS
- PORTAGE_READONLY_METADATA
- PORTAGE_READONLY_VARS

Their values are comprised by a whitespace-separated list of variable
names, which are referenced in as many as two ways. Firstly, by the
__filter_readonly_variables() function as the names of variables that
are to be filtered. Secondly, by the "ebuild.sh" utility as the names of
variables for which the readonly attribute should be set.

Given that none of these variables are used in any other capacity, and
that all are acting as mock-arrays, declare them as actual array
variables instead. That way, no word splitting need be performed, be it
with the aid of the read builtin or by way of an unquoted expansion. Two
instances of SC2086 are duly addressed.

Further, rename the variables so as to be in lower case. Given that it
is a widespread convention for environment variables to have names that
are entirely in upper case, this renders the provenance and purpose of
the variables clearer than would otherwise be the case. That is, none of
them are expected to:

- have been defined as an environment variable by the parent process
- be designated for exporting to subprocesses
- be referenced in any other capacity (such as by an ebuild or eclass)

Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/ebuild.sh  |  2 +-
 bin/phase-functions.sh | 72 ++
 2 files changed, 39 insertions(+), 35 deletions(-)

diff --git a/bin/ebuild.sh b/bin/ebuild.sh
index ff2527146d..6a12d65a7c 100755
--- a/bin/ebuild.sh
+++ b/bin/ebuild.sh
@@ -761,7 +761,7 @@ if [[ ${EBUILD_PHASE} = depend ]] ; then
 else
# Note: readonly variables interfere with __preprocess_ebuild_env(), so
# declare them only after it has already run.
-   declare -r ${PORTAGE_READONLY_METADATA} ${PORTAGE_READONLY_VARS}
+   declare -r "${portage_readonly_metadata[@]}" 
"${portage_readonly_vars[@]}"
if ___eapi_has_prefix_variables; then
declare -r ED EPREFIX EROOT
fi

diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh
index 58904cd80e..ed64024da5 100644
--- a/bin/phase-functions.sh
+++ b/bin/phase-functions.sh
@@ -8,40 +8,43 @@
 # of ebuild.sh will work for pkg_postinst, pkg_prerm, and pkg_postrm
 # when portage is upgrading itself.
 
-PORTAGE_READONLY_METADATA="BDEPEND DEFINED_PHASES DEPEND DESCRIPTION
-   EAPI HOMEPAGE IDEPEND INHERITED IUSE REQUIRED_USE KEYWORDS LICENSE
-   PDEPEND RDEPEND REPOSITORY RESTRICT SLOT SRC_URI"
-
-PORTAGE_READONLY_VARS="D EBUILD EBUILD_PHASE EBUILD_PHASE_FUNC \
-   EBUILD_SH_ARGS ED EMERGE_FROM EROOT FILESDIR MERGE_TYPE \
-   PM_EBUILD_HOOK_DIR \
-   PORTAGE_ACTUAL_DISTDIR PORTAGE_ARCHLIST PORTAGE_BASHRC  \
-   PORTAGE_BINPKG_FILE PORTAGE_BINPKG_TAR_OPTS PORTAGE_BINPKG_TMPFILE \
-   PORTAGE_BIN_PATH PORTAGE_BUILDDIR PORTAGE_BUILD_GROUP \
-   PORTAGE_BUILD_USER \
-   PORTAGE_COLORMAP PORTAGE_CONFIGROOT \
-   PORTAGE_DEBUG PORTAGE_DEPCACHEDIR PORTAGE_EBUILD_EXIT_FILE \
-   PORTAGE_EBUILD_EXTRA_SOURCE \
-   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 \
-   PORTAGE_PYM_PATH PORTAGE_PYTHON PORTAGE_PYTHONPATH \
-   PORTAGE_READONLY_METADATA PORTAGE_READONLY_VARS \
-   PORTAGE_REPO_NAME PORTAGE_REPOSITORIES PORTAGE_RESTRICT \
-   PORTAGE_SAVED_READONLY_VARS PORTAGE_SIGPIPE_STATUS \
-   PORTAGE_TMPDIR PORTAGE_UPDATE_ENV PORTAGE_USERNAME \
-   PORTAGE_VERBOSE PORTAGE_WORKDIR_MODE PORTAGE_XATTR_EXCLUDE \
-   REPLACING_VERSIONS REPLACED_BY_VERSION T WORKDIR \
-   __PORTAGE_HELPER __PORTAGE_TEST_HARDLINK_LOCKS"
-
-PORTAGE_SAVED_READONLY_VARS="A CATEGORY P PF PN PR PV PVR"
+portage_readonly_metadata=(
+   BDEPEND DEFINED_PHASES DEPEND DESCRIPTION EAPI HOMEPAGE IDEPEND
+   INHERITED IUSE REQUIRED_USE KEYWORDS LICENSE PDEPEND RDEPEND REPOSITORY
+   RESTRICT SLOT SRC_URI
+)
+
+portage_readonly_vars=(
+   D EBUILD EBUILD_PHASE EBUILD_PHASE_FUNC EBUILD_SH_ARGS ED EMERGE_FROM
+   EROOT FILESDIR MERGE_TYPE PM_EBUILD_HOOK_DIR PORTAGE_ACTUAL_DISTDIR
+   PORTAGE_ARCHLIST PORTAGE_BASHRC PORTAGE_BINPKG_FILE
+   PORTAGE_BINPKG_TAR_OPTS PORTAGE_BINPKG_TMPFILE PORTAGE_BIN_PATH
+   PORTAGE_BUILDDIR PORTAG

[gentoo-commits] proj/portage:master commit in: bin/

2025-07-22 Thread Sam James
commit: f3c551f237c822e4072fd56816577a3bdba6fa41
Author: Kerin Millar  plushkava  net>
AuthorDate: Sun Jul 13 09:43:08 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jul 22 22:25:39 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=f3c551f2

phase-helpers.sh: decare local variables on single line in unpack()

So as to accord with the latterly prevailing coding style.

Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/phase-helpers.sh | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index 0759affb0b..609d763915 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -322,14 +322,8 @@ use_enable() {
 }
 
 unpack() {
-   local created_symlink
-   local suffix_known
+   local created_symlink suffix_known basename srcdir suffix f -
local -a bzip2_cmd
-   local basename
-   local srcdir
-   local suffix
-   local f
-   local -
 
if (( $# == 0 )); then
die "unpack: too few arguments (got 0; expected at least 1)"



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-22 Thread Sam James
commit: 4521e440ba1760165e6fae3b3ef2d0b7673689a0
Author: Kerin Millar  plushkava  net>
AuthorDate: Sun Jul 13 10:03:52 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jul 22 22:25:38 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=4521e440

phase-helpers.sh: have eapply_user() abort if a given patch dir can't be read

Presently, the eapply_user() function is responsible for applying
user-supplied patches for EAPIs that support this feature (6 or
greater). In order to collect the patches, it walks a set of pathnames
that may exist as directories relative to the "/etc/portage/patches"
directory. However, it is unable to handle various modes of failure.
Consider the following potential scenarios.

- the pathname cannot be opened as a directory e.g. due to EACCESS
- the pathname is something other than a directory
- the pathname is a dangling symlink

In each of these scenarios, portage raises no diagnostic messages, nor
does it abort. Consequently, patches that the user relies upon being
applied might not actually be applied. Further, patches that the user
relies upon being suppressed - by way of an overlapping patch of greater
specificity that is an empty regular file - might not actually be
suppressed. To make matters worse, it is possible for the user to be
initially unaware that anything is wrong, particularly if specifying the
--quiet-build and/or --jobs options to emerge(1). Further, upon
discovering that there is a problem, they may lack the skills required
to perform a rapid diagnosis, duly placing a support burden upon others.

Address this issue by collecting the patches in such a way that portage
is able to determine whether a given pathname exists and can be read as
a directory. To do so in bash is challenging because it cannot report
the error numbers of syscalls such as opendir(3) and readdir(3) after
attempting pathname expansion. This commit incorporates a new function
by the name of __readdir(). Given the ostensible pathname of a
directory, it tries to collect the names of its immediate entries into
an array variable named 'dirents'. It works on the basis that, for both
the . and .. entries to be encountered, it can be reasonably assumed
that the pathname was successfully opened and read as a directory.

Hence, the eapply_user() function now calls __readdir(). Should the
latter function return false, the former function will test whether the
pathname exists and, if it does, convey a meaningful diagnostic message
to the __helpers_die() function. The reason for using __helpers_die()
over die() is to ensure that the implementation continues to conform
with the following excerpt from the Package Manager Specification.

"Returns shell true (0) if patches applied successfully, or if no
patches were provided. Otherwise, aborts the build process, unless run
using nonfatal."

Consider the following test case, where a patch directory is created for
the sys-apps/pv package with an unduly restrictive mode.

# mkdir -p /etc/portage/patches/sys-apps/pv
# chmod 700 /etc/portage/patches/sys-apps/pv
# emerge pv

The resulting exception shall be as follows.

 * ERROR: sys-apps/pv-1.9.31::gentoo failed (prepare phase):
 *   eapply_user: '/etc/portage/patches/sys-apps/pv' exists but can't be
 opened as a directory by 'portage'

Bug: https://bugs.gentoo.org/634396
Link: https://projects.gentoo.org/pms/8/pms.html#x1-12700012.3.7
Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/phase-helpers.sh | 39 ++-
 1 file changed, 38 insertions(+), 1 deletion(-)

diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index 5811a90658..0759affb0b 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -1062,9 +1062,42 @@ if ___eapi_has_eapply; then
 fi
 
 if ___eapi_has_eapply_user; then
+   # Considers the first operand as a directory pathname and attempts to
+   # read its immediate entries into an array variable named 'dirents'. If
+   # the operand is unspecified or empty, the current working directory
+   # shall be read. The array indices might not begin from 0, and might
+   # not be contiguous. If both the . and .. entries are seen, the return
+   # value shall be 0. Otherwise, it shall be greater than 0.
+   __readdir() {
+   local path=$1
+   local reset_shopts count i
+
+   # The globskipdots option was introduced by bash-5.2. Unless
+   # disabled, it prevents the matching of the . and .. entries.
+   reset_shopts=$(
+   shopt -p globskipdots 2>/dev/null
+   shopt -p nullglob extglob
+   )
+   [[ ${reset_shopts} == *globskipdots* ]] && shopt -u globskipdots
+   shopt -s nullglob extglob
+   [[ ${path} && ${path} != */ ]] && path+=/
+   eval 'dirents=( "${path}"@(.?(.)|*) );' "${reset_shopts}"
+
+

[gentoo-commits] proj/portage:master commit in: bin/

2025-07-22 Thread Sam James
commit: 6f3c0cb3cc826f355b34dafcbfee345f344f28ea
Author: Kerin Millar  plushkava  net>
AuthorDate: Sun Jul 13 09:48:04 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jul 22 22:25:38 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=6f3c0cb3

phase-helpers.sh: hoist locals to the top of eapply_user()

Local variables are not lexically scoped in bash and it has been my
experience that declaring them up-front can help to identify undue
complexity. Do so for the eapply_user() function.

Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/phase-helpers.sh | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index fef77e52d7..5811a90658 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -1063,23 +1063,23 @@ fi
 
 if ___eapi_has_eapply_user; then
eapply_user() {
+   local basename basedir columns tagfile hr d f
+   local -A patch_by
+
[[ ${EBUILD_PHASE} == prepare ]] || \
die "eapply_user() called during invalid phase: 
${EBUILD_PHASE}"
 
# Keep path in __dyn_prepare in sync!
-   local tagfile=${T}/.portage_user_patches_applied
+   tagfile=${T}/.portage_user_patches_applied
[[ -f ${tagfile} ]] && return
>> "${tagfile}"
 
-   local basedir=${PORTAGE_CONFIGROOT%/}/etc/portage/patches
+   basedir=${PORTAGE_CONFIGROOT%/}/etc/portage/patches
 
-   local columns=${COLUMNS:-0}
+   columns=${COLUMNS:-0}
[[ ${columns} == 0 ]] && columns=$(set -- $( ( stty size 
/dev/null || echo 24 80 ) ; echo $2)
(( columns > 0 )) || (( columns = 80 ))
 
-   local -A patch_by
-   local d f basename hr
-
# Patches from all matched directories are combined into a
# sorted (POSIX order) list of the patch basenames. Patches
# in more-specific directories override patches of the same



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-12 Thread Sam James
commit: 23ce89c761c080e7d3163165dded94241a9a9eea
Author: Kerin Millar  plushkava  net>
AuthorDate: Sat Jul  5 21:06:29 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Sun Jul 13 04:19:02 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=23ce89c7

emerge-webrsync: support bsdtar

Presently, emerge-webrsync is incompatible with bsdtar(1) because the
get_snapshot_timestamp() function specifies the --wildcards option.

Address this issue by only specifying this option in the case that the
tar(1) implementation is found to be that of GNU. The BSD implementation
always treats its operands as globs, provided that either the -t or -x
option has been specified.

It should be noted that this renders emerge-webrsync compatible with the
native tar(1) implementations of macOS, FreeBSD and NetBSD, but not
those of OpenBSD, MirBSD and Solaris. This matters little because the
Gentoo Prefix installation script bootstraps GNU tar. Nonetheless, there
is no harm in improving upon the portability of emerge-webrsync.

Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/emerge-webrsync | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/bin/emerge-webrsync b/bin/emerge-webrsync
index 8eb8546aa6..6f32a484ae 100755
--- a/bin/emerge-webrsync
+++ b/bin/emerge-webrsync
@@ -370,9 +370,13 @@ check_file_signature() {
 
 get_snapshot_timestamp() {
local file=$1
-   local unixtime
+   local unixtime is_gnu
 
-   tar --wildcards -O -xf "${file}" '*/metadata/timestamp.x' |
+   if tar --version 2>/dev/null | grep -q 'GNU tar'; then
+   is_gnu=1
+   fi
+
+   tar ${is_gnu+--wildcards} -O -xf "${file}" '*/metadata/timestamp.x' |
{
read -r unixtime _ \
&& is_uint "${unixtime}" \



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-12 Thread Sam James
commit: 44cc0ab2caf13a18cbb99580b91a8afe61ce9cc4
Author: Kerin Millar  plushkava  net>
AuthorDate: Tue Jul  8 01:07:33 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Sun Jul 13 04:19:06 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=44cc0ab2

save-ebuild-env.sh: clear triple-underscore namespace just before printing 
declarations

Presently, the __save_ebuild_env() function contains a routine that is
responsible for unsetting functions and variables whose names lead with
three consecutive underscores. Reposition this routine so that it
immediately precedes the invocations of the declare builtin that
conclude the function. This is to support an impending refactoring.

Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/save-ebuild-env.sh | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
index 5d5d25bbd7..a162334374 100644
--- a/bin/save-ebuild-env.sh
+++ b/bin/save-ebuild-env.sh
@@ -90,14 +90,6 @@ __save_ebuild_env() (
___eapi_has_in_iuse && unset -f in_iuse
___eapi_has_version_functions && unset -f ver_cut ver_rs ver_test
 
-   # Clear out the triple underscore namespace as it is reserved by the PM.
-   while IFS=' ' read -r _ _ REPLY; do
-   if [[ ${REPLY} == ___* ]]; then
-   unset -f "${REPLY}"
-   fi
-   done < <(declare -F)
-   unset -v REPLY "${!___@}"
-
# portage config variables and variables set directly by portage
unset ACCEPT_LICENSE BUILD_PREFIX COLS \
DISTDIR DOC_SYMLINKS_DIR \
@@ -127,6 +119,14 @@ __save_ebuild_env() (
# user config variables
unset DOC_SYMLINKS_DIR INSTALL_MASK PKG_INSTALL_MASK
 
+   # Clear out the triple underscore namespace as it is reserved by the PM.
+   while IFS=' ' read -r _ _ REPLY; do
+   if [[ ${REPLY} == ___* ]]; then
+   unset -f "${REPLY}"
+   fi
+   done < <(declare -F)
+   unset -v REPLY "${!___@}"
+
declare -p
declare -fp
 )



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-12 Thread Sam James
commit: b381d3533901b03ca50329d020c51c82757cdb5e
Author: Kerin Millar  plushkava  net>
AuthorDate: Sat Jul  5 22:23:07 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Sun Jul 13 04:19:04 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=b381d353

estrip: avoid repeated PATH searches for getfattr(1) and stat(1)

Presently, both get_node_number() and dump_xattrs() are implemented as
self-redeclaring functions, with the former testing whether the value of
the 'USERLAND' portage variable is "BSD", and the latter testing whether
getfattr(1) exists as a command.

However, given that both of these functions are called from within
command substitutions, they will perform their respective tests - and
redeclare themselves - on each and every occasion that they are called.
Further, repeated PATH searches will be performed for getfattr(1) and
stat(1); partly because the cache employed for Command Search and
Execution ends up being populated only after bash has forked, but also
because the cache can only contain positive entries (found paths by
utility name), not negative entries (unfound paths by utility name).

Though a minor issue, address it by declaring both functions only once,
at the point that the estrip script is initially parsed. Likewise for
the restore_attrs() function, so as to maintain a consistent style.

Fixes: e7c98eccdac4dc1e5a7de9e4048a37ea3756327d
Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/estrip | 74 ++
 1 file changed, 31 insertions(+), 43 deletions(-)

diff --git a/bin/estrip b/bin/estrip
index 67ceb4974f..3b2e4dfc62 100755
--- a/bin/estrip
+++ b/bin/estrip
@@ -277,51 +277,39 @@ process_ar() {
fi
 }
 
-get_inode_number() {
-   if  [[ ${USERLAND} == BSD ]]; then
-   get_inode_number() {
-   stat -f '%i' "$1"
-   }
-   else
-   get_inode_number() {
-   stat -c '%i' "$1"
-   }
-   fi
-
-   get_inode_number "$@"
-}
-
-dump_xattrs() {
-   if hash getfattr 2>/dev/null; then
-   dump_xattrs() {
-   getfattr -d -m - --absolute-names "$1"
-   }
-   else
-   dump_xattrs() {
-   PYTHONPATH=${PORTAGE_PYTHONPATH:-${PORTAGE_PYM_PATH}} \
-   "${PORTAGE_PYTHON:-/usr/bin/python}" \
-   "${PORTAGE_BIN_PATH}/xattr-helper.py" --dump < <(echo 
-n "$1")
-   }
-   fi
-
-   dump_xattrs "$@"
-}
+if  [[ ${USERLAND} == BSD ]]; then
+   get_inode_number() {
+   stat -f '%i' "$1"
+   }
+else
+   get_inode_number() {
+   stat -c '%i' "$1"
+   }
+fi
 
-restore_xattrs() {
-   if hash setfattr 2>/dev/null; then
-   restore_xattrs() {
-   setfattr --restore=-
-   }
-   else
-   restore_xattrs() {
-   PYTHONPATH=${PORTAGE_PYTHONPATH:-${PORTAGE_PYM_PATH}} \
-   "${PORTAGE_PYTHON:-/usr/bin/python}" \
-   "${PORTAGE_BIN_PATH}/xattr-helper.py" --restore
-   }
-   fi
+if hash getfattr 2>/dev/null; then
+   dump_xattrs() {
+   getfattr -d -m - --absolute-names "$1"
+   }
+else
+   dump_xattrs() {
+   PYTHONPATH=${PORTAGE_PYTHONPATH:-${PORTAGE_PYM_PATH}} \
+   "${PORTAGE_PYTHON:-/usr/bin/python}" \
+   "${PORTAGE_BIN_PATH}/xattr-helper.py" --dump < <(echo -n "$1")
+   }
+fi
 
-   restore_xattrs "$@"
-}
+if hash setfattr 2>/dev/null; then
+   restore_xattrs() {
+   setfattr --restore=-
+   }
+else
+   restore_xattrs() {
+   PYTHONPATH=${PORTAGE_PYTHONPATH:-${PORTAGE_PYM_PATH}} \
+   "${PORTAGE_PYTHON:-/usr/bin/python}" \
+   "${PORTAGE_BIN_PATH}/xattr-helper.py" --restore
+   }
+fi
 
 do_ignore() {
local -a skip_dirs



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-12 Thread Sam James
commit: 1262f1a722ef2501594736e4de69e8981ebb631c
Author: Kerin Millar  plushkava  net>
AuthorDate: Sun Jul  6 16:49:03 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Sun Jul 13 04:19:04 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=1262f1a7

phase-functions.sh: filter BASH_TRAPSIG in __filter_readonly_variables()

I spotted the new 'BASH_TRAPSIG' variable while comparing the manuals of
the 5.2 and 5.3 releases. Given that it is normally only visible from
within a trap handler, add it to the blacklist defined by the
__filter_readonly_variables() function.

See-also: 8a607ed23beb4995627f9c4e2c7580469ace56bb
Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/phase-functions.sh | 21 +++--
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh
index fd3c18b28d..afe28c613f 100644
--- a/bin/phase-functions.sh
+++ b/bin/phase-functions.sh
@@ -92,18 +92,19 @@ __filter_readonly_variables() {
| grep -vx PATH
)
# Incorporate other variables that are known to either be set by or be
-   # able to influence bash. This list was last updated for bash-5.3-rc2.
+   # able to influence bash. This list was last updated for bash-5.3.
bash_vars+=(
BASH_COMPAT BASH_ENV BASH_LOADABLES_PATH BASH_REMATCH
-   BASH_XTRACEFD CDPATH CHILD_MAX COLUMNS COMPREPLY COMP_CWORD
-   COMP_KEY COMP_LINE COMP_POINT COMP_TYPE COMP_WORDS COPROC
-   ENV EXECIGNORE FCEDIT FIGNORE FUNCNAME FUNCNEST GLOBIGNORE
-   GLOBSORT HISTCONTROL HISTFILE HISTFILESIZE HISTIGNORE HISTSIZE
-   HISTTIMEFORMAT HOME HOSTFILE IGNOREEOF INPUTRC INSIDE_EMACS
-   LINES MAIL MAILCHECK MAILPATH MAPFILE OLDPWD OPTARG PIPESTATUS
-   POSIXLY_CORRECT PROMPT_COMMAND PROMPT_DIRTRIM PS0 PS1 PS2 PS3
-   READLINE_ARGUMENT READLINE_LINE READLINE_MARK READLINE_POINT
-   REPLY TIMEFORMAT TMOUT TMPDIR auto_resume histchars
+   BASH_TRAPSIG BASH_XTRACEFD CDPATH CHILD_MAX COLUMNS COMPREPLY
+   COMP_CWORD COMP_KEY COMP_LINE COMP_POINT COMP_TYPE COMP_WORDS
+   COPROC ENV EXECIGNORE FCEDIT FIGNORE FUNCNAME FUNCNEST
+   GLOBIGNORE GLOBSORT HISTCONTROL HISTFILE HISTFILESIZE
+   HISTIGNORE HISTSIZE HISTTIMEFORMAT HOME HOSTFILE IGNOREEOF
+   INPUTRC INSIDE_EMACS LINES MAIL MAILCHECK MAILPATH MAPFILE
+   OLDPWD OPTARG PIPESTATUS POSIXLY_CORRECT PROMPT_COMMAND
+   PROMPT_DIRTRIM PS0 PS1 PS2 PS3 READLINE_ARGUMENT READLINE_LINE
+   READLINE_MARK READLINE_POINT REPLY TIMEFORMAT TMOUT TMPDIR
+   auto_resume histchars
 
# Exported functions bear this prefix.
"BASH_FUNC_.*"



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-12 Thread Sam James
commit: 1d3d917e6bc71570b00737682306fe8647568a3e
Author: Kerin Millar  plushkava  net>
AuthorDate: Mon Jul  7 13:22:16 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Sun Jul 13 04:19:05 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=1d3d917e

ebuild.sh: merge sandbox paths without sort -z and elide empty paths

Presently, the "ebuild.sh" utility contains a routine that merges the
colon-separated substrings of the 'SANDBOX_DENY', 'SANDBOX_PREDICT',
'SANDBOX_READ' and 'SANDBOX_WRITE' variables with those of their
counterparts that are prefixed with "PORTAGE_". In the course of doing
so, it executes the sort(1) and tr(1) utilities so as to de-duplicate
the resulting list, effectively producing a set. This routine suffers
from a few minor issues, which are described and addressed herewith.

The sort(1) utility is given the non-standard -z option. I find this to
be distasteful, chiefly because PMS makes no promise that a given
implementation of the utility shall be available. Address this issue by
refraining from using any external utilities whatsoever.

The routine fails to elide empty paths. Address this issue by
consistently disregarding the null string. Consider a scenario in which
the 'SANDBOX_DENY' and 'PORTAGE_SANDBOX_DENY' variables are being
processed, having been set as follows.

  SANDBOX_DENY=/foo::/bar
  PORTAGE_SANDBOX_DENY=/baz

Prior to this commit, the string representing the final set would be
formed as ":/bar:/baz:/foo". Following this commit, it shall instead be
formed as "/baz:/foo:/bar".

It should be noted that the revised code employs the ${param@Q} form of
expansion. Doing so is acceptable, given a target of >=bash-4.4.

Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/ebuild.sh | 28 
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/bin/ebuild.sh b/bin/ebuild.sh
index c81f4436e1..ff2527146d 100755
--- a/bin/ebuild.sh
+++ b/bin/ebuild.sh
@@ -576,20 +576,24 @@ then
# may be unusable (triggering in spurious sandbox violations)
# until we've merged them with our current values.
export SANDBOX_ON=0
-   for x in SANDBOX_DENY SANDBOX_PREDICT SANDBOX_READ SANDBOX_WRITE ; do
-   y="PORTAGE_${x}"
-   if [[ -z "${!x}" ]]; then
-   export ${x}="${!y}"
-   elif [[ -n "${!y}" && "${!y}" != "${!x}" ]]; then
-   # Filter out dupes
-   export ${x}="$(printf '%s:%s' "${!y}" "${!x}" | tr ":" 
"\0" | \
-   sort -z -u | tr "\0" ":")"
-   fi
-   export ${x}="${!x%:}"
-   unset PORTAGE_${x}
+   declare -A seen
+   for x in SANDBOX_DENY SANDBOX_PREDICT SANDBOX_READ SANDBOX_WRITE; do
+   {
+   export "${x}="
+   seen=()
+   i=0
+   while IFS= read -rd : path; do
+   if [[ ${path} && ! ${seen[$path]} ]]; then
+   (( i++ > 0 )) && eval "${x}+=:"
+   eval "${x}+=${path@Q}"
+   seen[$path]=1
+   fi
+   done
+   } < <(y="PORTAGE_${x}"; printf '%s:%s:' "${!y}" "${!x}")
+   unset "PORTAGE_${x}"
done
 
-   unset x y
+   unset path seen i x
export SANDBOX_ON=${PORTAGE_SANDBOX_ON}
unset PORTAGE_SANDBOX_ON
[[ -n ${EAPI} ]] || EAPI=0



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-12 Thread Sam James
commit: adc977d92024b6bf88e808e5e11a5c4cfc0226b1
Author: Kerin Millar  plushkava  net>
AuthorDate: Mon Jul  7 12:30:25 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Sun Jul 13 04:19:04 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=adc977d9

ebuild.sh: rectify a format string injection

Presently, the "ebuild.sh" utility contains a routine that merges the
values of the 'SANDBOX_DENY', 'SANDBOX_PREDICT', 'SANDBOX_READ' and
'SANDBOX_WRITE' variables with those of their counterparts that are
prefixed with "PORTAGE_". In the course of doing so, it directly injects
arbitrary pathnames into the format string given to an invocation of the
printf builtin. Refrain from doing so.

Fixes: 078abd42ede4b69f618b67c86a698030fe9d3c3b
Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/ebuild.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/ebuild.sh b/bin/ebuild.sh
index a7f67a89b0..c81f4436e1 100755
--- a/bin/ebuild.sh
+++ b/bin/ebuild.sh
@@ -582,7 +582,7 @@ then
export ${x}="${!y}"
elif [[ -n "${!y}" && "${!y}" != "${!x}" ]]; then
# Filter out dupes
-   export ${x}="$(printf "${!y}:${!x}" | tr ":" "\0" | \
+   export ${x}="$(printf '%s:%s' "${!y}" "${!x}" | tr ":" 
"\0" | \
sort -z -u | tr "\0" ":")"
fi
export ${x}="${!x%:}"



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-12 Thread Sam James
commit: e89c41e3925f60c88e04d5a2798722ee476fdf03
Author: Kerin Millar  plushkava  net>
AuthorDate: Tue Jul  8 23:24:56 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Sun Jul 13 04:19:05 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=e89c41e3

phase-functions.sh: improve the comment describing --allow-extra-vars behaviour

Presently, the "phase-functions.sh" unit contains a comment describing
the effect of the --allow-extra-vars option, as it pertains to the
__filter_readonly_variables() function. This comment contains two
typographical errors and does not properly describe the behaviour of the
option. Rectify these shortcomings.

Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/phase-functions.sh | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh
index afe28c613f..58904cd80e 100644
--- a/bin/phase-functions.sh
+++ b/bin/phase-functions.sh
@@ -76,10 +76,13 @@ PORTAGE_MUTABLE_FILTERED_VARS="AA HOSTNAME"
 # However, old settings should be overridden when loading the
 # environment from a binary or installed package.
 #
-# ---allow-extra-vars causes some extra vars to be allowd through, such
-# as ${PORTAGE_SAVED_READONLY_VARS} and ${PORTAGE_MUTABLE_FILTERED_VARS}.
-# This is enabled automatically if EMERGE_FROM=binary, since it preserves
-# variables from when the package was originally built.
+# --allow-extra-vars inhibits the filtering of the variables whose names are
+# specified by the PORTAGE_SAVED_READONLY_VARS and 
PORTAGE_MUTABLE_FILTERED_VARS
+# variables. However, in the absence of the option, only the CATEGORY, P, PF,
+# PN, PR, PV and PVR variables shall be filtered, provided that the value of
+# EMERGE_FROM is equal to "binary". The reason for this exception in behaviour
+# is to preserve various variables as they were at the time that the binary
+# package was built while protecting against the application of package 
renames.
 __filter_readonly_variables() {
local -a {binpkg_untrusted,filtered_sandbox,misc_garbage,bash}_vars 
words
local IFS



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-12 Thread Sam James
commit: 453ef9abe375b15de7d2055da5f91c62ed0f17f1
Author: Kerin Millar  plushkava  net>
AuthorDate: Sat Jul  5 21:17:47 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Sun Jul 13 04:19:03 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=453ef9ab

emerge-webrsync: mute an instance of SC2153 that is a false-positive

The get_fetchcommand() function begins with a conditional expression
that assesses the value of the 'FETCHCOMMAND' portage variable, causing
an SC2153 warning in shellcheck. Mute it by exempting the function in
its entirety.

Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/emerge-webrsync | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/emerge-webrsync b/bin/emerge-webrsync
index 6f32a484ae..69f18302b8 100755
--- a/bin/emerge-webrsync
+++ b/bin/emerge-webrsync
@@ -199,6 +199,7 @@ fetch_file() {
fi
 }
 
+# shellcheck disable=2153
 get_fetchcommand() {
local cmd_name cmd_args opts
 
@@ -207,7 +208,6 @@ get_fetchcommand() {
return 1
fi
 
-   # shellcheck disable=2153
read -rd '' cmd_name cmd_args <<<"${FETCHCOMMAND}"
 
case ${cmd_name} in



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-12 Thread Sam James
commit: a805000fc9ed82dedfab185831f70de28182
Author: Kerin Millar  plushkava  net>
AuthorDate: Fri Jul  4 15:27:56 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Sun Jul 13 04:19:01 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=a805000f

emerge-webrsync: don't tolerate an empty definition of GENTOO_MIRRORS

Presently, the do_snapshot() function considers the value of the
'GENTOO_MIRRORS' portage variable, separating its words into the
'mirrors' array variable. However, it will tolerate a value that is
either empty or blank, in which case it will warn that the snapshot
could not be found.

 * 20250704 snapshot was not found

Instead, have it report that the 'GENTOO_MIRRORS' variable is empty
before proceeding to die.

 * GENTOO_MIRRORS has been set as an empty or blank string
emerge-webrsync: couldn't parse GENTOO_MIRRORS

See-also: 432c18cc91037ba1a3a253fee00e66b820a1df33
Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/emerge-webrsync | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/bin/emerge-webrsync b/bin/emerge-webrsync
index 22e1699db4..096c25e874 100755
--- a/bin/emerge-webrsync
+++ b/bin/emerge-webrsync
@@ -519,6 +519,9 @@ do_snapshot() {
 
if (( have_files )); then
sync_local "${DISTDIR}/${file}"
+   elif (( ! ${#mirrors[@]} )); then
+   eerror "GENTOO_MIRRORS has been set as an empty or blank string"
+   die "couldn't parse GENTOO_MIRRORS"
else
ewarn "${date} snapshot was not found"
false



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-12 Thread Sam James
commit: fd92f3d7ee4577e63a069beb1da2df4727e4a422
Author: Kerin Millar  plushkava  net>
AuthorDate: Sun Jul  6 17:14:06 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Sun Jul 13 04:19:03 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=fd92f3d7

emerge-webrsync: drop a superfluous comment from fetch_file()

A considerable number of variables are defined by evaluating the output
of portageq envvar -v. As regards the fetch_file() function, there is no
particular need to observe that 'DISTDIR' is among them, nor exclusively
do so for one particular command within said function.

Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/emerge-webrsync | 1 -
 1 file changed, 1 deletion(-)

diff --git a/bin/emerge-webrsync b/bin/emerge-webrsync
index 69f18302b8..8807c8e737 100755
--- a/bin/emerge-webrsync
+++ b/bin/emerge-webrsync
@@ -192,7 +192,6 @@ fetch_file() {
rm -f -- "${DISTDIR}/${FILE}"
fi
 
-   # Already set DISTDIR=
if ! eval "${fetchcommand}" || [[ ! -s ${DISTDIR}/${FILE} ]]; then
rm -f -- "${DISTDIR}/${FILE}"
return 1



[gentoo-commits] proj/portage:master commit in: bin/

2025-07-12 Thread Sam James
commit: 801146653fa3bd408d12507057d5c12839def997
Author: Kerin Millar  plushkava  net>
AuthorDate: Sat Jul  5 20:05:14 2025 +
Commit: Sam James  gentoo  org>
CommitDate: Sun Jul 13 04:19:02 2025 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=80114665

emerge-webrsync: clarify the control flow of do_snapshot()

Presently, the do_snapshot() function composes an array of snapshot
tarballs and an array of mirrors before iterating over the cross product
of both, stopping after fetching a tarball that can be validated.

Render the control flow of its innermost loop just a little more clear
by consistently employing simple command chains joined by control
operators, and by briefly commenting as to the purpose of each.

Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 bin/emerge-webrsync | 35 ++-
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/bin/emerge-webrsync b/bin/emerge-webrsync
index 096c25e874..107613fbaf 100755
--- a/bin/emerge-webrsync
+++ b/bin/emerge-webrsync
@@ -488,6 +488,9 @@ do_snapshot() {
for mirror in "${mirrors[@]/%\/}"; do
einfo "Trying to retrieve ${date} snapshot from ${mirror} ..."
for file in "${tarballs[@]}"; do
+   have_files=0
+
+   # Attempt to use any previously downloaded files.
test -s "${DISTDIR}/${file}.md5sum" \
&& test -s "${DISTDIR}/${file}.gpgsig" \
&& test -s "${DISTDIR}/${file}" \
@@ -495,25 +498,23 @@ do_snapshot() {
&& check_file_signature "${DISTDIR}/${file}" \
&& have_files=1
 
-   if (( ! have_files )); then
-   fetch_file "${mirror}/snapshots/${file}.md5sum" 
\
-   && fetch_file 
"${mirror}/snapshots/${file}.gpgsig" \
-   && fetch_file "${mirror}/snapshots/${file}" \
-   && check_file_digest "${DISTDIR}/${file}" \
-   && check_file_signature "${DISTDIR}/${file}" \
-   && have_files=1
-   fi
+   # Otherwise, attempt to fetch the required files.
+   (( ! have_files )) \
+   && fetch_file "${mirror}/snapshots/${file}.md5sum" \
+   && fetch_file "${mirror}/snapshots/${file}.gpgsig" \
+   && fetch_file "${mirror}/snapshots/${file}" \
+   && check_file_digest "${DISTDIR}/${file}" \
+   && check_file_signature "${DISTDIR}/${file}" \
+   && have_files=1
 
+   # Accept any validated files under consideration,
+   # provided that the age of the snapshot is tolerable.
(( have_files )) \
-   && ! is_snapshot_fresh "${DISTDIR}/${file}" 
"${ignore_timestamp}" \
-   && have_files=0
-
-   if (( have_files )); then
-   break 2
-   else
-   # Remove files and use a different mirror
-   rm -f -- 
"${DISTDIR}/${file}"{".md5sum",".gpgsig",}
-   fi
+   && is_snapshot_fresh "${DISTDIR}/${file}" 
"${ignore_timestamp}" \
+   && break 2
+
+   # Remove any files before trying a different mirror.
+   rm -f -- "${DISTDIR}/${file}"{".md5sum",".gpgsig",}
done
done
 



  1   2   3   4   5   6   7   8   9   10   >