diff options
| author | Mattias Andrée <m@maandree.se> | 2026-02-22 22:36:36 +0100 |
|---|---|---|
| committer | Mattias Andrée <m@maandree.se> | 2026-02-22 22:36:36 +0100 |
| commit | bba93a2129c29ab516d438482086072db0392b71 (patch) | |
| tree | a30b5e0a65dedfaeea711e368691ffba9322c3b4 | |
| parent | Fix typo (diff) | |
| download | release-scripts-bba93a2129c29ab516d438482086072db0392b71.tar.gz release-scripts-bba93a2129c29ab516d438482086072db0392b71.tar.bz2 release-scripts-bba93a2129c29ab516d438482086072db0392b71.tar.xz | |
Update validate-checksum to check $# and allow upstream project name as third argument (in case renamed to downstream name)
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to '')
| -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")" |
