commit:     a0210b3c49ea346b1e999f92a7ed89802e8d6849
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Sun Jun  8 12:36:01 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Jun  8 13:36:12 2025 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=a0210b3c

ecompress: render compatible with the outdated GitHub CI runner

Presently, ecompress tries to use the -files0-from primary, which was
introduced by GNU findutils 4.9.0. However, this is not supported by the
prevailing GitHub CI operating environment, which suffers from an
outdated version of findutils (contrary to the RDEPEND declared by
sys-apps/portage).

Temporarily address the issue by relocating the find0() function to
"isolated-functions.sh" and having it implement itself in a
backward-compatible fashion if necessary, albeit with none of the safety
guarantees that the new primary affords.

See-also: d887c7fd33b5f136ff62d423d7a11980fb9faca1
Bug: https://bugs.gentoo.org/957550
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 bin/ecompress             |  7 -------
 bin/isolated-functions.sh | 22 ++++++++++++++++++++++
 2 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/bin/ecompress b/bin/ecompress
index a21391d1ed..0566a8331b 100755
--- a/bin/ecompress
+++ b/bin/ecompress
@@ -5,13 +5,6 @@
 
 source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
-# shellcheck disable=2185
-if hash gfind 2>/dev/null; then
-       find0() { gfind -files0-from - "$@"; }
-else
-       find0() { find -files0-from - "$@"; }
-fi
-
 do_ignore() {
        local -x LC_ALL= LC_COLLATE=C
        local -a skip_dirs

diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index b35fc7e926..1befb4a91f 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -692,4 +692,26 @@ contains_word() {
        [[ $1 == +([![:space:]]) && " ${*:2} " == *[[:space:]]"$1"[[:space:]]* 
]]
 }
 
+# Invoke GNU find(1) in such a way that the paths to be searched are consumed
+# as a null-terminated list from STDIN. The positional parameters shall be
+# conveyed verbatim and treated as options and/or primaries.
+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 paths
+
+                       mapfile -td '' paths
+                       find "${paths[@]}" "$@"
+               }
+       fi
+
+       find0 "$@"
+}
+
 true

Reply via email to