[SCM] Installer for game data files branch, master, updated. 2f1f027bc6b48d3230ca299719c5b28715cb56ce
Simon McVittie
smcv at debian.org
Thu Jul 14 08:09:24 UTC 2011
The following commit has been merged in the master branch:
commit 2d12656341ba47ec987404c169972c7e48b01270
Author: Simon McVittie <smcv at debian.org>
Date: Thu Jul 14 09:05:46 2011 +0100
Add verify_md5sum_alternatives function
diff --git a/Makefile b/Makefile
index a7a7ffa..3e4336d 100644
--- a/Makefile
+++ b/Makefile
@@ -52,4 +52,7 @@ clean:
make -f wolf3d.mk VERSION=$(VERSION) clean
for d in $(DIRS); do [ ! -d "$$d" ] || rmdir "$$d"; done
-.PHONY: default clean
+check:
+ ./t/verify-md5sum-alternatives.sh
+
+.PHONY: default clean check
diff --git a/lib/game-data-packager-shared b/lib/game-data-packager-shared
index 129d9af..2e33571 100644
--- a/lib/game-data-packager-shared
+++ b/lib/game-data-packager-shared
@@ -67,6 +67,23 @@ verify_md5sum() {
[ "$SUM" = "$GOODSUM" ] || die "$FILE's md5 checksum is unknown"
}
+## verify_md5sum_alternatives(file,sums)
+## calculates the md5sum of file and compares it to sums (comma-separated).
+## if the sum doesn't match any of them, complains on stderr and causes
+## the program to exit.
+verify_md5sum_alternatives() {
+ FILE=$1
+ GOODSUMS=$2
+ SUM=`md5sum $FILE|cut -d' ' -f1`
+ case ",$GOODSUMS," in
+ (*,$SUM,*)
+ ;;
+ (*)
+ die "$FILE's md5 checksum $SUM is unknown"
+ ;;
+ esac
+}
+
## verify_directory(dir)
## ensures dir is a directory, or complains on stderr
## and causes the program to exit.
diff --git a/t/verify-md5sum-alternatives.sh b/t/verify-md5sum-alternatives.sh
new file mode 100755
index 0000000..8dc0b58
--- /dev/null
+++ b/t/verify-md5sum-alternatives.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+. lib/game-data-packager-shared
+
+echo "foo" > out/foo
+echo "bar" > out/bar
+echo "baz" > out/baz
+
+foosum=`md5sum out/foo | cut -d' ' -f1`
+barsum=`md5sum out/bar | cut -d' ' -f1`
+
+verify_md5sum_alternatives out/foo $foosum,$barsum
+verify_md5sum_alternatives out/bar $foosum,$barsum
+if ( verify_md5sum_alternatives out/baz $foosum,$barsum ); then
+ die "out/baz should have failed the md5sum check!"
+else
+ echo "^ don't worry, that was meant to fail the md5sum check"
+fi
--
Installer for game data files
More information about the Pkg-games-commits
mailing list