From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: bin/install-qa-check.d/, bin/
Date: Thu, 20 Sep 2018 18:49:28 +0000 (UTC) [thread overview]
Message-ID: <1537469317.aecc59a5f2c05db09ee7e04a32875998adddf446.mgorny@gentoo> (raw)
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')"
next reply other threads:[~2018-09-20 18:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-20 18:49 Michał Górny [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-07-26 10:22 [gentoo-commits] proj/portage:master commit in: bin/install-qa-check.d/, bin/ Sam James
2022-11-09 1:17 Sam James
2018-04-17 2:14 Zac Medico
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1537469317.aecc59a5f2c05db09ee7e04a32875998adddf446.mgorny@gentoo \
--to=mgorny@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox