Files
scylladb/tools/toolchain/prepare
Avi Kivity 1e7cece837 tools: toolchain: prepare: use buildah multi-arch build instead of bash hacks
In 69af7a830b ("tools: toolchain: prepare: build arch images in parallel"),
we added parallel image generation. But it turns out that buildah can
do this natively (with the --platform option to specify architectures
and --jobs parameter to allow parallelism). This is simpler and likely
has better error handling than an ad-hoc bash script, so switch to it.

Closes #10734
2022-06-07 11:51:13 +03:00

50 lines
1.3 KiB
Bash
Executable File

#!/bin/bash -e
bv=$(buildah --version)
if (( $? != 0 )); then
echo install buildah 1.19.3 or later
exit 1
fi
# translate to array of version components
bv="${bv#buildah version }"
bv="${bv% (*}"
bv=(${bv//./ })
maj=${bv[0]}
min=${bv[1]}
patch=${bv[2]}
ok=$(( maj > 1 || ( maj == 1 && min > 19 ) || ( maj == 1 && min == 19 && patch >= 3 ) ))
if (( ! ok )); then
echo install buildah 1.19.3 or later
exit 1
fi
archs=(amd64 arm64 s390x)
# docker arch has a diffrent spelling than uname arch
arch_uname_amd64=x86_64
arch_uname_arm64=aarch64
arch_uname_s390x=s390x
for arch in "${archs[@]}"; do
# translate from docker arch to uname arch
indirect="arch_uname_${arch}"
arch_uname="${!indirect}"
if [[ "$(uname -m)" == "${arch_uname}" ]]; then
continue
fi
if [[ ! -f /proc/sys/fs/binfmt_misc/qemu-"${arch_uname}" ]]; then
echo install qemu-user-static
exit 1
fi
done
buildah bud "${archs[@]/#/--platform=linux/}" --jobs 0 --squash --no-cache --pull -f tools/toolchain/Dockerfile --manifest "$(<tools/toolchain/image)"
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)"