To be on the safe side, add some asserts to the script.

Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/05d73f86
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/05d73f86
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/05d73f86

Branch: refs/heads/trunk
Commit: 05d73f86e883027dee36452c51ddd338f5ed0fc9
Parents: 5b60e4f
Author: Tomaz Muraus <[email protected]>
Authored: Tue Dec 31 14:49:13 2013 +0100
Committer: Tomaz Muraus <[email protected]>
Committed: Tue Dec 31 14:49:13 2013 +0100

----------------------------------------------------------------------
 dist/verify_checksums.sh | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/05d73f86/dist/verify_checksums.sh
----------------------------------------------------------------------
diff --git a/dist/verify_checksums.sh b/dist/verify_checksums.sh
index 52cb9a2..c739dd1 100755
--- a/dist/verify_checksums.sh
+++ b/dist/verify_checksums.sh
@@ -34,6 +34,30 @@ EXTENSIONS[2]="zip"
 APACHE_MIRROR_URL="http://www.apache.org/dist/libcloud";
 PYPI_MIRROR_URL="https://pypi.python.org/packages/source/a/apache-libcloud";
 
+# From http://tldp.org/LDP/abs/html/debugging.html#ASSERT
+function assert ()                 #  If condition false,
+{                         #+ exit from script
+                          #+ with appropriate error message.
+  E_PARAM_ERR=98
+  E_ASSERT_FAILED=99
+
+
+  if [ -z "$2" ]          #  Not enough parameters passed
+  then                    #+ to assert() function.
+    return $E_PARAM_ERR   #  No damage done.
+  fi
+
+  lineno=$2
+
+  if [ ! $1 ]
+  then
+    echo "Assertion failed:  \"$1\""
+    echo "File \"$0\", line $lineno"    # Give name of file and line number.
+    exit $E_ASSERT_FAILED
+  fi
+}
+
+
 echo "Comparing checksums for version: ${VERSION}"
 echo "Downloaded files will be stored in: ${TMP_DIR}"
 echo ""
@@ -46,9 +70,13 @@ do
     apache_url="${APACHE_MIRROR_URL}/${file_name}"
     pypi_url="${PYPI_MIRROR_URL}/${file_name}"
 
+    assert "${apache_url} != ${pypi_url}", "URLs must be different"
+
     file_name_apache="${file_name}-apache"
     file_name_pypi="${file_name}-pypi"
 
+    assert "${file_name_apache} != ${file_name_pypi}", "file names must be 
different"
+
     file_path_apache="${TMP_DIR}/${file_name_apache}"
     file_path_pypi="${TMP_DIR}/${file_name_pypi}"
 

Reply via email to