+ echo "make" > debian/$paket.build
+ chmod 755 debian/$paket.build
+ cmake .
+ popd >/dev/null
+}
+function check_unversioned {
+ # has to be called in the projects base directory
+ # result: "M" in stdout or nothing
+ set -e
+
+ # check if build is running in a sandbox
+ if ! [ -f .cm.ignore ]
+ then
+ # we create one
+ echo ".cm.ignore" > .cm.ignore
+ echo "debian.*" >> .cm.ignore
+ echo "up.*" >> .cm.ignore
+ fi
+
+ project=$(pwd)
+ project=${project##*/}
+ pushd .. >/dev/null
+ mCM $project -b -an > /dev/null
+ wc=$(wc $project.batch)
+ rm $project.batch
+ if [ "${wc:0:5}" != "0 0 0" ]
+ then
+ echo "M"
+ fi
+ popd >/dev/null
+}
+
+function set_build {
+ set -e
+ if [ -e .svn ]
+ then
+ version="0.0"
+ build=$(svnversion)
+ build=${build/:/-}
+ build="$build$(check_unversioned)"
+ elif [ -e .git ]
+ then
+ tag=$(git describe --tags --match "${paket}_*" 2>/dev/null) || true
+ if test -z "$tag"
+ then
+ # try generic "v_" tag
+ tag=$(git describe --tags --match "v_*" 2>/dev/null) || true
+ fi
+ if test -z "$tag"
+ then
+ tag="0.0-0TOP"
+ fi
+ changes=$(check_unversioned)
+ tag="$tag$changes"
+ version=${tag##*_}
+ version=${version%%-*}
+ build=${tag##*-}
+ else
+ echo "No configuration system found. Cannot determine version."
+ exit 1
+ fi
+}
+
+function check_version {
+ set -e
+
+ vline=$(head -1 debian/$paket.changelog)
+ vline=${vline%-*}
+ clversion=${vline#*(}
+ if [ $version = "0.0" ]
+ then
+ version=$clversion
+ return
+ fi
+
+ # do no check on a modified git repos
+ if [ "${build: -1}" == "M" ]
+ then
+ return
+ fi
+
+ if [ "$clversion" != $version ]
+ then
+ echo "version mismatch: git: $version, changelog: $clversion"
+ exit 1
+ fi
+}
+
+##############################################################################
+# Main program
+##############################################################################
+
+install_dir="/"
+while [ $OPTIND -le "$#" ]
+do
+ if getopts "a:C:i:Iv:V" opt
+ then
+ case $opt in
+ a) ARCH=$OPTARG
+ ;;
+ C) cross=$OPTARG
+ ;;
+ i) install_dir=$OPTARG
+ ;;
+ I) echo_usage
+ exit 0
+ ;;
+ v) optversion=$OPTARG
+ ;;
+ V) optversion="0.0"
+ ;;
+ \?) echo "Invalid option: -$OPTARG"
+ echo_usage
+ exit 1
+ ;;
+ :) echo "Option -$OPTARG requires an argument."
+ echo_usage
+ exit 1
+ ;;
+ esac
+ else
+ paket="${!OPTIND}"
+ eval OPTIND=OPTIND+1
+ fi
+done
+
+if [ -z "$paket" ]