5 echo "usage: mconfigure [options] <package>"
8 echo " -C <cross environment>"
10 echo " -p : pack default: do all"
11 echo " -o : support old Debian 7 format"
14 function cmake_check {
15 pushd ../build >/dev/null
17 if [ -e debian/$paket.build ]
19 echo "cmake is not compatible with other builds. Remove $paket.build"
22 if [ -e debian/$paket.prebuild ]
24 echo "cmake is not compatible with other builds. Remove $paket.prebuild"
30 # inject cross toolset
31 echo "set (CMAKE_MODULE_PATH $cross)" > CMakeLists.txt
32 echo "include(toolset)" >> CMakeLists.txt
33 cat debian/$paket.cmake >> CMakeLists.txt
35 cp debian/$paket.cmake CMakeLists.txt
38 echo "make" > debian/$paket.build
39 chmod 755 debian/$paket.build
43 function check_unversioned {
44 # has to be called in the projects base directory
45 # result: "M" in stdout or nothing
48 # check if build is running in a sandbox
49 if ! [ -f .cm.ignore ]
52 echo ".cm.ignore" > .cm.ignore
53 echo "debian.*" >> .cm.ignore
54 echo "up.*" >> .cm.ignore
58 project=${project##*/}
60 mCM $project -b -an > /dev/null
61 wc=$(wc $project.batch)
63 if [ "${wc:0:5}" != "0 0 0" ]
77 build="$build$(check_unversioned)"
80 tag=$(git describe --tags --match "${paket}_*" 2>/dev/null) || true
85 changes=$(check_unversioned)
88 version=${version%%-*}
91 echo "No configuration system found. Cannot determine version."
96 function check_version {
99 vline=$(head -1 debian/$paket.changelog)
101 clversion=${vline#*(}
102 if [ $version = "0.0" ]
108 # do no check on a modified git repos
109 if [ "${build: -1}" == "M" ]
114 if [ "$clversion" != $version ]
116 echo "version mismatch: git: $version, changelog: $clversion"
123 echo "run mconfigure in the project base directory with a debian directory in it!"
130 while getopts "a:cC:dpo" opt; do
144 \?) echo "Invalid option: -$OPTARG"
148 :) echo "Option -$OPTARG requires an argument."
164 if [ -n "$ARCH" -a -n "$cross" ]
166 echo "invalid options: supply -a for multiarch or -C for explicit cross compile environment"
170 # if nothing is selected, select all
171 if [ $configure -eq 0 -a $compile -eq 0 -a $pack -eq 0 ]
178 if [ $configure -eq 1 ]
180 # delete changelog and control
181 rm debian/changelog debian/control debian/README.debian debian/copyright 2>/dev/null || true
183 # mconfigure builds 2 environment files: setenv.sh + rules.pre
184 echo "" > debian/rules.pre
185 if [ -e debian/setenv.sh ]; then rm debian/setenv.sh; fi
189 if [ ${cross:0:1} != "/" ]
191 cross="/opt/cross/$cross"
194 if [ -f "$cross/setenv.sh" ]
197 cp $cross/setenv.sh debian/setenv.sh
201 # determine architecture
202 GNU_ARCH=${cross%-*} # assumed format: DEB_HOST_GNU_TYPE-g++version, e.g. arm-linux-gnueabihf-4.9
203 GNU_ARCH=${GNU_ARCH##*/}
204 arch_opt="-t $GNU_ARCH"
212 dpkg-architecture $arch_opt >> debian/setenv.sh
214 echo "paket=$paket" >> debian/setenv.sh
215 echo "oldpack=\"$oldpack\"" >> debian/setenv.sh
219 echo "version=$version" >> debian/setenv.sh
220 echo "build=$build" >> debian/setenv.sh
222 # get repository name
226 # echo "pwd=$pwd" >> debian/rules.pre
228 echo "building $paket with build $version-$build"
230 pushd debian >/dev/null
231 # ./debian -------------------------------------
233 ln -sf /usr/share/mbuild/rules .
240 # check for pre/post installation scripts
241 echo "TODO: check for conffiles"
242 if [ -f $paket.preinst ]
244 echo "add_inst_tgt += debian/tmp/DEBIAN/preinst" >> rules.pre
246 if [ -f $paket.postinst ]
248 echo "add_inst_tgt += debian/tmp/DEBIAN/postinst" >> rules.pre
250 if [ -f $paket.prerm ]
252 echo "add_inst_tgt += debian/tmp/DEBIAN/prerm" >> rules.pre
254 if [ -f $paket.postrm ]
256 echo "add_inst_tgt += debian/tmp/DEBIAN/postrm" >> rules.pre
259 # check for README.debian
260 if [ -f $paket.README.debian ]
262 cp $paket.README.debian README.debian
267 # add export to setenv.sh
268 sed -i "s/^/export /" setenv.sh
271 # ./. ---------------------------------------------
273 # copy package control
274 if [ -f debian/$paket.control ]
279 echo "warning: control file not found"
280 echo " this file is necessary for any package production."
284 if [ -x debian/$paket.prepare ]
287 debian/$paket.prepare
290 if [ -x debian/$paket.build -o -e debian/$paket.cmake ]
297 if grep -- "-prepare" debian/$paket.build >/dev/null
299 echo "prepare in <paket>.build no longer supported. Use <paket>.prebuild"
307 if [ -x debian/$paket.build ]
309 if [ -x debian/$paket.prebuild ]
311 pushd ../build >/dev/null
313 debian/$paket.prebuild
318 if [ -e debian/$paket.cmake ]
324 if [ -f debian/$paket.cp -a -f debian/$paket.control ]
326 echo "PACK=binary" >> debian/rules.pre
327 if grep "^Architecture: *all" debian/$paket.control >/dev/null
329 echo "arch = all" >> debian/rules.pre
330 echo "BINARY_INDEP = copy ../${paket}_$version-${build}_all.deb" >> debian/rules.pre
332 echo 'arch = ${DEB_HOST_ARCH}' >> debian/rules.pre
333 echo "BINARY_ARCH = copy ../${paket}_$version-${build}_"'$(arch).deb' >> debian/rules.pre
335 elif [ -f debian/$paket.cp ]
337 echo "PACK=zip" >> debian/rules.pre
339 echo "PACK=version" >> debian/rules.pre
343 if [ $compile -eq 1 ]
345 if [ -x debian/$paket.build -o -e debian/$paket.cmake ]
351 echo "skipping build step ..."