Discussion:
[gentoo-portage-dev] [PATCH] install-qa-check.d/60pngfix: parallel support (bug 630292)
Zac Medico
2018-07-25 19:59:58 UTC
Permalink
If xargs supports the --max-procs option then use the makeopts_jobs
function from helper-functions.sh to generate a --max-procs argument.

Bug: https://bugs.gentoo.org/630292
---
bin/install-qa-check.d/60pngfix | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/bin/install-qa-check.d/60pngfix b/bin/install-qa-check.d/60pngfix
index 8d53040b6..2bf020079 100644
--- a/bin/install-qa-check.d/60pngfix
+++ b/bin/install-qa-check.d/60pngfix
@@ -1,7 +1,17 @@
# Check for issues with PNG files

+source "${PORTAGE_BIN_PATH}/helper-functions.sh" || exit 1
+
pngfix_check() {
- local pngfix=$(type -P pngfix)
+ local 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})
+ fi
+ fi
+
if [[ -n ${pngfix} ]] ; then
local pngout=()
local next
@@ -25,7 +35,7 @@ pngfix_check() {
fi
eqawarn " ${pngout[@]:7}: ${error}"
fi
- done < <(find "${ED}" -type f -name '*.png' -exec "${pngfix}" {} +)
+ done < <(find "${ED}" -type f -name '*.png' -print0 | "${xargs[@]}" -0 "${pngfix}")
fi
}
--
2.16.4
Michał Górny
2018-08-09 07:40:25 UTC
Permalink
W dniu śro, 25.07.2018 o godzinie 12∶59 -0700, uÅŒytkownik Zac Medico
Post by Zac Medico
If xargs supports the --max-procs option then use the makeopts_jobs
function from helper-functions.sh to generate a --max-procs argument.
Bug: https://bugs.gentoo.org/630292
---
bin/install-qa-check.d/60pngfix | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/bin/install-qa-check.d/60pngfix b/bin/install-qa-check.d/60pngfix
index 8d53040b6..2bf020079 100644
--- a/bin/install-qa-check.d/60pngfix
+++ b/bin/install-qa-check.d/60pngfix
@@ -1,7 +1,17 @@
# Check for issues with PNG files
+source "${PORTAGE_BIN_PATH}/helper-functions.sh" || exit 1
+
pngfix_check() {
- local pngfix=$(type -P pngfix)
+ local jobs pngfix=$(type -P pngfix) xargs=(${XARGS})
+
+ if xargs --help | grep -q -- --max-procs=; then
'--help' is not a valid argument on FreeBSD, so this spews errors
to stderr:

* Final size of build directory: 3655 KiB (3.5 MiB)
* Final size of installed tree: 24 KiB

xargs: illegal option -- -
usage: xargs [-0opt] [-E eofstr] [-I replstr [-R replacements] [-S replsize]]
[-J replstr] [-L number] [-n number [-x]] [-P maxprocs]
[-s size] [utility [argument ...]]
strip: strip --strip-unneeded -R .comment -R .GCC.command.line -R .note.gnu.gold-version
usr/lib/libgraphene-1.0.so.0.800.2

Also note that -P is more portable than --max-procs.
Post by Zac Medico
+ jobs=$(makeopts_jobs)
+ if [[ ${jobs} -gt 1 ]]; then
+ xargs+=(--max-procs=${jobs})
+ fi
+ fi
+
if [[ -n ${pngfix} ]] ; then
local pngout=()
local next
@@ -25,7 +35,7 @@ pngfix_check() {
fi
fi
- done < <(find "${ED}" -type f -name '*.png' -exec "${pngfix}" {} +)
fi
}
--
Best regards,
Michał Górny
Ulrich Mueller
2018-08-09 09:09:21 UTC
Permalink
Post by Michał Górny
Post by Zac Medico
+ if xargs --help | grep -q -- --max-procs=; then
'--help' is not a valid argument on FreeBSD, so this spews errors
IIRC, GNU findutils is required by PMS?

Ulrich
Michał Górny
2018-08-09 09:13:47 UTC
Permalink
W dniu czw, 09.08.2018 o godzinie 11∶09 +0200, uÅŒytkownik Ulrich Mueller
Post by Ulrich Mueller
Post by Michał Górny
Post by Zac Medico
+ if xargs --help | grep -q -- --max-procs=; then
'--help' is not a valid argument on FreeBSD, so this spews errors
IIRC, GNU findutils is required by PMS?
Yes, using gxargs is another option. I suppose the usual ebuild env
override is not used in this phase.
--
Best regards,
Michał Górny
Zac Medico
2018-08-09 20:14:42 UTC
Permalink
Post by Michał Górny
W dniu czw, 09.08.2018 o godzinie 11∶09 +0200, uÅŒytkownik Ulrich Mueller
Post by Ulrich Mueller
Post by Michał Górny
Post by Zac Medico
+ if xargs --help | grep -q -- --max-procs=; then
'--help' is not a valid argument on FreeBSD, so this spews errors
IIRC, GNU findutils is required by PMS?
Yes, using gxargs is another option. I suppose the usual ebuild env
override is not used in this phase.
The 'alias xargs=gxargs' from profiles/default/bsd/fbsd/profile.bashrc
is ineffective because it doesn't apply to the XARGS variable that
portage defines in isolated-functions.sh:

case ${USERLAND} in
BSD)
export XARGS="xargs"
;;
*)
export XARGS="xargs -r"
;;
esac

I guess it should simply use gxargs if available. However, I don't see
anything in PMS about the 'g' prefix, though I do see this in the
findutils ebuilds:

program_prefix=$(usex userland_GNU '' g)
--
Thanks,
Zac
Loading...