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

Add --build optional parameter to mkdocker.sh to allow use of podman #15888

Merged
merged 1 commit into from
Sep 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions buildenv/docker/mkdocker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ usage() {
echo "Options:"
echo " --help|-h print this help, then exit"
echo " --arch=... specify the processor architecture (default: host architecture)"
echo " --build build the docker image (overrides '--print')"
echo " --build[=engine] build the image (overrides '--print'). Optionally specify the engine (default: docker, or podman, if found)"
echo " --criu include CRIU"
echo " --cuda include CUDA header files"
echo " --dist=... specify the Linux distribution (e.g. centos, ubuntu)"
Expand Down Expand Up @@ -64,6 +64,8 @@ arch=
criu=no
cuda=no
dist=unspecified
engine=docker
engine_specified=0
freemarker=no
gen_git_cache=yes
jdk_versions=all
Expand All @@ -88,6 +90,11 @@ parse_options() {
--build)
action=build
;;
--build=*)
action=build
engine="${arg#*=}"
engine_specified=1
;;
--criu)
criu=3.16.1
;;
Expand Down Expand Up @@ -124,6 +131,15 @@ parse_options() {
;;
esac
done

# If --build was specified without an engine, and `docker` isn't on $PATH,
# and `podman` is on $PATH, then assume they're okay to use `podman`.
if [ "${action}" = build ] \
&& [ "${engine_specified}" -eq 0 ] \
&& ! command -v "$engine" >/dev/null 2>&1 \
&& command -v podman >/dev/null 2>&1 ; then
engine=podman
fi
}

validate_options() {
Expand Down Expand Up @@ -242,6 +258,11 @@ validate_options() {
exit 1
fi
done

if [ "${action}" = build ] && ! command -v "$engine" >/dev/null 2>&1 ; then
echo "Executable '$engine' could not be found. Update \$PATH or use another engine with '--build=engine'" >&2
exit 1
fi
}

build_cmd() {
Expand Down Expand Up @@ -889,7 +910,7 @@ fi
main() {
if [ $action = build ] ; then
prepare_user
print_dockerfile | docker $(build_cmd -)
print_dockerfile | $engine $(build_cmd -)
else
print_dockerfile
fi
Expand Down