examples/deploy-container.sh: add extra-container version check

It now uses the same version check as
make-container.sh (which is called by run-tests.sh)
This commit is contained in:
Erik Arvstedt 2023-07-08 15:33:02 +02:00
parent 6c2d1108a4
commit 76dc7b92e1
No known key found for this signature in database
GPG Key ID: 33312B944DD97846
3 changed files with 15 additions and 13 deletions

View File

@ -87,6 +87,7 @@ read -rd '' src <<EOF || true
};
}
EOF
. "${BASH_SOURCE[0]%/*}"/../test/lib/extra-container-check-version.sh
extra-container shell -E "$src" "${runCmd[@]}"
# The container is automatically deleted at exit

View File

@ -0,0 +1,13 @@
containerBin=$(type -P extra-container) || true
if [[ ! ($containerBin && $(realpath "$containerBin") == *extra-container-0.12*) ]]; then
echo
echo "Building extra-container. Skip this step by adding extra-container 0.12 to PATH."
nix build --out-link /tmp/extra-container "${BASH_SOURCE[0]%/*}"/../..#extra-container
# When this script is run as root, e.g. when run in an extra-container shell,
# chown the gcroot symlink to the regular (login) user so that the symlink can be
# overwritten when this script is run without root.
if [[ $EUID == 0 ]]; then
chown "$(logname):" --no-dereference /tmp/extra-container
fi
export PATH="/tmp/extra-container/bin${PATH:+:}$PATH"
fi

View File

@ -71,18 +71,6 @@ while [[ $# -gt 0 ]]; do
esac
done
containerBin=$(type -P extra-container) || true
if [[ ! ($containerBin && $(realpath "$containerBin") == *extra-container-0.12*) ]]; then
echo
echo "Building extra-container. Skip this step by adding extra-container 0.12 to PATH."
nix build --out-link /tmp/extra-container "$scriptDir"/..#extra-container
# When this script is run as root, e.g. when run in an extra-container shell,
# chown the gcroot symlink to the regular (login) user so that the symlink can be
# overwritten when this script is run without root.
if [[ $EUID == 0 ]]; then
chown "$(logname):" --no-dereference /tmp/extra-container
fi
export PATH="/tmp/extra-container/bin${PATH:+:}$PATH"
fi
. "${BASH_SOURCE[0]%/*}"/extra-container-check-version.sh
exec "$container"/bin/container "$containerCommand" "$@"