tools: toolchain: prepare: build arch images in parallel

To speed up the build, run each arch in parallel, using bash's
awkward job control.
This commit is contained in:
Avi Kivity
2022-04-10 18:45:08 +03:00
parent 39ccd744de
commit 69af7a830b

View File

@@ -45,13 +45,31 @@ done
buildah manifest create "$(<tools/toolchain/image)"
for arch in "${archs[@]}"; do
build_arch() {
local arch="$1"
image_id_file="$(mktemp)"
buildah bud --arch="$arch" --no-cache --pull -f tools/toolchain/Dockerfile --iidfile "$image_id_file"
buildah manifest add --all "$(<tools/toolchain/image)" "$(<$image_id_file)"
rm "$image_id_file"
}
for arch in "${archs[@]}"; do
build_arch "$arch" &
done
fails=0
for arch in "${archs[@]}"; do
if ! wait -n; then
(( fails += 1 ))
fi
done
if (( fails > 0 )); then
echo "$fails failures building arch-specific images"
exit 1
fi
echo "Done building $(<tools/toolchain/image). You can now test it, and push with"
echo ""
echo " podman manifest push --all $(<tools/toolchain/image) docker://$(<tools/toolchain/image)"