status-mobile/scripts/toolversion
Jakub Sokołowski 984404b9e2
change .TOOLVERSION into csv, add toolversion script
Signed-off-by: Jakub Sokołowski <jakub@status.im>
Signed-off-by: Pedro Pombeiro <pombeirp@users.noreply.github.com>
2019-01-18 22:43:11 +01:00

44 lines
1.0 KiB
Bash
Executable File

#!/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
echo "This script extract tooling versions from ${TOOL_VERSIONS_FILE}"
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 () {
awk -F';' "/^${NAME};/{print \$${1}}" "${TOOL_VERSIONS_FILE}"
}
if [[ $CHECKSUM ]]; then
getColumn 3
else
getColumn 2
fi