diff options
| -rwxr-xr-x | validate-checksum | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/validate-checksum b/validate-checksum index 49a46c5..ee94401 100755 --- a/validate-checksum +++ b/validate-checksum @@ -2,7 +2,7 @@ signature_key=3683C4B70CFA859F0173F2CCE0DD13EBFC7D5E3E -# Copyright © 2025 Mattias Andrée (m@maandree.se) +# Copyright © 2025, 2026 Mattias Andrée (m@maandree.se) # # Copying and distribution of this script, with or without modification, # are permitted in any medium without royalty provided the copyright @@ -13,10 +13,14 @@ signature_key=3683C4B70CFA859F0173F2CCE0DD13EBFC7D5E3E set -e usage () { - printf 'usage: %s hasher file\n' "$0" >&2 + printf 'usage: %s hasher file [project]\n' "$0" >&2 exit 1 } +if test $# -lt 2 || $# -gt 3; then + usage +fi + get_algo () { if test "$1" = sha224sum; then echo SHA224 elif test "$1" = sha256sum; then echo SHA256 @@ -38,6 +42,7 @@ signature_key="$(printf '%s\n' "${signature_key}" | tr -d ' ')" hasher="$(printf '%s\n' "$1" | sed 's/s$//')" file="$2" +proj="$3" if ! algo="$(get_algo "${hasher}")" || test ! -f "${file}"; then usage @@ -49,11 +54,15 @@ hash="$(${hasher} -- "${file}" | cut -d ' ' -f 1 | tr A-F a-f)" pkgname="$(basename -- "${file}" | sed -n 's/-[^-]*\.tar\.gz$//p')" pkgver="$(basename -- "${file}" | sed -n 's/^.*-\([^-]*\)\.tar\.gz$/\1/p')" +if test -z "${proj}"; then + proj="${pkgname}" +fi + if test -z "${pkgname}" || test -z "${pkgver}"; then usage fi -url="https://maandree.se/rel/$pkgname/$pkgver.html" +url="https://maandree.se/rel/$proj/$pkgver.html" page="$(curl -sL -- "${url}")" sigpage="$(curl -sL -- "${url}.sig")" |
