* [gentoo-commits] proj/portage:master commit in: bin/install-qa-check.d/, bin/
@ 2018-04-17 2:14 Zac Medico
0 siblings, 0 replies; 5+ messages in thread
From: Zac Medico @ 2018-04-17 2:14 UTC (permalink / raw
To: gentoo-commits
commit: ae6d6aa22d074c04cd9caefe1ca02bf615bfd86f
Author: Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org>
AuthorDate: Tue Apr 17 02:06:38 2018 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Apr 17 02:11:19 2018 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=ae6d6aa2
estrip, install-qa-check.d/10ignored-flags: fix bug 653352
Update detection of ELF files to work with >=sys-apps/file-5.33.
Bug: https://bugs.gentoo.org/653352
bin/estrip | 3 ++-
bin/install-qa-check.d/10ignored-flags | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/bin/estrip b/bin/estrip
index 030d9e8bf..5709b862c 100755
--- a/bin/estrip
+++ b/bin/estrip
@@ -427,7 +427,8 @@ do
${STRIP} -g "${x}"
fi
fi
- elif [[ ${f} == *"SB executable"* || ${f} == *"SB shared object"* ]] ; then
+ elif [[ ${f} == *"SB executable"* || ${f} == *"SB pie executable"* ||
+ ${f} == *"SB shared object"* ]] ; then
process_elf "${x}" "${inode_link}" ${PORTAGE_STRIP_FLAGS}
elif [[ ${f} == *"SB relocatable"* ]] ; then
process_elf "${x}" "${inode_link}" ${SAFE_STRIP_FLAGS}
diff --git a/bin/install-qa-check.d/10ignored-flags b/bin/install-qa-check.d/10ignored-flags
index 28aec6787..dc160e182 100644
--- a/bin/install-qa-check.d/10ignored-flags
+++ b/bin/install-qa-check.d/10ignored-flags
@@ -32,7 +32,7 @@ ignored_flag_check() {
# similar to how prepstrip uses it.
f=$(file "${x}") || continue
[[ -z ${f} ]] && continue
- if [[ ${f} == *"SB executable"* ||
+ if [[ ${f} == *"SB executable"* || ${f} == *"SB pie executable"* ||
${f} == *"SB shared object"* ]] ; then
echo "${x}" >> "${T}"/scanelf-ignored-CFLAGS.log
fi
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/portage:master commit in: bin/install-qa-check.d/, bin/
@ 2018-09-20 18:49 Michał Górny
0 siblings, 0 replies; 5+ messages in thread
From: Michał Górny @ 2018-09-20 18:49 UTC (permalink / raw
To: gentoo-commits
commit: aecc59a5f2c05db09ee7e04a32875998adddf446
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Sep 20 18:18:44 2018 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Sep 20 18:48:37 2018 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=aecc59a5
Move parallel xargs wrapping to isolated-functions.sh
Move the parallel xargs support used in pngfix QA check
to isolated-functions.sh, to be reused in ecompress.
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
Reviewed-by: Zac Medico <zmedico <AT> gentoo.org>
bin/helper-functions.sh | 9 +--------
bin/install-qa-check.d/60pngfix | 13 ++-----------
bin/isolated-functions.sh | 22 ++++++++++++++++++++++
3 files changed, 25 insertions(+), 19 deletions(-)
diff --git a/bin/helper-functions.sh b/bin/helper-functions.sh
index 9b6e201aa..2d359762a 100644
--- a/bin/helper-functions.sh
+++ b/bin/helper-functions.sh
@@ -10,13 +10,6 @@ source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
#
# API functions for doing parallel processing
#
-makeopts_jobs() {
- # Copied from eutils.eclass:makeopts_jobs()
- local jobs=$(echo " ${MAKEOPTS} " | \
- sed -r -n 's:.*[[:space:]](-j|--jobs[=[:space:]])[[:space:]]*([0-9]+).*:\2:p')
- echo ${jobs:-1}
-}
-
__multijob_init() {
# Setup a pipe for children to write their pids to when they finish.
# We have to allocate two fd's because POSIX has undefined behavior
@@ -34,7 +27,7 @@ __multijob_init() {
rm -f "${pipe}"
# See how many children we can fork based on the user's settings.
- mj_max_jobs=$(makeopts_jobs "$@")
+ mj_max_jobs=$(___makeopts_jobs "$@")
mj_num_jobs=0
}
diff --git a/bin/install-qa-check.d/60pngfix b/bin/install-qa-check.d/60pngfix
index b69c55614..a2e23d1d3 100644
--- a/bin/install-qa-check.d/60pngfix
+++ b/bin/install-qa-check.d/60pngfix
@@ -1,16 +1,7 @@
# Check for issues with PNG files
-source "${PORTAGE_BIN_PATH}/helper-functions.sh" || exit 1
-
pngfix_check() {
- local chunksize=1 jobs pngfix=$(type -P pngfix) xargs=(${XARGS})
-
- if "${xargs[@]}" --help | grep -q -- --max-procs=; then
- jobs=$(makeopts_jobs)
- if [[ ${jobs} -gt 1 ]]; then
- xargs+=("--max-procs=${jobs}" -L "${chunksize}")
- fi
- fi
+ local pngfix=$(type -P pngfix)
if [[ -n ${pngfix} ]] ; then
local pngout=()
@@ -35,7 +26,7 @@ pngfix_check() {
fi
eqawarn " ${pngout[@]:7}: ${error}"
fi
- done < <(find "${ED}" -type f -name '*.png' -print0 | "${xargs[@]}" -0 "${pngfix}")
+ done < <(find "${ED}" -type f -name '*.png' -print0 | ___parallel_xargs -0 "${pngfix}")
fi
}
diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index cac42a4c5..39b0ad344 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -460,6 +460,28 @@ if [[ -z ${XARGS} ]] ; then
esac
fi
+___makeopts_jobs() {
+ # Copied from eutils.eclass:makeopts_jobs()
+ local jobs=$(echo " ${MAKEOPTS} " | \
+ sed -r -n 's:.*[[:space:]](-j|--jobs[=[:space:]])[[:space:]]*([0-9]+).*:\2:p')
+ echo ${jobs:-1}
+}
+
+# Run ${XARGS} in parallel for detected number of CPUs, if supported.
+# Passes all arguments to xargs, and returns its exit code
+___parallel_xargs() {
+ local chunksize=1 jobs xargs=( ${XARGS} )
+
+ if "${xargs[@]}" --help | grep -q -- --max-procs=; then
+ jobs=$(___makeopts_jobs)
+ if [[ ${jobs} -gt 1 ]]; then
+ xargs+=("--max-procs=${jobs}" -L "${chunksize}")
+ fi
+ fi
+
+ "${xargs[@]}" "${@}"
+}
+
hasq() {
has $EBUILD_PHASE prerm postrm || eqawarn \
"QA Notice: The 'hasq' function is deprecated (replaced by 'has')"
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/portage:master commit in: bin/install-qa-check.d/, bin/
@ 2022-11-09 1:17 Sam James
0 siblings, 0 replies; 5+ messages in thread
From: Sam James @ 2022-11-09 1:17 UTC (permalink / raw
To: gentoo-commits
commit: 85723dbd4d8fa6392001adeb8ca695a29e530949
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Nov 9 01:16:27 2022 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Nov 9 01:17:50 2022 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=85723dbd
bin: replace check-implicit-pointer-usage.py
Always die on -Wimplicit-function-declaration as Clang 16 is going
to make it fatal and it's always pretty dubious.
The licencing of check-implicit-pointer-usage.py is also unclear,
but the tool has been broken since GCC 4.5(!)
Bug: https://bugs.gentoo.org/365655
Bug: https://bugs.gentoo.org/870412
Signed-off-by: Sam James <sam <AT> gentoo.org>
bin/check-implicit-pointer-usage.py | 79 -----------------------------------
bin/install-qa-check.d/90gcc-warnings | 46 ++++----------------
2 files changed, 7 insertions(+), 118 deletions(-)
diff --git a/bin/check-implicit-pointer-usage.py b/bin/check-implicit-pointer-usage.py
deleted file mode 100755
index 06b666c88..000000000
--- a/bin/check-implicit-pointer-usage.py
+++ /dev/null
@@ -1,79 +0,0 @@
-#!/usr/bin/env python
-
-# Ripped from HP and updated from Debian
-# Update by Gentoo to support unicode output
-
-#
-# Copyright (c) 2004 Hewlett-Packard Development Company, L.P.
-# David Mosberger <davidm@hpl.hp.com>
-#
-# Scan standard input for GCC warning messages that are likely to
-# source of real 64-bit problems. In particular, see whether there
-# are any implicitly declared functions whose return values are later
-# interpreted as pointers. Those are almost guaranteed to cause
-# crashes.
-#
-
-import re
-import sys
-
-implicit_pattern = re.compile(
- r"([^:]*):(\d+): warning: implicit declaration " + "of function [`']([^']*)'"
-)
-pointer_pattern = (
- r"([^:]*):(\d+): warning: "
- + r"("
- + r"(assignment"
- + r"|initialization"
- + r"|return"
- + r"|passing arg \d+ of `[^']*'"
- + r"|passing arg \d+ of pointer to function"
- + r") makes pointer from integer without a cast"
- + r"|"
- + r"cast to pointer from integer of different size)"
-)
-
-unicode_quote_open = "\u2018"
-unicode_quote_close = "\u2019"
-
-
-def write(msg):
- sys.stdout.buffer.write(msg.encode("utf_8", "backslashreplace"))
-
-
-pointer_pattern = re.compile(pointer_pattern)
-
-last_implicit_filename = ""
-last_implicit_linenum = -1
-last_implicit_func = ""
-
-while True:
- line = sys.stdin.buffer.readline().decode("utf_8", "replace")
- if not line:
- break
- # translate unicode open/close quotes to ascii ones
- line = line.replace(unicode_quote_open, "`")
- line = line.replace(unicode_quote_close, "'")
- m = implicit_pattern.match(line)
- if m:
- last_implicit_filename = m.group(1)
- last_implicit_linenum = int(m.group(2))
- last_implicit_func = m.group(3)
- else:
- m = pointer_pattern.match(line)
- if m:
- pointer_filename = m.group(1)
- pointer_linenum = int(m.group(2))
- if (
- last_implicit_filename == pointer_filename
- and last_implicit_linenum == pointer_linenum
- ):
- write(
- "Function `%s' implicitly converted to pointer at "
- "%s:%d\n"
- % (
- last_implicit_func,
- last_implicit_filename,
- last_implicit_linenum,
- )
- )
diff --git a/bin/install-qa-check.d/90gcc-warnings b/bin/install-qa-check.d/90gcc-warnings
index f5dae8a76..cd12558ba 100644
--- a/bin/install-qa-check.d/90gcc-warnings
+++ b/bin/install-qa-check.d/90gcc-warnings
@@ -110,12 +110,17 @@ gcc_warn_check() {
f=$(LC_CTYPE=C LC_COLLATE=C "${grep_cmd}" -E -a "${joined_msgs}" "${PORTAGE_LOG_FILE}" | uniq)
if [[ -n ${f} ]] ; then
abort="yes"
+
# for now, don't make this fatal (see bug #337031)
#if [[ ${f} == *'will always overflow destination buffer'* ]]; then
# always_overflow=yes
#fi
- if [[ ${always_overflow} = yes ]] ; then
+ if [[ ${f} == *'[-Wimplicit-function-declaration]'* ]] ; then
+ implicit_func_decl=yes
+ fi
+
+ if [[ ${always_overflow} = yes || ${implicit_func_decl} = yes ]] ; then
eerror
eerror "QA Notice: Package triggers severe warnings which indicate that it"
eerror " may exhibit random runtime failures."
@@ -134,47 +139,10 @@ gcc_warn_check() {
fi
fi
- local cat_cmd=cat
- [[ ${PORTAGE_LOG_FILE} = *.gz ]] && cat_cmd=zcat
[[ ${reset_debug} = 1 ]] && set -x
- # Use safe cwd, avoiding unsafe import for bug #469338.
- f=$(cd "${PORTAGE_PYM_PATH}" ; ${cat_cmd} "${PORTAGE_LOG_FILE}" | \
- "${PORTAGE_PYTHON:-/usr/bin/python}" "${PORTAGE_BIN_PATH}"/check-implicit-pointer-usage.py || die "check-implicit-pointer-usage.py failed")
-
- if [[ -n ${f} ]] ; then
- # In the future this will be a forced "die". In preparation,
- # increase the log level from "qa" to "eerror" so that people
- # are aware this is a problem that must be fixed ASAP.
-
- # Just warn on 32bit hosts but bail on 64bit hosts
- case ${CHOST} in
- alpha*|aarch64*|arm64*|hppa64*|ia64*|powerpc64*|loongarch64*|mips64*|riscv64*|sparc64*|sparcv9*|s390x*|x86_64*) gentoo_bug=yes ;;
- esac
-
- abort=yes
-
- if [[ ${gentoo_bug} = yes ]] ; then
- eerror
- eerror "QA Notice: Package triggers severe warnings which indicate that it"
- eerror " will almost certainly crash on 64bit architectures."
- eerror
- eerror "${f}"
- eerror
- eerror " Please file a bug about this at https://bugs.gentoo.org/"
- eerror " with the maintainer of the package."
- eerror
- else
- __vecho -ne '\n'
- eqawarn "QA Notice: Package triggers severe warnings which indicate that it"
- eqawarn " will almost certainly crash on 64bit architectures."
- eqawarn "${f}"
- __vecho -ne '\n'
- fi
-
- fi
if [[ ${abort} == "yes" ]] ; then
- if [[ ${gentoo_bug} = yes || ${always_overflow} = yes ]] ; then
+ if [[ ${gentoo_bug} = yes || ${always_overflow} = yes || ${implicit_func_decl} = yes ]] ; then
die "install aborted due to severe warnings shown above"
else
echo "Please do not file a Gentoo bug and instead" \
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/portage:master commit in: bin/install-qa-check.d/, bin/
@ 2024-07-26 10:22 Sam James
0 siblings, 0 replies; 5+ messages in thread
From: Sam James @ 2024-07-26 10:22 UTC (permalink / raw
To: gentoo-commits
commit: cc793fb5f0d7c39c904f9e209b804d8f762a96cd
Author: Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Tue Jul 23 16:05:51 2024 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Jul 26 10:22:40 2024 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=cc793fb5
Check whether xtrace is enabled sensibly
To write [[ ${-/x/} != $- ]] is horribly backwards and comparatively
expensive. Implement the test - and its inverse - in a sensible fashion.
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>
bin/ebuild.sh | 4 ++--
bin/install-qa-check.d/90cython-dep | 2 +-
bin/install-qa-check.d/90gcc-warnings | 2 +-
bin/phase-functions.sh | 6 +++---
4 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/bin/ebuild.sh b/bin/ebuild.sh
index 8b1e0861a8..a742397db9 100755
--- a/bin/ebuild.sh
+++ b/bin/ebuild.sh
@@ -473,7 +473,7 @@ __try_source() {
if [[ -r ${1} && -f ${1} ]]; then
local debug_on=false
- if [[ "${PORTAGE_DEBUG}" == "1" ]] && [[ "${-/x/}" == "$-" ]]; then
+ if [[ ${PORTAGE_DEBUG} == 1 ]] && [[ $- != *x* ]]; then
debug_on=true
fi
@@ -628,7 +628,7 @@ if ! has "${EBUILD_PHASE}" clean cleanrm ; then
unset E_RESTRICT PROVIDES_EXCLUDE REQUIRES_EXCLUDE
unset PORTAGE_EXPLICIT_INHERIT
- if [[ ${PORTAGE_DEBUG} != 1 || ${-/x/} != $- ]] ; then
+ if [[ ${PORTAGE_DEBUG} != 1 || $- == *x* ]] ; then
source "${EBUILD}" || die "error sourcing ebuild"
else
set -x
diff --git a/bin/install-qa-check.d/90cython-dep b/bin/install-qa-check.d/90cython-dep
index 4932c02429..2458074c39 100644
--- a/bin/install-qa-check.d/90cython-dep
+++ b/bin/install-qa-check.d/90cython-dep
@@ -13,7 +13,7 @@ cython_dep_check() {
# In debug mode, the grep calls will produce false positives
# if they're shown in the trace.
local reset_debug=0
- if [[ ${-/x/} != $- ]] ; then
+ if [[ $- == *x* ]] ; then
set +x
reset_debug=1
fi
diff --git a/bin/install-qa-check.d/90gcc-warnings b/bin/install-qa-check.d/90gcc-warnings
index 1060618dfa..2e728268e1 100644
--- a/bin/install-qa-check.d/90gcc-warnings
+++ b/bin/install-qa-check.d/90gcc-warnings
@@ -10,7 +10,7 @@ gcc_warn_check() {
# In debug mode, this variable definition and corresponding grep calls
# will produce false positives if they're shown in the trace.
local reset_debug=0
- if [[ ${-/x/} != $- ]] ; then
+ if [[ $- == *x* ]] ; then
set +x
reset_debug=1
fi
diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh
index d037cf6776..2c3f2d389f 100644
--- a/bin/phase-functions.sh
+++ b/bin/phase-functions.sh
@@ -1002,7 +1002,7 @@ __ebuild_main() {
ewarn "pkg_${1}() is not defined: '${EBUILD##*/}'"
fi
export SANDBOX_ON="0"
- if [[ "${PORTAGE_DEBUG}" != "1" || "${-/x/}" != "$-" ]]; then
+ if [[ ${PORTAGE_DEBUG} != 1 || $- == *x* ]]; then
__ebuild_phase_with_hooks pkg_${1}
else
set -x
@@ -1069,7 +1069,7 @@ __ebuild_main() {
;;
esac
- if [[ "${PORTAGE_DEBUG}" != "1" || "${-/x/}" != "$-" ]]; then
+ if [[ ${PORTAGE_DEBUG} != 1 || $- == *x* ]]; then
__dyn_${1}
else
set -x
@@ -1083,7 +1083,7 @@ __ebuild_main() {
# for example, awking and piping a file in /tmp requires a temp file to be created
# in /etc. If pkg_setup is in the sandbox, both our lilo and apache ebuilds break.
export SANDBOX_ON="0"
- if [[ "${PORTAGE_DEBUG}" != "1" || "${-/x/}" != "$-" ]]; then
+ if [[ ${PORTAGE_DEBUG} != 1 || $- == *x* ]]; then
__dyn_${1}
else
set -x
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/portage:master commit in: bin/install-qa-check.d/, bin/
@ 2025-06-28 2:30 Sam James
0 siblings, 0 replies; 5+ messages in thread
From: Sam James @ 2025-06-28 2:30 UTC (permalink / raw
To: gentoo-commits
commit: d2ffee09c8470e1e84b5b07442536757f17130f5
Author: Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Tue Jun 24 10:45:07 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Jun 28 02:28:40 2025 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=d2ffee09
isolated-functions.sh: introduce ___parallel() to replace ___parallel_xargs()
Presently, the "isolated-functions.sh" unit provides the
___parallel_xargs() function, whose purpose is to dispatch a simple
command multiple times in parallel, with each invocation taking one
additional parameter. However, in order to be able to issue commands in
parallel, it requires for the xargs(1) utility to support the wholly
non-standard --max-procs option, which only the GNU implementation
provides. This is in spite of the fact that the -P option is commonly
implemented by the current releases of popular unix-like operating
systems, though that, too, is a non-standard option.
This commit introduces a new function, named ___parallel(). It acts in a
way that is very similar to GNU xargs(1), as accompanied by its -0, -L
and -P options. Yet it requires no particular implementation thereof.
Indeed, it does not use xargs(1) at all. Rather, it uses the native
process management features provided by bash. In particular, it takes
advantage of the -n option of the wait builtin, which was introduced by
the release of bash-4.4.
As the following sample commands demonstrate, it is trivial to port any
existing call sites.
# BEFORE
find . -type f -name '*.png' -print0 | ___parallel_xargs -0 pngfix
# AFTER
find . -type f -name '*.png' -print0 | ___parallel pngfix
Indeed, it transpires that ___parallel_xargs() is used only by the
following two units, both of which are ported by this commit.
- bin/ecompress
- bin/install-qa-check.d/60pngfix
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>
bin/ecompress | 2 +-
bin/install-qa-check.d/60pngfix | 2 +-
bin/isolated-functions.sh | 49 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 51 insertions(+), 2 deletions(-)
diff --git a/bin/ecompress b/bin/ecompress
index 2500bd5a2c..a59e699f07 100755
--- a/bin/ecompress
+++ b/bin/ecompress
@@ -248,7 +248,7 @@ export PORTAGE_COMPRESS_SUFFIX PORTAGE_COMPRESS_FLAGS PORTAGE_COMPRESS
printf '%s\0' "${ED}" \
| find0 -name '*.ecompress' ! -path $'*\n*' -delete -print0 \
-| ___parallel_xargs -0 "${PORTAGE_BIN_PATH}"/ecompress-file
+| ___parallel "${PORTAGE_BIN_PATH}"/ecompress-file
all_compressed=$(( $? == 0 ))
if [[ -s ${T}/.ecompress_had_precompressed ]]; then
diff --git a/bin/install-qa-check.d/60pngfix b/bin/install-qa-check.d/60pngfix
index 0300ed2ac1..d00810e594 100644
--- a/bin/install-qa-check.d/60pngfix
+++ b/bin/install-qa-check.d/60pngfix
@@ -28,7 +28,7 @@ pngfix_check() {
fi
eqawarn " ${pngout[@]:7}: ${error}"
fi
- done < <(find "${ED}" -type f -name '*.png' -print0 | ___parallel_xargs -0 "${pngfix}")
+ done < <(find "${ED}" -type f -name '*.png' -print0 | ___parallel "${pngfix}")
fi
}
diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index 88f1913fdf..d0f7d4d09b 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -509,6 +509,55 @@ ___makeopts_jobs() {
printf '%s\n' "${jobs}"
}
+# Considers the positional parameters as comprising a simple command, which
+# shall be executed for each null-terminated record read from the standard
+# input. For each record processed, its value shall be taken as an additional
+# parameter to append to the command. Commands shall be executed in parallel,
+# with the maximal degree of concurrency being determined by the output of the
+# ___makeopts_jobs function. Thus, the behaviour is quite similar to that of
+# xargs -0 -L1 -P"$(___makeopts_jobs)".
+#
+# If no records are read, or if all commands complete successfully, the return
+# value shall be 0. Otherwise, the return value shall be that of the failed
+# command that was last reaped by bash. Should any command fail, no further
+# records shall be consumed and the function shall attempt to return as soon as
+# possible. Hence, the caller should assume that not all records were processed
+# in the event of a non-zero return value. As a special case, the function shall
+# return 127 if the first parameter cannot be resolved as a valid command name.
+___parallel() (
+ local max_procs retval arg i
+
+ if ! hash "$1" 2>/dev/null; then
+ printf >&2 '%s: %q: command not found\n' "$0" "$1"
+ return 127
+ fi
+
+ max_procs=$(___makeopts_jobs)
+ retval=0
+
+ while IFS= read -rd '' arg; do
+ if (( ++i > max_procs )); then
+ wait -n
+ case $? in
+ 0) ;;
+ *) retval=$?; break
+ esac
+ fi
+ "$@" "${arg}" &
+ done
+
+ while true; do
+ wait -n
+ case $? in
+ 127) break ;; # no more unwaited-for children left
+ 0) ;;
+ *) retval=$?
+ esac
+ done
+
+ return "${retval}"
+)
+
# Run ${XARGS} in parallel for detected number of CPUs, if supported.
# Passes all arguments to xargs, and returns its exit code
___parallel_xargs() {
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-06-28 2:30 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-28 2:30 [gentoo-commits] proj/portage:master commit in: bin/install-qa-check.d/, bin/ Sam James
-- strict thread matches above, loose matches on Subject: below --
2024-07-26 10:22 Sam James
2022-11-09 1:17 Sam James
2018-09-20 18:49 Michał Górny
2018-04-17 2:14 Zac Medico
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox