diff options
-rwxr-xr-x | bin/injectdigs | 59 | ||||
-rwxr-xr-x | setup | 2 |
2 files changed, 60 insertions, 1 deletions
diff --git a/bin/injectdigs b/bin/injectdigs new file mode 100755 index 0000000..2414acd --- /dev/null +++ b/bin/injectdigs @@ -0,0 +1,59 @@ +#!/bin/sh + +PROG=injectdigs + +if [ $# -eq 0 ] +then + digstr="md5 sha512" +else + digstr=$* +fi + +if ! which openssl > /dev/null +then + echo "$PROG: openssl needs to be installed to calculate digests" + exit 2 +fi + +awk -v digstr="$digstr" -v prog="$PROG" ' +BEGIN { + diglen = split(digstr, digalgs) + FS = "\n"; RS = ""; ORS = "\n\n" +} + +function calcdigs(alg, files) +{ + cmd = "openssl " alg " " files + digests = "" + while(cmd | getline > 0){ + digests = digests $2 "\n" + } + close(cmd) + return digests +} + +1 + +$1 == "source" { + for(i = 2; i <= NF; i++){ + file = $i + sub(/.*\//, "", file) + if(system("test -f " file) != 0){ + print prog ": source file " file " is missing!" | "cat 1>&2" + exit 1 + } + files = files file " " + filelen++ + } +} + +END { + FS = " "; RS = "\n" + OFS = ORS = "\n" + if(!filelen) exit 0 + for(i = 1; i <= diglen; i++){ + alg = digalgs[i] + print alg "sums", calcdigs(alg, files) + } +} +' @@ -3,7 +3,7 @@ set -e umask 022 prog=setup -binfiles='genpkg mkpkgmeta modpkg pbfields putpkgtree getpkgtree' +binfiles='genpkg mkpkgmeta modpkg pbfields putpkgtree getpkgtree injectdigs' metas='perl perl.d/ perl.d/fetchcpan perl.d/perl-dist perl.d/perl-pkgbuild perl.d/scrapecore' |