Changeset View
Changeset View
Standalone View
Standalone View
contrib/verifybinaries/verify.sh
Show All 24 Lines | |||||
BASEDIR="https://bitcoin.org/bin/" | BASEDIR="https://bitcoin.org/bin/" | ||||
VERSIONPREFIX="bitcoin-core-" | VERSIONPREFIX="bitcoin-core-" | ||||
RCVERSIONSTRING="rc" | RCVERSIONSTRING="rc" | ||||
if [ ! -d "$WORKINGDIR" ]; then | if [ ! -d "$WORKINGDIR" ]; then | ||||
mkdir "$WORKINGDIR" | mkdir "$WORKINGDIR" | ||||
fi | fi | ||||
cd "$WORKINGDIR" | cd "$WORKINGDIR" || exit 1 | ||||
deadalnix: It's probably a good idea to enforce setting various bash flags with a linter, such as `set… | |||||
#test if a version number has been passed as an argument | #test if a version number has been passed as an argument | ||||
if [ -n "$1" ]; then | if [ -n "$1" ]; then | ||||
#let's also check if the version number includes the prefix 'bitcoin-', | #let's also check if the version number includes the prefix 'bitcoin-', | ||||
# and add this prefix if it doesn't | # and add this prefix if it doesn't | ||||
if [[ $1 == "$VERSIONPREFIX"* ]]; then | if [[ $1 == "$VERSIONPREFIX"* ]]; then | ||||
VERSION="$1" | VERSION="$1" | ||||
else | else | ||||
VERSION="$VERSIONPREFIX$1" | VERSION="$VERSIONPREFIX$1" | ||||
fi | fi | ||||
#now let's see if the version string contains "rc", and strip it off if it does | #now let's see if the version string contains "rc", and strip it off if it does | ||||
# and simultaneously add RCSUBDIR to BASEDIR, where we will look for SIGNATUREFILENAME | # and simultaneously add RCSUBDIR to BASEDIR, where we will look for SIGNATUREFILENAME | ||||
if [[ $VERSION == *"$RCVERSIONSTRING"* ]]; then | if [[ $VERSION == *"$RCVERSIONSTRING"* ]]; then | ||||
BASEDIR="$BASEDIR${VERSION/%-$RCVERSIONSTRING*}/" | BASEDIR="$BASEDIR${VERSION/%-$RCVERSIONSTRING*}/" | ||||
BASEDIR="$BASEDIR$RCSUBDIR.$RCVERSIONSTRING${VERSION: -1}/" | BASEDIR="$BASEDIR$RCSUBDIR.$RCVERSIONSTRING${VERSION: -1}/" | ||||
else | else | ||||
BASEDIR="$BASEDIR$VERSION/" | BASEDIR="$BASEDIR$VERSION/" | ||||
fi | fi | ||||
SIGNATUREFILE="$BASEDIR$SIGNATUREFILENAME" | |||||
else | else | ||||
echo "Error: need to specify a version on the command line" | echo "Error: need to specify a version on the command line" | ||||
exit 2 | exit 2 | ||||
fi | fi | ||||
#first we fetch the file containing the signature | #first we fetch the file containing the signature | ||||
WGETOUT=$(wget -N "$BASEDIR$SIGNATUREFILENAME" 2>&1) | WGETOUT=$(wget -N "$BASEDIR$SIGNATUREFILENAME" 2>&1) | ||||
#and then see if wget completed successfully | #and then see if wget completed successfully | ||||
if [ $? -ne 0 ]; then | if [ $? -ne 0 ]; then | ||||
echo "Error: couldn't fetch signature file. Have you specified the version number in the following format?" | echo "Error: couldn't fetch signature file. Have you specified the version number in the following format?" | ||||
echo "[$VERSIONPREFIX]<version>-[$RCVERSIONSTRING[0-9]] (example: "$VERSIONPREFIX"0.10.4-"$RCVERSIONSTRING"1)" | echo "[$VERSIONPREFIX]<version>-[$RCVERSIONSTRING[0-9]] (example: ${VERSIONPREFIX}0.10.4-${RCVERSIONSTRING}1)" | ||||
echo "wget output:" | echo "wget output:" | ||||
echo "$WGETOUT"|sed 's/^/\t/g' | echo "$WGETOUT"|sed 's/^/\t/g' | ||||
exit 2 | exit 2 | ||||
fi | fi | ||||
#then we check it | #then we check it | ||||
GPGOUT=$(gpg --yes --decrypt --output "$TMPFILE" "$SIGNATUREFILENAME" 2>&1) | GPGOUT=$(gpg --yes --decrypt --output "$TMPFILE" "$SIGNATUREFILENAME" 2>&1) | ||||
▲ Show 20 Lines • Show All 53 Lines • Show Last 20 Lines |
It's probably a good idea to enforce setting various bash flags with a linter, such as set -euxo pipefail or alike.