PKGBUILDs/devel/container/makecontainerpkg

35 lines
905 B
Bash
Executable File

#!/bin/bash
set -e
# parse arguments
cre_args=(--workdir "/startdir" -v "$PWD":/startdir --rm)
script_args= read_script_args= no_sync=
for arg in "$@"; do
if [[ $read_script_args ]]; then
if [[ $arg == '--nodeps' ]] || [[ $arg == '-d' ]]; then
no_sync=1
fi
script_args+=" '$arg'"
else
if [[ $arg == '--' ]]; then
read_script_args=1
else
cre_args+=("$arg")
fi
fi
done
# load "containerbuild" and "containersync" script
bindir=$(dirname "$0")
script=$(cat "$bindir/containerbuild")
if ! [[ $no_sync ]]; then
script_sync=$(cat "$bindir/containersync")
fi
# allow one to prevent the container from stopping via DEBUG variable
if [[ $DEBUG ]]; then
script_args+=' ; sleep infinity'
fi
${CRE:-docker} run "${cre_args[@]}" "${CRE_IMAGE:-archlinux-base-devel}" bash -c "$script_sync $script $script_args"