# 255 - A suitable download or checksum utility is missing
[ -n "$1" ] || {
+ echo "$0 - Download and verify build artifacts"
echo "Usage: $0 <url>" >&2
exit 1
}
echo "Cleaning up."
rm -r "/tmp/verify.$$"
}
- exit $1
+ exit "$1"
}
trap "finish 254" INT TERM
checksum() { sha256sum -c --ignore-missing "sha256sums"; }
elif which shasum >/dev/null; then
checksum() {
- local sum="$(shasum -a 256 "$image_file")";
+ local sum
+ sum="$(shasum -a 256 "$image_file")";
grep -xF "${sum%% *} *$image_file" "sha256sums";
}
else
}
fi
-mkdir -p "/tmp/verify.$$"
-cd "/tmp/verify.$$"
+tmpdir="$(mktemp -d)"
+cd "$tmpdir" || {
+ echo "Failed to create temporary directory!" >&2
+ finish 255
+}
echo ""
-echo "1) Downloading image file"
+echo "1) Downloading artifact file"
echo "========================="
download "$image_file" "$image_url" || {
echo "Failed to download image file!" >&2
echo "" >&2
while true; do
- printf "Keyserver to use? [$keyserver_url] > "
- read url; case "${url:-$keyserver_url}" in
+ printf 'Keyserver to use? [%s] > ' "$keyserver_url"
+ read -r url; case "${url:-$keyserver_url}" in
hkp://*)
gpg --keyserver "${url:-$keyserver_url}" --recv-keys "$missing_key" || {
echo "Failed to download public key." >&2
echo ""
echo "Verification done!"
echo "=================="
-echo "Firmware image placed in '$destdir/$image_file'."
+echo "Downloaded artifact placed in '$destdir/$image_file'."
echo ""
finish 0