[SCM] Installer for game data files branch, master, updated. 691eb2f7b00d7352de22abb21bcae9a30a59bb52

Jon Dowland jmtd at debian.org
Tue Apr 5 21:53:10 UTC 2011


The following commit has been merged in the master branch:
commit 691eb2f7b00d7352de22abb21bcae9a30a59bb52
Author: Jon Dowland <jmtd at debian.org>
Date:   Tue Apr 5 22:53:10 2011 +0100

    make use of die() inside other lib routines

diff --git a/lib/game-data-packager-shared b/lib/game-data-packager-shared
index 8a1740c..dcfbf88 100644
--- a/lib/game-data-packager-shared
+++ b/lib/game-data-packager-shared
@@ -43,6 +43,19 @@ warn() {
 	echo "WARNING: $*" >&2
 }
 
+## die(string,retcode)
+##      end the program, complaining with string on stderr
+##      and returning retcode if supplied, 2 if not.
+die() { 
+    if [ $# -lt 2 ]; then
+        RET=2
+    else
+        RET=$2
+    fi
+	echo $0: $1 >&2
+	exit $RET
+}
+
 ## verify_md5sum(file,sum)
 ##      calculates the md5sum of file and compares it to sum.
 ##      if the sum doesn't match, complains on stderr and causes the program
@@ -51,12 +64,7 @@ verify_md5sum() {
 	FILE=$1
 	GOODSUM=$2
 	SUM=`md5sum $FILE|cut -d' ' -f1`
-	if [ "$SUM" != "$GOODSUM" ]; then
-		echo "error: $FILE's md5 checksum is unknown." >&2
-		echo "perhaps it is corrupted?" >&2
-		echo "quitting." >&2
-		exit 1
-	fi
+	[ "$SUM" = "$GOODSUM" ] || die "$FILE's md5 checksum is unknown"
 }
 
 ## verify_directory(dir)
@@ -64,10 +72,7 @@ verify_md5sum() {
 ##      and causes the program to exit.
 verify_directory() {
 	DIR=$1
-	if [ ! -d "$DIR" ]; then
-		echo "error: $DIR is not a directory. Quitting." >&2
-		exit 1
-	fi
+	[ -d "$DIR" ] || die "$DIR is not a directory" 
 }
 
 ## verify_file(file)
@@ -75,23 +80,7 @@ verify_directory() {
 ##      and causes the program to exit.
 verify_file() {
 	FILE=$1
-	if [ ! -f "$FILE" ]; then
-		echo "error: $FILE is not a file. Quitting." >&2
-		exit 1
-	fi
-}
-
-## die(string,retcode)
-##      end the program, complaining with string on stderr
-##      and returning retcode if supplied, 2 if not.
-die() { 
-    if [ $# -lt 2 ]; then
-        RET=2
-    else
-        RET=$2
-    fi
-	echo $0: $1 >&2
-	exit $RET
+	[ -f "$FILE" ] || die "$FILE is not a file"
 }
 
 ## slipstream(deb,relpath,file1,file2...)

-- 
Installer for game data files



More information about the Pkg-games-commits mailing list