build-aux/release.sh: fix shellcheck warnings

Too many to mention, but most are:

> SC2086 (info): Double quote to prevent globbing and word splitting

Use bash arrays where it make sense, and move the repeated stuff into
the BUILD_CMD.

PS I tried to make it more readable, but in some places with all the
added quotes it might actually become worse, so feel free to drop this
commit.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin
2025-04-24 16:37:27 -07:00
parent 5c14c0dc1b
commit 739a2bffa1
2 changed files with 33 additions and 24 deletions

View File

@@ -320,6 +320,6 @@ clang-format:
git ls-files src tests | grep -E "\\.[hc]" | grep -v "blake3\|chroot_realpath.c\|cloned_binary.c\|signals.c\|mount_flags.c" | xargs clang-format -style=file -i
shellcheck:
shellcheck autogen.sh tests/run_all_tests.sh tests/*/*.sh contrib/*.sh
shellcheck autogen.sh build-aux/release.sh tests/run_all_tests.sh tests/*/*.sh contrib/*.sh
.PHONY: coverity sync generate-rust-bindings generate-signals.c generate-mount_flags.c clang-format shellcheck

View File

@@ -13,54 +13,63 @@ test -e Makefile && make distclean
./configure
make -j $(nproc)
make -j "$(nproc)"
VERSION=$($(dirname $0)/git-version-gen --prefix "" .)
if test x$SKIP_CHECKS = x; then
grep $VERSION NEWS
VERSION="$("$(dirname "$0")/git-version-gen" --prefix "" .)"
if test "$SKIP_CHECKS" = ""; then
grep "$VERSION" NEWS
fi
OUTDIR=${OUTDIR:-release-$VERSION}
if test -e $OUTDIR; then
if test -e "$OUTDIR"; then
echo "the directory $OUTDIR already exists" >&2
exit 1
fi
mkdir -p $OUTDIR
mkdir -p "$OUTDIR"
rm -f crun-*.tar*
make dist-gzip
make ZSTD_OPT="--ultra -c22" dist-zstd
mv crun-*.tar.gz $OUTDIR
mv crun-*.tar.zst $OUTDIR
mv crun-*.tar.gz "$OUTDIR"
mv crun-*.tar.zst "$OUTDIR"
make distclean
RUNTIME=${RUNTIME:-podman}
RUNTIME_EXTRA_ARGS=${RUNTIME_EXTRA_ARGS:-}
read -r -a RUNTIME_EXTRA_ARGS <<< "${RUNTIME_EXTRA_ARGS:-}"
BUILD_CMD=(
"${RUNTIME:-podman}" run --init --rm
"${RUNTIME_EXTRA_ARGS[@]}"
--privileged
-v /nix:/nix -v "${PWD}:${PWD}"
-w "${PWD}"
"${NIX_IMAGE}"
nix
--extra-experimental-features nix-command
--print-build-logs
--option cores "$(nproc)"
--option max-jobs "$(nproc)"
build
--max-jobs auto
)
mkdir -p /nix
NIX_ARGS="--extra-experimental-features nix-command --print-build-logs --option cores $(nproc) --option max-jobs $(nproc)"
for ARCH in amd64 arm64 ppc64le riscv64 s390x; do
$RUNTIME run --init --rm $RUNTIME_EXTRA_ARGS --privileged -v /nix:/nix -v ${PWD}:${PWD} -w ${PWD} ${NIX_IMAGE} \
nix $NIX_ARGS build --max-jobs auto --file nix/default-${ARCH}.nix
cp ./result/bin/crun $OUTDIR/crun-$VERSION-linux-${ARCH}
"${BUILD_CMD[@]}" --file nix/default-${ARCH}.nix
cp ./result/bin/crun "$OUTDIR/crun-$VERSION-linux-${ARCH}"
rm -rf result
$RUNTIME run --init --rm $RUNTIME_EXTRA_ARGS --privileged -v /nix:/nix -v ${PWD}:${PWD} -w ${PWD} ${NIX_IMAGE} \
nix $NIX_ARGS build --max-jobs auto --file nix/default-${ARCH}.nix --arg enableSystemd false
cp ./result/bin/crun $OUTDIR/crun-$VERSION-linux-${ARCH}-disable-systemd
"${BUILD_CMD[@]}" --file nix/default-${ARCH}.nix --arg enableSystemd false
cp ./result/bin/crun "$OUTDIR/crun-$VERSION-linux-${ARCH}-disable-systemd"
rm -rf result
done
if test x$SKIP_GPG = x; then
for i in $OUTDIR/*; do
gpg2 -b --armour $i
if test "$SKIP_GPG" = ""; then
for i in "$OUTDIR"/*; do
gpg2 -b --armour "$i"
done
fi