posaune
[projects.git] / tools / make / configure
index 0771d51..32b2558 100755 (executable)
@@ -5,6 +5,8 @@ function echo_usage {
        echo "usage: configure <package> <revision> [options]"
        echo "  -b <branch-rev>"
        echo "  -a <arch>"
+       echo "  -g <alternative repository>"
+       echo "  -n : do not delete src dir"
 }
 
 # to build a package you need ...
@@ -20,13 +22,33 @@ fi
 
 paket=$1
 build=$2
+shift 2
 ARCH=""
 cpp_build=0
+alt_repos=""
+delete_src=1
+
+while getopts ":a:b:g:n" opt; do
+       case $opt in
+               a) ARCH=$OPTARG
+                       ;;
+               b) branch=$OPTARG
+                       ;;
+               g) alt_repos="-g $OPTARG"
+                       ;;
+               n) delete_src=0
+                       ;;
+               \?) echo "Invalid option: -$OPTARG"
+                       echo_usage
+                       exit 1
+                       ;;
+               :) echo "Option -$OPTARG requires an argument."
+                       echo_usage
+                       exit 1
+                       ;;
+       esac
+done
 
-# checkout build utilities
-if [ ! -d projects ]; then
-       git clone https://github.com/wagner-tech/projects/
-fi
 ln -sf projects/tools/make/makefile .
 
 # check standard files
@@ -35,13 +57,13 @@ then
        echo "file $paket.co missing or not executable."
        exit 1
 fi
-if [ ! -x $paket.cp ]
+
+# clean dirs and check out
+if [ -d src -a $delete_src -eq 1 ]
 then
-       echo "warning: file $paket.cp missing or not executable:"
-       echo "  this file is necessary for any package production."
+       rm -rf src
 fi
 
-# clean dirs and check out
 if [ -e $paket ]
 then
        rm -rf $paket
@@ -54,7 +76,7 @@ cwd=$(pwd)
 
 # checkout
 pushd src >/dev/null
-       ../$paket.co $build
+       ../$paket.co $alt_repos $build 
 popd >/dev/null
 
 # load util functions for C/C++ - build
@@ -79,6 +101,15 @@ else
        version=$(grep Version $paket.control |sed "s/Version: //")
 fi
 
+# check for copy file
+copy=$(find src -name $paket.cp)
+if [ -n "$copy" ]
+then
+       ln -sf $copy .
+else
+       echo "warning: file $paket.cp missing or not executable:"
+       echo "  this file is necessary for any package production."
+fi
 
 # check for postinst
 postinst=$(find src -name $paket.postinst)
@@ -100,4 +131,5 @@ fi
 
 # append version to make.pre
 echo "version = $version" >> make.pre
+echo "build = $build" >> make.pre