| #!/bin/bash |
| # Copyright 2022 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| set -exo pipefail |
| |
| SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" |
| TOOL="$(basename "${SCRIPT_DIR}")" |
| TOOL_AWK_COMMAND='$2 == "version:" { print $3; }' |
| |
| # This runs in a new empty directory, unpack the CIPD package to verify |
| # its content and that it runs properly. |
| unzip -q "$1" |
| |
| # Run the tool binary and extract its version to verify it matches |
| # _3PP_VERSION. Note that the latter might have a suffix like -fuchsia1 |
| # that should be ignored. |
| ./"$TOOL" --version | tee stdout.txt |
| VERSION="$(awk "${TOOL_AWK_COMMAND}" stdout.txt)" |
| if [[ -z "${VERSION}" ]]; then |
| echo >&2 "Could not find $TOOL version!" |
| exit 1 |
| fi |
| |
| if [[ "${_3PP_VERSION#${VERSION}}" == "${_3PP_VERSION}" ]]; then |
| echo >&2 "Invalid ${TOOL} version (${VERSION}), does not match ${_3PP_VERSION}" |
| exit 1 |
| fi |
| |
| echo "All good!" |