2023-03-09 09:23:42 -05:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
shopt -s inherit_errexit
|
|
|
|
|
|
|
|
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
|
|
|
|
REPOSITORY_ROOT="${REPOSITORY_ROOT:-$(cd "${SCRIPT_DIR}" && git rev-parse --show-toplevel)}"
|
|
|
|
|
2023-04-12 11:41:13 -04:00
|
|
|
goos() {
|
|
|
|
case "$(uname -sr)" in
|
|
|
|
Darwin*) echo 'darwin' ;;
|
|
|
|
Linux*) echo 'linux' ;;
|
|
|
|
*)
|
|
|
|
echo 'Unknown OS' >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
goarch() {
|
|
|
|
case $(uname -m) in
|
|
|
|
x86_64) echo 'amd64' ;;
|
|
|
|
arm) echo 'arm64' ;; # this is slightly simplified, but we only care about arm64
|
2023-04-26 02:54:20 -04:00
|
|
|
arm64) echo 'arm64' ;;
|
2023-04-12 11:41:13 -04:00
|
|
|
*)
|
|
|
|
echo 'Unknown arch' >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2023-03-09 09:23:42 -05:00
|
|
|
ensure_pseudo_version_tool() {
|
|
|
|
if [[ ! -f "${REPOSITORY_ROOT}/tools/pseudo-version" ]]; then
|
2023-04-12 11:41:13 -04:00
|
|
|
get_pseudo_version_tool
|
|
|
|
fi
|
|
|
|
expected=$(cat "${REPOSITORY_ROOT}/tools/pseudo_version_$(goos)_$(goarch).sha256")
|
2023-04-26 02:54:20 -04:00
|
|
|
if ! shasum -a 256 -c --status <(echo "${expected} ${REPOSITORY_ROOT}/tools/pseudo-version"); then
|
2023-04-12 11:41:13 -04:00
|
|
|
get_pseudo_version_tool
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
get_pseudo_version_tool() {
|
|
|
|
out="${REPOSITORY_ROOT}/tools/pseudo-version"
|
|
|
|
hash=$(cat "${REPOSITORY_ROOT}/tools/pseudo_version_$(goos)_$(goarch).sha256")
|
|
|
|
url=https://cdn.confidential.cloud/constellation/cas/sha256/${hash}
|
|
|
|
if command -v curl &> /dev/null; then
|
|
|
|
curl -fsSL "${url}" -o "${out}"
|
|
|
|
elif command -v wget &> /dev/null; then
|
|
|
|
wget -q -O "${out}" "${url}"
|
|
|
|
else
|
|
|
|
echo "curl or wget is required to download the pseudo-version tool" >&2
|
|
|
|
exit 1
|
2023-03-09 09:23:42 -05:00
|
|
|
fi
|
2023-04-12 11:41:13 -04:00
|
|
|
chmod +x "${out}"
|
2023-03-09 09:23:42 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
pseudo_version() {
|
2023-03-14 09:53:33 -04:00
|
|
|
ensure_pseudo_version_tool
|
|
|
|
"${REPOSITORY_ROOT}/tools/pseudo-version" -skip-v
|
2023-03-09 09:23:42 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
timestamp() {
|
|
|
|
ensure_pseudo_version_tool
|
|
|
|
"${REPOSITORY_ROOT}/tools/pseudo-version" -print-timestamp -timestamp-format '2006-01-02T15:04:05Z07:00'
|
|
|
|
}
|
|
|
|
|
2023-03-20 11:05:08 -04:00
|
|
|
echo "REPO_URL https://github.com/edgelesssys/constellation.git"
|
2023-03-09 09:23:42 -05:00
|
|
|
echo "STABLE_STAMP_COMMIT $(git rev-parse HEAD)"
|
2023-03-31 06:41:32 -04:00
|
|
|
echo "STABLE_STAMP_STATE $(git update-index -q --really-refresh && git diff-index --quiet HEAD -- && echo "clean" || echo "dirty")"
|
2023-03-09 09:23:42 -05:00
|
|
|
echo "STABLE_STAMP_VERSION $(pseudo_version)"
|
|
|
|
echo "STABLE_STAMP_TIME $(timestamp)"
|