diff options
author | Justin Davis <jrcd83@gmail.com> | 2012-04-16 00:39:15 +0200 |
---|---|---|
committer | Justin Davis <jrcd83@gmail.com> | 2012-04-16 00:39:15 +0200 |
commit | f5cff74bb9665b4de3eb7cf16ed0504da0ee599e (patch) | |
tree | 115fbc8b7bac9bf1693377992409ba4d800deb12 | |
parent | 52d178a3bff39f62e6e6607610ad90444779af50 (diff) | |
download | genpkg-f5cff74bb9665b4de3eb7cf16ed0504da0ee599e.tar.gz genpkg-f5cff74bb9665b4de3eb7cf16ed0504da0ee599e.tar.xz |
New injectdigs script.
This takes PKGDATA on standard input printing it to standard
output. Digests for each file entry in the source array are
printed along with the other PKGDATA fields.
-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' |