btrfs-progs/ci/images/docker-run
David Sterba b02d151bd1 btrfs-progs: ci: fix docker-run argument parsing
The runner script allows to pass arguments to docker and the final
command, using the -- separator. This did not work as expected, the
arguments got concatenated to the first member, not all of them passed.
The following now works:

  $ ./docker-run --env CC=clang
  $ ./docker-run --env CC=clang --
  $ ./docker-run --env CC=clang -- /bin/bash

Signed-off-by: David Sterba <dsterba@suse.com>
2021-05-08 00:58:50 +02:00

23 lines
582 B
Bash
Executable File

#!/bin/bash
# Run the container
# $0 [docker arguments] [-- command and arguments]
prefix=kdave
image=$(basename `pwd` | tr '[A-Z]' '[a-z]')
declare -a ARGS
while [ $# -gt 0 ]; do
case "$1" in
--) shift; break;;
*) ARGS+=("$1"); shift;;
esac
done
echo "ARGS: ${ARGS[@]}"
echo "RUN : $@"
# Device mapper devices are not visible inside the environment if the /dev mount
# is the default one (tmpfs instead of devtmpfs)
# Mounts and loop device manipulation is required
docker run --mount type=bind,source=/dev,target=/dev -it --privileged "${ARGS[@]}" "$prefix/$image" "$@"