Created usage function
authoretrunko <eblima@gmail.com>
Tue, 4 Dec 2007 20:52:15 +0000 (20:52 +0000)
committeretrunko <eblima@gmail.com>
Tue, 4 Dec 2007 20:52:15 +0000 (20:52 +0000)
trunk/build-all.sh

index f62a7f9..127bd86 100755 (executable)
@@ -4,8 +4,15 @@ source "helper-functions.sh"
 __this_script=`basename $0`
 __this_script_dir=`dirname $0`
 
-# git definitions
+# Binaries
+__date=`which date`
 __git=`which git`
+__head=`which head`
+__mkdir=`which mkdir`
+__sed=`which sed`
+__uname=`which uname`
+
+# git definitions
 __git_clone="$__git clone"
 __git_pull="$__git pull"
 __git_clean="$__git clean"
@@ -24,7 +31,6 @@ __python_modules="python-evas:python-ecore:python-edje:python-epsilon:python-e_d
 __python_etk_module="python-etk"
 
 # dpkg definitions
-__uname=`which uname`
 __arch=`$__uname -m`
 __common_build_pkg_options="-rfakeroot -us -uc -D -tc"
 __build_pkg_options="$__common_build_pkg_options -sa"
@@ -32,21 +38,33 @@ if [ "x$__arch" = "xarm" ] ; then
     __build_pkg_options="$__common_build_pkg_options -B"
 fi
 
-# other definitions
-__sed=`which sed`
-__mkdir=`which mkdir`
-__date=`which date`
-__today=`$__date +%Y%m%d`
-
-__head=`which head`
+# Distro
 __distro=`$__head -1 /etc/apt/sources.list|cut -d" " -f3`
 
+# Packages dirs and log file
+__today=`$__date +%Y%m%d`
 __base_pkg_dir="$__this_script_dir/packages_$__today"
 __pkg_dir="$__base_pkg_dir/$__distro/$__arch"
-
 __output_file="$PWD/$__base_pkg_dir/packages_$__today.log"
 
+# Scratchbox definitions
+__scratchbox=/scratchbox
+
 # Function definitions
+function usage() {
+    cat << EOF
+
+Usage: $__this_script [OPTIONS]
+
+Build script for EFL debian packages for Maemo.
+
+Options:
+    -h      Show this usage guide.
+    -s PATH Specify alternate scratchbox path (default: $__scratchbox).
+
+EOF
+}
+
 function log_to_file() {
     local now
     local msg
@@ -76,7 +94,7 @@ function start_log() {
         error "start_log(): Could not create $__output_file file"
     fi
 
-cat << EOF >> $__output_file
+    cat << EOF >> $__output_file
 *********************************************************
 * Started $__this_script: $now *
 *********************************************************
@@ -96,7 +114,7 @@ function finish_log() {
         error "finish_log(): Log file does not exist"
     fi
 
-cat << EOF >> $__output_file
+    cat << EOF >> $__output_file
 
 * Finished $__this_script: $now
 EOF
@@ -164,6 +182,23 @@ function get_sources() {
     done
 }
 
+# Verify options
+while getopts "hs" opt ; do
+    case "$opt" in
+        h)
+            usage
+            exit 0
+            ;;
+        s)
+            __scratchbox=$OPTARG
+            ;;
+        [?])
+            usage
+            exit 1
+            ;;
+    esac
+done
+
 # Initial checks
 
 # Distro variable must not be empty
@@ -176,7 +211,7 @@ msg_begin "Checking for scratchbox environment"
 test -r /targets/links/scratchbox.config
 msg_end $?
 
-# Begin
+# Create packages dir and log file
 $__mkdir -p $__pkg_dir
 start_log
 log_to_file "Created $__pkg_dir"