Proper options for id-pbuild-all.sh
authorAdam Dickmeiss <adam@indexdata.dk>
Thu, 25 Mar 2010 12:31:13 +0000 (13:31 +0100)
committerAdam Dickmeiss <adam@indexdata.dk>
Thu, 25 Mar 2010 12:31:13 +0000 (13:31 +0100)
The id-pbuild-all.sh script takes options --debian, --ubuntu, --update,
--upload and --concurrency .

id-deb-build/id-pbuild-all.sh

index b93a9f1..4541116 100755 (executable)
@@ -1,48 +1,98 @@
 #!/bin/sh
+
+usage()
+{
+    cat <<EOF
+Usage: id-pbuild-all.sh [OPTIONS]
+Options:
+       [--debian=distros]
+       [--ubuntu=distros]
+       [--update=true|false]
+       [--upload]
+       [--concurrency=N]
+EOF
+    exit $1
+}
+
+# things that might be set by options
+upload=false
 update=true
+do_help=false
+concurrency=4
+DEBIAN_DIST=${DEBIAN_DIST:="squeeze etch lenny"}
+UBUNTU_DIST=${UBUNTU_DIST:="karmic jaunty intrepid hardy"}
+
 if test -f IDMETA; then
-       . ./IDMETA
+    . ./IDMETA
+fi
+while test $# -gt 0; do
+    case "$1" in
+       -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+       *) optarg= ;;
+    esac
+    
+    case $1 in
+       --ubuntu=*)
+           UBUNTU_DIST=$optarg
+           ;;
+       --debian=*)
+           DEBIAN_DIST=$optarg
+           ;;
+        --update=*)
+           update=$optarg
+           ;;
+        --concurrency=*)
+           concurrency=$optarg
+           ;;
+        --upload)
+           upload=true
+           ;;
+       -*)
+           do_help=yes
+           ;;
+    esac
+    shift
+done
+
+if test "$do_help" = "yes"; then
+    usage 1 1>&2
 fi
+
 if test -d deb-src; then
-       cd deb-src
+    cd deb-src
 fi
 for f in *.dsc; do
-       if test -f "$f"; then
-               PKG=$f
-       fi
+    if test -f "$f"; then
+       PKG=$f
+    fi
 done
 if test -z "$PKG"; then
-       echo "Specify .dsc file"
-       exit 1
+    echo "Specify .dsc file"
+    exit 1
 fi
 if test ! -e "$PKG"; then
-       echo "${PKG} does not exist"
-       exit 1
+    echo "${PKG} does not exist"
+    exit 1
 fi
 PRODUCT=`echo *.dsc|sed 's/_.*//g'`
-if test -z "$DEBIAN_DIST"; then
-       DEBIAN_DIST="squeeze etch lenny"
-fi
-if test -z "$UBUNTU_DIST"; then
-       UBUNTU_DIST="karmic jaunty intrepid hardy"
-fi
 
-if test "$1" = "upload"; then
-       for dist in ${UBUNTU_DIST}; do
-               scp ${dist}-*/* ftp.indexdata.dk:/home/ftp/pub/${PRODUCT}/ubuntu/${dist}
-       done
-       for dist in ${DEBIAN_DIST}; do
-               scp ${dist}-*/* ftp.indexdata.dk:/home/ftp/pub/${PRODUCT}/debian/${dist}
-       done
-       echo "Remember to update APT on ftp.indexdata.dk"
-       echo "cd git-tools/update-archive"
-       echo "sudo su"
-       echo "./update-archive.sh"
-       exit 0
+echo "Dsc $PKG . Product $PRODUCT"
+echo "Ubuntu distros: $UBUNTU_DIST"
+echo "Debian distros: $DEBIAN_DIST"
+if $upload; then
+    for dist in ${UBUNTU_DIST}; do
+       scp ${dist}-*/* ftp.indexdata.dk:/home/ftp/pub/${PRODUCT}/ubuntu/${dist}
+    done
+    for dist in ${DEBIAN_DIST}; do
+       scp ${dist}-*/* ftp.indexdata.dk:/home/ftp/pub/${PRODUCT}/debian/${dist}
+    done
+    echo "Remember to update APT on ftp.indexdata.dk"
+    echo "cd git-tools/update-archive"
+    echo "sudo su"
+    echo "./update-archive.sh"
+    exit 0
 fi
 i=0
-concurrency=4
-echo "Building $PKG"
 date
 for dist in ${DEBIAN_DIST} ${UBUNTU_DIST}; do
     for arch in i386 amd64; do
@@ -77,3 +127,8 @@ for dist in ${DEBIAN_DIST} ${UBUNTU_DIST}; do
 done
 date
 echo "Done"
+# Local Variables:
+# mode:shell-script
+# sh-indentation: 2
+# sh-basic-offset: 4
+# End: