Sdd a helper script to validate the contents of a MANIFEST
authorSteve McIntyre <steve.mcintyre@arm.com>
Thu, 7 May 2020 18:54:10 +0000 (19:54 +0100)
committerSteve McIntyre <steve.mcintyre@arm.com>
Thu, 7 May 2020 18:54:10 +0000 (19:54 +0100)
scripts/check_MANIFEST [new file with mode: 0755]

diff --git a/scripts/check_MANIFEST b/scripts/check_MANIFEST
new file mode 100755 (executable)
index 0000000..1b7a562
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/sh
+#
+# check_MANIFEST
+#
+# Simple helper script. Check that the files mentioned in a MANIFEST
+# file are correct
+#
+# <FILENAME>:<MODE>:<BYTES>:<SHA256>
+#
+# Apart from the MANIFEST itself, all files offered up for download
+# should be compressed with gzip. In each case, the runtime script
+# will download $FILENAME.gz, decompress it and then validate the
+# checksum
+
+for LINE in $(cat MANIFEST); do
+    FILENAME=$(echo $LINE | awk -F: '{print $1}')
+    MODE=$(echo $LINE | awk -F: '{print $2}')
+    BYTES=$(echo $LINE | awk -F: '{print $3}')
+    SHA=$(echo $LINE | awk -F: '{print $4}')
+
+    SHA_FILE=$(gzip -cd $FILENAME.gz | sha256sum | awk '{print $1}')
+    if [ $SHA_FILE != $SHA ]; then
+        echo "ERROR: Failed to validate $FILENAME.gz correctly"
+    else
+        echo "GOOD:  $FILENAME.gz"
+    fi
+done
+