Improve checks for directories used during release process.
authormrenzmann <mrenzmann@0192ed92-7a03-0410-a25b-9323aeb14dbd>
Thu, 31 Jul 2008 05:48:07 +0000 (05:48 +0000)
committermrenzmann <mrenzmann@0192ed92-7a03-0410-a25b-9323aeb14dbd>
Thu, 31 Jul 2008 05:48:07 +0000 (05:48 +0000)
git-svn-id: http://madwifi-project.org/svn/madwifi/trunk@3829 0192ed92-7a03-0410-a25b-9323aeb14dbd

scripts/make-release.bash

index 33adef0336cbacc1bd37da8112a39f8a6a3d90b5..b6e65d5bfe0fe044f9d754233ea89ee8c6dfe45b 100755 (executable)
@@ -3,6 +3,27 @@
 # Purpose: automate the process of tagging a release and packing a tarball
 # for it.
 
+# check_dir_prereq:
+# ensures that a given directory name exist and is writeable
+# note: $1 is expected to be set to the name of the variable that contains
+#       the name of the directory that is to be tested (indirect reference)
+function check_dir_prereq {
+       eval d="\$$1"
+       n="$1"
+    
+       if [[ ! -d "$d" || ! -w "$d" ]]; then
+               echo
+               echo "ERROR:"
+               echo -n "$n, currently set to $d, "
+               [[ ! -d "$d" ]] && echo "does not exist" || echo "is not writable"
+               echo
+               exit 1
+       fi
+}
+
+
+
+
 # check if the script has been called directly
 if [[ "$(basename $(pwd))" == "scripts" ]]; then
     echo
@@ -23,6 +44,11 @@ if [[ "$RELEASE_TMP" == "" || "$RELEASE_STORE" == "" ]]; then
     exit 1
 fi
 
+# make sure that the directories passed in RELEASE_TMP and RELEASE_STORE
+# actually exist and are writable for the caller
+check_dir_prereq "RELEASE_TMP"
+check_dir_prereq "RELEASE_STORE"
+
 # caller must have write access to the madwifi.org repository
 valid=0
 repos=$(svn info | grep "Repository Root" | cut -d" " -f3)
@@ -48,14 +74,6 @@ if [[ "$valid" != "1" ]]; then
 fi
 
 
-if [[ ! -d "$RELEASE_TMP" ]]; then
-    echo
-    echo "ERROR:"
-    echo "RELEASE_TMP seems to be wrong. $RELEASE_TMP: no such directory"
-    echo
-    exit 1
-fi
-
 # check if we're in the top-level directory of the snapshot
 if [[ ! -f ./release.h ]]; then
     echo