Changeset View
Changeset View
Standalone View
Standalone View
contrib/release/make-sha256sums.sh
#!/usr/bin/env bash | #!/usr/bin/env bash | ||||
export LC_ALL=C | export LC_ALL=C | ||||
set -euo pipefail | set -euo pipefail | ||||
help_message() { | help_message() { | ||||
echo "Output sha256sums from Gitian build output." | (cat <<EOF | ||||
echo "Usage: $0 AssetDirectory > sha256sums" | Output sha256sums from Gitian build output. | ||||
Usage: $0 AssetDirectory Prefix > sha256sums | |||||
Prefix will be matched in the manifest and then removed from the final output. | |||||
EOF | |||||
) | |||||
} | } | ||||
if [ "$#" -ne 1 ]; then | |||||
echo "Error: Expects 1 argument: AssetDirectory" | |||||
exit 1 | |||||
fi | |||||
case $1 in | case $1 in | ||||
-h|--help) | -h|--help) | ||||
help_message | help_message | ||||
exit 0 | exit 0 | ||||
;; | ;; | ||||
esac | esac | ||||
if [ "$#" -ne 2 ]; then | |||||
echo "Error: Expects 2 arguments" | |||||
echo | |||||
help_message | |||||
exit 1 | |||||
fi | |||||
ASSET_DIR="$1" | |||||
PREFIX="$2" | |||||
# Trim off preceding whitespace that exists in the manifest | # Trim off preceding whitespace that exists in the manifest | ||||
trim() { | trim() { | ||||
sed 's/^\s*//' | sed 's/^\s*//' | ||||
} | } | ||||
# Get the hash of the source tarball and output that first | # Get the hash of the source tarball and output that first | ||||
cat "$1"/linux/bitcoin-abc-*linux-res.yml | grep -E "bitcoin-abc-[0-9.]+.tar.gz" | trim | cat "${ASSET_DIR}"/linux/bitcoin-abc-*linux-res.yml | grep -E "bitcoin-abc-[0-9.]+.tar.gz" | trim | ||||
strip_prefix() { | |||||
sed -E "s/ $1.?bitcoin-/ bitcoin-/" | |||||
} | |||||
# Output hashes of all of the binaries | # Output hashes of all of the binaries | ||||
cat "$1"/linux/bitcoin-abc-*linux-res.yml | grep -E "bitcoin-abc-[0-9.]+.*-linux-.*.tar.gz" | trim | cat "${ASSET_DIR}"/linux/bitcoin-abc-*linux-res.yml | \ | ||||
cat "$1"/win/bitcoin-abc-*win-res.yml | grep -E -- "bitcoin-abc-[0-9.]+-win.*.(exe|tar.gz|zip)" | trim | grep -E "${PREFIX}.?bitcoin-abc-[0-9.]+.*-linux-.*.tar.gz" | \ | ||||
cat "$1"/osx/bitcoin-abc-*osx-res.yml | grep -E -- "bitcoin-abc-[0-9.]+-osx.*.(dmg|tar.gz)" | trim | strip_prefix "${PREFIX}" | trim | ||||
cat "${ASSET_DIR}"/win/bitcoin-abc-*win-res.yml | \ | |||||
grep -E -- "${PREFIX}.?bitcoin-abc-[0-9.]+-win.*.(exe|tar.gz|zip)" | \ | |||||
strip_prefix "${PREFIX}" | trim | |||||
cat "${ASSET_DIR}"/osx/bitcoin-abc-*osx-res.yml | \ | |||||
grep -E -- "${PREFIX}.?bitcoin-abc-[0-9.]+-osx.*.(dmg|tar.gz)" | \ | |||||
strip_prefix "${PREFIX}" | trim |