2019-01-18 14:09:23 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# This tool fetches versions and checksums of build tools from the .TOOLVERSIONS
|
|
|
|
# file in project root. This is then used by various setup scripts,
|
|
|
|
# and most importantly by Dockerfiles.
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
GIT_ROOT=$(git rev-parse --show-toplevel)
|
|
|
|
TOOL_VERSIONS_FILE="${GIT_ROOT}/.TOOLVERSIONS"
|
|
|
|
|
|
|
|
usage () {
|
|
|
|
echo "Usage: toolversion [-c] <name>" >&2
|
|
|
|
echo
|
2019-01-23 10:11:31 +00:00
|
|
|
echo "This script extracts tooling versions from ${TOOL_VERSIONS_FILE}"
|
2019-01-18 14:09:23 +00:00
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
# some options parsing
|
|
|
|
while getopts ":ch" opt; do
|
|
|
|
case $opt in
|
|
|
|
c) CHECKSUM=1; shift ;;
|
|
|
|
h) usage;;
|
|
|
|
\?) echo "Invalid option: -$OPTARG" >&2; exit 1;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
# verify the main argument was given
|
|
|
|
if [[ -z "${1}" ]]; then usage; fi
|
|
|
|
|
|
|
|
NAME=${1}
|
|
|
|
|
|
|
|
getColumn () {
|
2019-01-26 15:36:12 +00:00
|
|
|
local value=$(awk -F';' "/^${NAME};/{print \$${1}}" "${TOOL_VERSIONS_FILE}")
|
|
|
|
[ -z "$value" ] && echo "\nUnexpected missing value for ${NAME} in ${TOOL_VERSIONS_FILE}" && exit 1
|
|
|
|
echo $value
|
2019-01-18 14:09:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if [[ $CHECKSUM ]]; then
|
|
|
|
getColumn 3
|
|
|
|
else
|
|
|
|
getColumn 2
|
|
|
|
fi
|