Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweaks to docker build script #1688

Merged
merged 3 commits into from Oct 1, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 20 additions & 9 deletions src/test/docker/docker-run-checks.sh
Expand Up @@ -10,13 +10,14 @@
IMAGE=bionic-base
FLUX_SECURITY_VERSION=0.2.0
JOBS=2
MOUNT_HOME_ARGS="--volume=$HOME:/home/$USER -e HOME"

#
declare -r prog=${0##*/}
die() { echo -e "$prog: $@"; exit 1; }

#
declare -r long_opts="help,quiet,interactive,image:,flux-security-version:,jobs:,no-cache,distcheck,tag:"
declare -r long_opts="help,quiet,interactive,image:,flux-security-version:,jobs:,no-cache,no-home,distcheck,tag:"
declare -r short_opts="hqIdi:S:j:t:"
declare -r usage="
Usage: $prog [OPTIONS] -- [CONFIGURE_ARGS...]\n\
Expand All @@ -28,6 +29,7 @@ Uses the current git repo for the build.\n\
Options:\n\
-h, --help Display this message\n\
--no-cache Disable docker caching\n\
--no-home Skip mounting the host home directory\n\
-q, --quiet Add --quiet to docker-build\n\
-t, --tag=TAG If checks succeed, tag image as NAME\n\
-i, --image=NAME Use base docker image NAME (default=$IMAGE)\n\
Expand All @@ -38,21 +40,29 @@ Options:\n\
image with interactive shell.\n\
"

GETOPTS=`/usr/bin/getopt -u -o $short_opts -l $long_opts -n $prog -- $@`
if test $? != 0; then
die "$usage"
# check if running in OSX
if [[ "$(uname)" == "Darwin" ]]; then
# BSD getopt
GETOPTS=`/usr/bin/getopt $short_opts -- $*`
else
# GNU getopt
GETOPTS=`/usr/bin/getopt -u -o $short_opts -l $long_opts -n $prog -- $@`
if [[ $? != 0 ]]; then
die "$usage"
fi
eval set -- "$GETOPTS"
fi
eval set -- "$GETOPTS"
while true; do
case "$1" in
-h|--help) echo -ne "$usage"; exit 0 ;;
-q|--quiet) QUIET="--quiet"; shift ;;
-i|--image) IMAGE="$2"; shift 2 ;;
-S|--flux-security-version) FLUX_SECURITY_VERSION="$2"; shift 2 ;;
-j|--jobs) JOBS="$2"; shift 2 ;;
-I|--interactive) INTERACTIVE=${SHELL}; shift ;;
-I|--interactive) INTERACTIVE="/bin/bash"; shift ;;
-d|--distcheck) DISTCHECK=t; shift ;;
--no-cache) NO_CACHE="--no-cache"; shift ;;
--no-home) MOUNT_HOME_ARGS=""; shift ;;
-t|--tag) TAG="$2"; shift 2 ;;
--) shift; break; ;;
*) die "Invalid option '$1'\n$usage" ;;
Expand Down Expand Up @@ -84,7 +94,9 @@ travis_fold "docker_build" \
$TOP/src/test/docker/travis \
|| die "docker build failed"

echo "mounting $HOME as /home/$USER"
if [[ -n "$MOUNT_HOME_ARGS" ]]; then
echo "mounting $HOME as /home/$USER"
fi
echo "mounting $TOP as /usr/src"

export JOBS
Expand All @@ -93,8 +105,8 @@ export chain_lint

docker run --rm \
--workdir=/usr/src \
--volume=$HOME:/home/$USER \
--volume=$TOP:/usr/src \
$MOUNT_HOME_ARGS \
-e CC \
-e CXX \
-e LDFLAGS \
Expand All @@ -109,7 +121,6 @@ docker run --rm \
-e DISTCHECK \
-e chain_lint \
-e JOBS \
-e HOME \
-e USER \
-e TRAVIS \
${INTERACTIVE:+--tty --interactive} \
Expand Down