1
0
intel-media-ffmpeg/scripts/build-dockerfile
James Ketrenos 82aba14ec6 Red Hat images can now be built and pushed. See README.md
Signed-off-by: James Ketrenos <james.p.ketrenos@intel.com>
2019-11-07 11:59:01 -08:00

103 lines
2.0 KiB
Bash
Executable File

#!/bin/bash
# Determine if it is Mac OS and switch to use gxargs instead
CMD=xargs
if [ $(which system_profiler) ]; then
CMD=gxargs
fi
# Bring in the variables from SOLUTION file, supporting
# nested substitution
. SOLUTION
. MANIFEST
VARS=($(sed -nE "s,(^[^#][^=]*).*$,\1,pg" SOLUTION))
VARS+=($(sed -nE "s,(^[^#][^=]*).*$,\1,pg" MANIFEST))
for var in ${VARS[@]}; do
export ${var}
done
case "${OS_DISTRO}" in
rhel)
SOLUTION_SUFFIX=".rhel-8.0"
;;
ubuntu)
SOLUTION_SUFFIX=""
;;
*)
echo "Unrecognized OS_DISTRO: '${OS_DISTRO}'"
exit -1
;;
esac
export DOCKERFILE="Dockerfile${SOLUTION_SUFFIX}"
export SOLUTION="Dockerfile.solution${SOLUTION_SUFFIX}"
VARS+=("DOCKERFILE")
VARS+=("SOLUTION")
# Build a SHELL-FORMAT value to pass to envsubst.
# Only those variables matched in SHELL-FORMAT will
# be escaped by envsubst.
ENV=''
for var in ${VARS[@]}; do
ENV=${ENV}'$'${var}
done
# Remove the Dockerfile if it exists; should check
# if it is clean first, and abort if not.
#
[ -e ${DOCKERFILE} ] && rm ${DOCKERFILE}
cat << EOM > ${DOCKERFILE}
#
# DO NOT EDIT THIS DOCKERFILE
#
# This file is auto-generated via scripts/build-dockerfile
# by using environment substitution while concatenating the
# contents of templates/*, and then adding the contents
# of ${SOLUTION}
#
# Most solution specific changes should be isolated in
# ${SOLUTION}. After making changes, you can then re-run
# scripts/build-dockerfile
#
EOM
for snippet in templates/${OS_DISTRO}/??-*.in; do
cat << EOM >> ${DOCKERFILE}
#
# Template from ${snippet}
#
EOM
envsubst ${ENV} < $snippet >> ${DOCKERFILE}
done
cat << EOM >> ${DOCKERFILE}
#
# Solution begins here (from ${SOLUTION})
#
EOM
envsubst ${ENV} < ${SOLUTION} >> ${DOCKERFILE}
cat << EOM >> ${DOCKERFILE}
#
# Standard ending begins here (from templates/ending.in)
#
EOM
envsubst ${ENV} < templates/ending.in >> ${DOCKERFILE}
cat << EOM
${DOCKERFILE} has been updated.
To build the image, you can run:
OS_DISTRO=${OS_DISTRO} OS_RELEASE=${OS_RELEASE} scripts/build-images
EOM