aboutsummaryrefslogtreecommitdiff
path: root/scripts/validate-archive
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/validate-archive')
-rwxr-xr-xscripts/validate-archive55
1 files changed, 55 insertions, 0 deletions
diff --git a/scripts/validate-archive b/scripts/validate-archive
new file mode 100755
index 0000000..2d14066
--- /dev/null
+++ b/scripts/validate-archive
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+set -e
+set -u
+
+fatal () {
+ echo "$@" >&2
+ exit 1
+}
+
+archive="$1"
+shift
+
+if ! [ -f "$archive" ]; then
+ fatal "No such file: $archive"
+fi
+
+
+ok=0
+
+for item in "$@"; do
+ oIFS="$IFS"; IFS=':'
+ set -- $item
+ m="$1"
+ v="$2"
+ IFS="$oIFS"
+ case "$m" in
+ sha1|sha256|md5)
+ printf "$m: $archive: "
+ sum=`${m}sum "$archive" | awk '{print $1}'`
+ if [ "$sum" = "$v" ]; then
+ echo "OK"
+ else
+ echo "FAILED (got:$sum, expected:$v)"
+ ok=1
+ fi
+ ;;
+ size)
+ printf "$m: $archive: "
+ size=`stat -c '%s' "$archive"`
+ if [ "$size" = "$v" ]; then
+ echo "OK"
+ else
+ echo "FAILED (got:$size, expected:$v)"
+ ok=1
+ fi
+ ;;
+ *)
+ fatal "Unsupported method: $m"
+ ;;
+ esac
+done
+
+exit $ok
+