2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-29 05:17:59 +00:00

Merge init: make xargs invocation busybox-compatible

busybox xargs does not have -d nor long --max-procs options, instead use -0 (and separate arguments with printf "%s\\0") and -P which are more portable. While we are here, also add -r (--no-run-if-empty, which also has no long equivalent for busybox) as we likely don't want to run anything if no profile were found

This is useful for alpine systems where findutils is not installed by default, but busybox xargs is available.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/828
Acked-by: John Johansen <john.johansen@canoical.com>
(cherry picked from commit 0e52b555ae5450a13fd8770fa948e65ba59e6933)
Signed-off-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
John Johansen 2022-01-27 03:23:50 +00:00 committed by John Johansen
parent 5049cdb45f
commit 1e9e0e40a9

View File

@ -181,10 +181,10 @@ __parse_profiles_dir() {
if [ ! -f "$profile" ] ; then
continue
fi
echo "$profile"
printf "%s\0" "$profile"
done | \
# Use xargs to parallelize calls to the parser over all CPUs
xargs -n1 -d"\n" --max-procs="$(getconf _NPROCESSORS_ONLN)" \
xargs -n1 -0r -P "$(getconf _NPROCESSORS_ONLN)" \
"$PARSER" $PARSER_OPTS "$parser_cmd" --
if [ $? -ne 0 ]; then
status=1