fix: support bash v3 by removing array usage (#705)

This commit is contained in:
Reuben Miller 2023-09-25 15:59:25 +02:00 committed by Serge Schneider
parent 446f3e34c8
commit ed68013abb

View File

@ -1,6 +1,8 @@
#!/bin/bash -eu
#!/usr/bin/env bash
# Note: Avoid usage of arrays as MacOS users have an older version of bash (v3.x) which does not supports arrays
set -eu
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
DIR="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd)"
BUILD_OPTS="$*"
@ -93,18 +95,12 @@ ${DOCKER} build --build-arg BASE_IMAGE=${BASE_IMAGE} -t pi-gen "${DIR}"
if [ "${CONTAINER_EXISTS}" != "" ]; then
DOCKER_CMDLINE_NAME="${CONTAINER_NAME}_cont"
DOCKER_CMDLINE_PRE=( \
--rm \
)
DOCKER_CMDLINE_POST=( \
--volumes-from="${CONTAINER_NAME}" \
)
DOCKER_CMDLINE_PRE="--rm"
DOCKER_CMDLINE_POST="--volumes-from=\"${CONTAINER_NAME}\""
else
DOCKER_CMDLINE_NAME="${CONTAINER_NAME}"
DOCKER_CMDLINE_PRE=( \
)
DOCKER_CMDLINE_POST=( \
)
DOCKER_CMDLINE_PRE=""
DOCKER_CMDLINE_POST=""
fi
# Check if binfmt_misc is required
@ -145,7 +141,7 @@ fi
trap 'echo "got CTRL+C... please wait 5s" && ${DOCKER} stop -t 5 ${DOCKER_CMDLINE_NAME}' SIGINT SIGTERM
time ${DOCKER} run \
"${DOCKER_CMDLINE_PRE[@]}" \
$DOCKER_CMDLINE_PRE \
--name "${DOCKER_CMDLINE_NAME}" \
--privileged \
--cap-add=ALL \
@ -154,7 +150,7 @@ time ${DOCKER} run \
${PIGEN_DOCKER_OPTS} \
--volume "${CONFIG_FILE}":/config:ro \
-e "GIT_HASH=${GIT_HASH}" \
"${DOCKER_CMDLINE_POST[@]}" \
$DOCKER_CMDLINE_POST \
pi-gen \
bash -e -o pipefail -c "
dpkg-reconfigure qemu-user-static &&