5 echo "usage: mconfigure [options] <package>"
8 echo " -C <cross environment>"
10 echo " -p : pack default: do all"
11 echo " -v : set version"
12 echo " -V : version set by project"
13 echo " -o : support old Debian 7 format"
16 function cmake_check {
17 pushd ../build >/dev/null
19 if [ -e debian/$paket.build ]
21 echo "cmake is not compatible with other builds. Remove $paket.build"
24 if [ -e debian/$paket.prebuild ]
26 echo "cmake is not compatible with other builds. Remove $paket.prebuild"
32 # inject cross toolset
33 echo "set (CMAKE_MODULE_PATH $cross)" > CMakeLists.txt
34 echo "include(toolset)" >> CMakeLists.txt
35 cat debian/$paket.cmake >> CMakeLists.txt
37 cp debian/$paket.cmake CMakeLists.txt
40 echo "make" > debian/$paket.build
41 chmod 755 debian/$paket.build
45 function check_unversioned {
46 # has to be called in the projects base directory
47 # result: "M" in stdout or nothing
50 # check if build is running in a sandbox
51 if ! [ -f .cm.ignore ]
54 echo ".cm.ignore" > .cm.ignore
55 echo "debian.*" >> .cm.ignore
56 echo "up.*" >> .cm.ignore
60 project=${project##*/}
62 mCM $project -b -an > /dev/null
63 wc=$(wc $project.batch)
65 if [ "${wc:0:5}" != "0 0 0" ]
79 build="$build$(check_unversioned)"
82 tag=$(git describe --tags --match "${paket}_*" 2>/dev/null) || true
85 # try generic "v_" tag
86 tag=$(git describe --tags --match "v_*" 2>/dev/null) || true
92 changes=$(check_unversioned)
95 version=${version%%-*}
98 echo "No configuration system found. Cannot determine version."
103 function check_version {
106 vline=$(head -1 debian/$paket.changelog)
108 clversion=${vline#*(}
109 if [ $version = "0.0" ]
115 # do no check on a modified git repos
116 if [ "${build: -1}" == "M" ]
121 if [ "$clversion" != $version ]
123 echo "version mismatch: git: $version, changelog: $clversion"
128 ##############################################################################
130 ##############################################################################
134 echo "run mconfigure in the project base directory with a debian directory in it!"
141 while [ $OPTIND -le "$#" ]
143 if getopts "a:cC:dpov:V" opt
158 v) optversion=$OPTARG
162 \?) echo "Invalid option: -$OPTARG"
166 :) echo "Option -$OPTARG requires an argument."
183 if [ -n "$ARCH" -a -n "$cross" ]
185 echo "invalid options: supply -a for multiarch or -C for explicit cross compile environment"
189 # if nothing is selected, select all
190 if [ $configure -eq 0 -a $compile -eq 0 -a $pack -eq 0 ]
197 if [ $configure -eq 1 ]
199 # delete changelog and control
200 rm debian/changelog debian/control debian/README.debian debian/copyright 2>/dev/null || true
202 # mconfigure builds 2 environment files: setenv.sh + rules.pre
203 echo "" > debian/rules.pre
204 if [ -e debian/setenv.sh ]; then rm debian/setenv.sh; fi
208 if [ ${cross:0:1} != "/" ]
210 cross="/opt/cross/$cross"
213 if [ -f "$cross/setenv.sh" ]
216 cp $cross/setenv.sh debian/setenv.sh
220 # determine architecture
221 GNU_ARCH=${cross%-*} # assumed format: DEB_HOST_GNU_TYPE-g++version, e.g. arm-linux-gnueabihf-4.9
222 GNU_ARCH=${GNU_ARCH##*/}
223 arch_opt="-t $GNU_ARCH"
231 dpkg-architecture $arch_opt >> debian/setenv.sh
233 echo "paket=$paket" >> debian/setenv.sh
234 echo "oldpack=\"$oldpack\"" >> debian/setenv.sh
237 if [ -z "$optversion" ]
243 echo "version=$version" >> debian/setenv.sh
244 echo "build=$build" >> debian/setenv.sh
246 # get repository name
250 # echo "pwd=$pwd" >> debian/rules.pre
252 echo "building $paket with version/build=$version-$build"
254 pushd debian >/dev/null
255 # ./debian -------------------------------------
257 ln -sf /usr/share/mbuild/rules .
264 # check for pre/post installation scripts
265 if [ -f $paket.preinst ]
267 echo "add_inst_tgt += debian/tmp/DEBIAN/preinst" >> rules.pre
269 if [ -f $paket.postinst ]
271 echo "add_inst_tgt += debian/tmp/DEBIAN/postinst" >> rules.pre
273 if [ -f $paket.prerm ]
275 echo "add_inst_tgt += debian/tmp/DEBIAN/prerm" >> rules.pre
277 if [ -f $paket.postrm ]
279 echo "add_inst_tgt += debian/tmp/DEBIAN/postrm" >> rules.pre
282 # check for README.debian
283 if [ -f $paket.README.debian ]
285 cp $paket.README.debian README.debian
290 # add export to setenv.sh
291 sed -i "s/^/export /" setenv.sh
294 # ./. ---------------------------------------------
296 # copy package control
297 if [ -f debian/$paket.control ]
302 echo "warning: control file not found"
303 echo " this file is necessary for any package production."
307 if [ -x debian/$paket.prepare ]
310 debian/$paket.prepare
313 if [ -x debian/$paket.build -o -e debian/$paket.cmake ]
320 if grep -- "-prepare" debian/$paket.build >/dev/null
322 echo "prepare in <paket>.build no longer supported. Use <paket>.prebuild"
330 if [ -x debian/$paket.build ]
332 if [ -x debian/$paket.prebuild ]
334 pushd ../build >/dev/null
336 debian/$paket.prebuild
341 if [ -e debian/$paket.cmake ]
347 if [ -f debian/$paket.cp -a -f debian/$paket.control ]
349 echo "PACK=binary" >> debian/rules.pre
350 if grep "^Architecture: *all" debian/$paket.control >/dev/null
352 echo "arch = all" >> debian/rules.pre
353 echo 'BINARY_INDEP = copy ../$(paket)_$(version)-$(build)_all.deb' >> debian/rules.pre
355 echo 'arch = ${DEB_HOST_ARCH}' >> debian/rules.pre
356 echo "BINARY_ARCH = copy ../${paket}_$version-${build}_"'$(arch).deb' >> debian/rules.pre
358 if ! [ -f debian/$paket.changelog ]
360 echo "changelog_source = debian/default.changelog" >> debian/rules.pre
361 if [ -f debian/default.changelog ]
363 rm debian/default.changelog
366 elif [ -f debian/$paket.cp ]
368 echo "PACK=zip" >> debian/rules.pre
370 echo "PACK=version" >> debian/rules.pre
374 if [ $compile -eq 1 ]
376 if [ -x debian/$paket.build -o -e debian/$paket.cmake ]
382 echo "skipping build step ..."