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 " -o : support old Debian 7 format"
15 function cmake_check {
16 pushd ../build >/dev/null
18 if [ -e debian/$paket.build ]
20 echo "cmake is not compatible with other builds. Remove $paket.build"
23 if [ -e debian/$paket.prebuild ]
25 echo "cmake is not compatible with other builds. Remove $paket.prebuild"
31 # inject cross toolset
32 echo "set (CMAKE_MODULE_PATH $cross)" > CMakeLists.txt
33 echo "include(toolset)" >> CMakeLists.txt
34 cat debian/$paket.cmake >> CMakeLists.txt
36 cp debian/$paket.cmake CMakeLists.txt
39 echo "make" > debian/$paket.build
40 chmod 755 debian/$paket.build
44 function check_unversioned {
45 # has to be called in the projects base directory
46 # result: "M" in stdout or nothing
49 # check if build is running in a sandbox
50 if ! [ -f .cm.ignore ]
53 echo ".cm.ignore" > .cm.ignore
54 echo "debian.*" >> .cm.ignore
55 echo "up.*" >> .cm.ignore
59 project=${project##*/}
61 mCM $project -b -an > /dev/null
62 wc=$(wc $project.batch)
64 if [ "${wc:0:5}" != "0 0 0" ]
78 build="$build$(check_unversioned)"
81 tag=$(git describe --tags --match "${paket}_*" 2>/dev/null) || true
86 changes=$(check_unversioned)
89 version=${version%%-*}
92 echo "No configuration system found. Cannot determine version."
97 function check_version {
100 vline=$(head -1 debian/$paket.changelog)
102 clversion=${vline#*(}
103 if [ $version = "0.0" ]
109 # do no check on a modified git repos
110 if [ "${build: -1}" == "M" ]
115 if [ "$clversion" != $version ]
117 echo "version mismatch: git: $version, changelog: $clversion"
124 echo "run mconfigure in the project base directory with a debian directory in it!"
131 while getopts "a:cC:dpov:" opt; do
145 v) optversion=$OPTARG
147 \?) echo "Invalid option: -$OPTARG"
151 :) echo "Option -$OPTARG requires an argument."
167 if [ -n "$ARCH" -a -n "$cross" ]
169 echo "invalid options: supply -a for multiarch or -C for explicit cross compile environment"
173 # if nothing is selected, select all
174 if [ $configure -eq 0 -a $compile -eq 0 -a $pack -eq 0 ]
181 if [ $configure -eq 1 ]
183 # delete changelog and control
184 rm debian/changelog debian/control debian/README.debian debian/copyright 2>/dev/null || true
186 # mconfigure builds 2 environment files: setenv.sh + rules.pre
187 echo "" > debian/rules.pre
188 if [ -e debian/setenv.sh ]; then rm debian/setenv.sh; fi
192 if [ ${cross:0:1} != "/" ]
194 cross="/opt/cross/$cross"
197 if [ -f "$cross/setenv.sh" ]
200 cp $cross/setenv.sh debian/setenv.sh
204 # determine architecture
205 GNU_ARCH=${cross%-*} # assumed format: DEB_HOST_GNU_TYPE-g++version, e.g. arm-linux-gnueabihf-4.9
206 GNU_ARCH=${GNU_ARCH##*/}
207 arch_opt="-t $GNU_ARCH"
215 dpkg-architecture $arch_opt >> debian/setenv.sh
217 echo "paket=$paket" >> debian/setenv.sh
218 echo "oldpack=\"$oldpack\"" >> debian/setenv.sh
221 if [ -z "$optversion" ]
227 echo "version=$version" >> debian/setenv.sh
228 echo "build=$build" >> debian/setenv.sh
230 # get repository name
234 # echo "pwd=$pwd" >> debian/rules.pre
236 echo "building $paket with build $version-$build"
238 pushd debian >/dev/null
239 # ./debian -------------------------------------
241 ln -sf /usr/share/mbuild/rules .
248 # check for pre/post installation scripts
249 echo "TODO: check for conffiles"
250 if [ -f $paket.preinst ]
252 echo "add_inst_tgt += debian/tmp/DEBIAN/preinst" >> rules.pre
254 if [ -f $paket.postinst ]
256 echo "add_inst_tgt += debian/tmp/DEBIAN/postinst" >> rules.pre
258 if [ -f $paket.prerm ]
260 echo "add_inst_tgt += debian/tmp/DEBIAN/prerm" >> rules.pre
262 if [ -f $paket.postrm ]
264 echo "add_inst_tgt += debian/tmp/DEBIAN/postrm" >> rules.pre
267 # check for README.debian
268 if [ -f $paket.README.debian ]
270 cp $paket.README.debian README.debian
275 # add export to setenv.sh
276 sed -i "s/^/export /" setenv.sh
279 # ./. ---------------------------------------------
281 # copy package control
282 if [ -f debian/$paket.control ]
287 echo "warning: control file not found"
288 echo " this file is necessary for any package production."
292 if [ -x debian/$paket.prepare ]
295 debian/$paket.prepare
298 if [ -x debian/$paket.build -o -e debian/$paket.cmake ]
305 if grep -- "-prepare" debian/$paket.build >/dev/null
307 echo "prepare in <paket>.build no longer supported. Use <paket>.prebuild"
315 if [ -x debian/$paket.build ]
317 if [ -x debian/$paket.prebuild ]
319 pushd ../build >/dev/null
321 debian/$paket.prebuild
326 if [ -e debian/$paket.cmake ]
332 if [ -f debian/$paket.cp -a -f debian/$paket.control ]
334 echo "PACK=binary" >> debian/rules.pre
335 if grep "^Architecture: *all" debian/$paket.control >/dev/null
337 echo "arch = all" >> debian/rules.pre
338 echo 'BINARY_INDEP = copy ../$(paket)_$(version)-$(build)_all.deb' >> debian/rules.pre
340 echo 'arch = ${DEB_HOST_ARCH}' >> debian/rules.pre
341 echo "BINARY_ARCH = copy ../${paket}_$version-${build}_"'$(arch).deb' >> debian/rules.pre
343 if ! [ -f $paket.changelog ]
345 echo "changelog_source = debian/default.changelog" >> debian/rules.pre
346 if [ -f debian/default.changelog ]
348 rm debian/default.changelog
351 elif [ -f debian/$paket.cp ]
353 echo "PACK=zip" >> debian/rules.pre
355 echo "PACK=version" >> debian/rules.pre
359 if [ $compile -eq 1 ]
361 if [ -x debian/$paket.build -o -e debian/$paket.cmake ]
367 echo "skipping build step ..."