5 echo "usage: configure [options] <package>"
8 echo " -C <cross environment>"
10 echo " -i : install dir. default: /"
11 echo " -I : print this info"
12 echo " -p : pack default: do all"
13 echo " -v : set version"
14 echo " -V : version set by project"
17 function cmake_check {
18 pushd ../build >/dev/null
20 if [ -e debian/$paket.build ]
22 echo "cmake is not compatible with other builds. Remove $paket.build"
25 if [ -e debian/$paket.prebuild ]
27 echo "cmake is not compatible with other builds. Remove $paket.prebuild"
33 # inject cross toolset
34 echo "set (CMAKE_MODULE_PATH $cross)" > CMakeLists.txt
35 echo "include(toolset)" >> CMakeLists.txt
36 cat debian/$paket.cmake >> CMakeLists.txt
38 cp debian/$paket.cmake CMakeLists.txt
41 echo "make" > debian/$paket.build
42 chmod 755 debian/$paket.build
46 function check_unversioned {
47 # has to be called in the projects base directory
48 # result: "M" in stdout or nothing
51 # check if build is running in a sandbox
52 if ! [ -f .cm.ignore ]
55 echo ".cm.ignore" > .cm.ignore
56 echo "debian.*" >> .cm.ignore
57 echo "up.*" >> .cm.ignore
61 project=${project##*/}
63 mCM $project -b -an > /dev/null
64 wc=$(wc $project.batch)
66 if [ "${wc:0:5}" != "0 0 0" ]
80 build="$build$(check_unversioned)"
83 tag=$(git describe --tags --match "${paket}_*" 2>/dev/null) || true
86 # try generic "v_" tag
87 tag=$(git describe --tags --match "v_*" 2>/dev/null) || true
93 changes=$(check_unversioned)
96 version=${version%%-*}
99 echo "No configuration system found. Cannot determine version."
104 function check_version {
107 vline=$(head -1 debian/$paket.changelog)
109 clversion=${vline#*(}
110 if [ $version = "0.0" ]
116 # do no check on a modified git repos
117 if [ "${build: -1}" == "M" ]
122 if [ "$clversion" != $version ]
124 echo "version mismatch: git: $version, changelog: $clversion"
129 ##############################################################################
131 ##############################################################################
134 while [ $OPTIND -le "$#" ]
136 if getopts "a:C:i:Iv:V" opt
143 i) install_dir=$OPTARG
148 v) optversion=$OPTARG
152 \?) echo "Invalid option: -$OPTARG"
156 :) echo "Option -$OPTARG requires an argument."
173 if [ -n "$ARCH" -a -n "$cross" ]
175 echo "invalid options: supply -a for multiarch or -C for explicit cross compile environment"
181 ln -s /usr/share/mbuild/rules Makefile
184 # delete changelog and control
185 rm debian/changelog debian/control debian/README.debian debian/copyright 2>/dev/null || true
187 # mconfigure builds 2 environment files: setenv.sh + rules.pre
188 echo "paket=$paket" > debian/rules.pre
189 echo "INSTALL_DIR=$install_dir" >> debian/rules.pre
190 if [ -e debian/setenv.sh ]; then rm debian/setenv.sh; fi
194 if [ ${cross:0:1} != "/" ]
196 cross="/opt/cross/$cross"
199 if [ -f "$cross/setenv.sh" ]
202 cp $cross/setenv.sh debian/setenv.sh
206 # determine architecture
207 GNU_ARCH=${cross%-*} # assumed format: DEB_HOST_GNU_TYPE-g++version, e.g. arm-linux-gnueabihf-4.9
208 GNU_ARCH=${GNU_ARCH##*/}
209 arch_opt="-t $GNU_ARCH"
217 dpkg-architecture $arch_opt >> debian/setenv.sh
219 echo "paket=$paket" >> debian/setenv.sh
220 echo "oldpack=\"$oldpack\"" >> debian/setenv.sh
223 if [ -z "$optversion" ]
229 echo "version=$version" >> debian/rules.pre
230 echo "build=$build" >> debian/rules.pre
232 # get repository name
236 # echo "pwd=$pwd" >> debian/rules.pre
238 echo "building $paket with version/build=$version-$build"
240 pushd debian >/dev/null
241 # ./debian -------------------------------------
243 ln -sf /usr/share/mbuild/rules .
250 # check for pre/post installation scripts
251 if [ -f $paket.preinst ]
253 echo "add_inst_tgt += debian/tmp/DEBIAN/preinst" >> rules.pre
255 if [ -f $paket.postinst ]
257 echo "add_inst_tgt += debian/tmp/DEBIAN/postinst" >> rules.pre
259 if [ -f $paket.prerm ]
261 echo "add_inst_tgt += debian/tmp/DEBIAN/prerm" >> rules.pre
263 if [ -f $paket.postrm ]
265 echo "add_inst_tgt += debian/tmp/DEBIAN/postrm" >> rules.pre
268 # check for README.debian
269 if [ -f $paket.README.debian ]
271 cp $paket.README.debian README.debian
276 # add export to setenv.sh
277 sed -i "s/^/export /" setenv.sh
280 # ./. ---------------------------------------------
282 # copy package control
283 if [ -f debian/$paket.control ]
288 echo "warning: control file not found"
289 echo " this file is necessary for any package production."
293 if [ -x debian/$paket.prepare ]
296 debian/$paket.prepare
300 if [ -x debian/$paket.build -o -e debian/$paket.cmake ]
303 echo "BUILD=build" >> debian/rules.pre
304 if [ -n "$BUILD_DIR" ]
309 echo "BUILD=nobuild" >> debian/rules.pre
312 if [ -x debian/$paket.build ]
314 if [ -x debian/$paket.prebuild ]
316 pushd $BUILD_DIR >/dev/null
318 debian/$paket.prebuild
323 if [ -e debian/$paket.cmake ]
329 if [ -f debian/$paket.cp -a -f debian/$paket.control ]
331 echo "PACK=binary" >> debian/rules.pre
332 if grep "^Architecture: *all" debian/$paket.control >/dev/null
334 echo "arch = all" >> debian/rules.pre
335 echo 'BINARY_INDEP = copy ../$(paket)_$(version)-$(build)_all.deb' >> debian/rules.pre
337 echo 'arch = ${DEB_HOST_ARCH}' >> debian/rules.pre
338 echo "BINARY_ARCH = copy ../${paket}_$version-${build}_"'$(arch).deb' >> debian/rules.pre
340 if ! [ -f debian/$paket.changelog ]
342 echo "changelog_source = debian/default.changelog" >> debian/rules.pre
343 if [ -f debian/default.changelog ]
345 rm debian/default.changelog
348 elif [ -f debian/$paket.cp ]
350 echo "PACK=zip" >> debian/rules.pre
352 echo "PACK=version" >> debian/rules.pre