diff options
| author | Teddy Wing | 2022-03-31 23:57:37 +0200 |
|---|---|---|
| committer | Teddy Wing | 2022-03-31 23:58:21 +0200 |
| commit | 454a2404420759ebe07f26346eb1cea1449b1902 (patch) | |
| tree | 201761849ba5bcec5781559f48cd81e20f6473bf | |
| parent | eef75d8524c9d4c5b15b74194863fb3d71065239 (diff) | |
| download | macports-ports-454a2404420759ebe07f26346eb1cea1449b1902.tar.bz2 | |
Add scripts/port-checksums.sh
Add a script to generate the `checksums` line in Portfiles.
| -rwxr-xr-x | scripts/port-checksums.sh | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/scripts/port-checksums.sh b/scripts/port-checksums.sh new file mode 100755 index 0000000..9338cb7 --- /dev/null +++ b/scripts/port-checksums.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +# port-checksums.sh +# +# Output MacPorts Portfile checksums for a file. +# +# Example: +# checksums rmd160 c799daf7113027e02eb2e931d61a1936323ec044 \ +# sha256 f28dbeef1de974fa6c9e07ba78179a1dcf75fe5c1342cabde135e7d928045aee \ +# size 23341 + +# TODO: --append argument for `checksums-append` +# TODO: Help output +# TODO: Allow reading from standard input +# TODO: support multiple file inputs + +file="$1" + +rmd160="$(openssl dgst -sha256 "$file" | cut -d ' ' -f 2)" +sha256="$(shasum -a 256 "$file" | cut -d ' ' -f 1)" +size="$(wc -c "$file" | awk '{ print $1 }')" + +cat <<EOF +checksums rmd160 ${rmd160} \\ + sha256 ${sha256} \\ + size ${size} +EOF |
