From 9394564918533c4f5fa266db93aace06cc26881d Mon Sep 17 00:00:00 2001 From: "James P. Ketrenos" Date: Tue, 3 Dec 2019 10:55:11 -0800 Subject: [PATCH] Added scripts/build.sh (missed with last xe-solutions update) Signed-off-by: James P. Ketrenos --- scripts/build.sh | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100755 scripts/build.sh diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100755 index 0000000..2a5034b --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# Bring in the variables from SOLUTION file, supporting +# nested substitution +. SOLUTION + +function fail { + >&2 echo "$*" + exit -1 +} + +case "${OS_DISTRO}" in + rhel) + SOLUTION_SUFFIX=".rhel-8.0" + ;; + ubuntu) + SOLUTION_SUFFIX="" + ;; + *) + SOLUTION_SUFFIX=".${OS_DISTRO}-${OS_RELEASE}" + [[ -d "templates/${OS_DISTRO}" ]] || { + echo "Unrecognized OS_DISTRO: '${OS_DISTRO}'" + exit -1 + } + [[ ! -e "Dockerfile.solution.${SOLUTION_SUFFIX}" ]] && { + SOLUTION_SUFFIX="" + } + ;; +esac + +[[ ! -e "Dockerfile${SOLUTION_SUFFIX}" ]] && { + cat << EOF +'${OS_DISTRO}' set as OS_DISTRO, but Dockerfile${SOLUTION_SUFFIX} does +not exist. + +Using Dockerfile instead. +EOF + + SOLUTION_SUFFIX="" +} + +export DOCKERFILE="Dockerfile${SOLUTION_SUFFIX}" +export SOLUTION="Dockerfile.solution${SOLUTION_SUFFIX}" + +[[ "${SOLUTION}" -nt "${DOCKERFILE}" ]] && { + echo "${SOLUTION} is newer than ${DOCKERFILE}. Running scripts/build-dockerfile.sh" + scripts/build-dockerfile.sh || fail "Unable to update ${DOCKERFILE}" +} + +scripts/build-image.sh || fail "Unable to build ${DOCKERFILE}"