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"
28 cp debian/$paket.cmake CMakeLists.txt
32 # inject cross toolset
33 echo "set (CMAKE_MODULE_PATH $cross)" >> CMakeLists.txt
34 echo "include(toolset)" >> CMakeLists.txt
37 echo "make" > debian/$paket.build
38 chmod 755 debian/$paket.build
42 function check_unversioned {
43 # has to be called in the projects base directory
44 # result: "M" in stdout or nothing
47 # check if build is running in a sandbox
48 if ! [ -f .cm.ignore ]
51 echo ".cm.ignore" > .cm.ignore
52 echo "debian.*" >> .cm.ignore
53 echo "up.*" >> .cm.ignore
57 project=${project##*/}
59 mCM $project -b -an > /dev/null
60 wc=$(wc $project.batch)
62 if [ "${wc:0:5}" != "0 0 0" ]
76 build="$build$(check_unversioned)"
79 tag=$(git describe --tags --match "${paket}_*" 2>/dev/null) || true
84 changes=$(check_unversioned)
87 version=${version%%-*}
90 echo "No configuration system found. Cannot determine version."
95 function check_version {
98 vline=$(head -1 debian/$paket.changelog)
100 clversion=${vline#*(}
101 if [ $version = "0.0" ]
107 # do no check on a modified git repos
108 if [ "${build: -1}" == "M" ]
113 if [ "$clversion" != $version ]
115 echo "version mismatch: git: $version, changelog: $clversion"
122 echo "run mconfigure in the project base directory with a debian directory in it!"
129 while getopts "a:cC:dpo" opt; do
143 \?) echo "Invalid option: -$OPTARG"
147 :) echo "Option -$OPTARG requires an argument."
163 if [ -n "$ARCH" -a -n "$cross" ]
165 echo "invalid options: supply -a for multiarch or -C for explicit cross compile environment"
169 # if nothing is selected, select all
170 if [ $configure -eq 0 -a $compile -eq 0 -a $pack -eq 0 ]
177 if [ $configure -eq 1 ]
179 # delete changelog and control
180 rm debian/changelog debian/control debian/README.debian debian/copyright 2>/dev/null || true
182 # mconfigure builds 2 environment files: setenv.sh + rules.pre
183 echo "" > debian/rules.pre
184 if [ -e debian/setenv.sh ]; then rm debian/setenv.sh; fi
188 if [ ${cross:0:1} != "/" ]
190 cross="/opt/cross/$cross"
193 if [ -f "$cross/setenv.sh" ]
196 cp $cross/setenv.sh debian/setenv.sh
200 # determine architecture
201 GNU_ARCH=${cross%-*} # assumed format: DEB_HOST_GNU_TYPE-g++version, e.g. arm-linux-gnueabihf-4.9
202 GNU_ARCH=${GNU_ARCH##*/}
203 arch_opt="-t $GNU_ARCH"
211 dpkg-architecture $arch_opt >> debian/setenv.sh
213 echo "paket=$paket" >> debian/setenv.sh
214 echo "oldpack=\"$oldpack\"" >> debian/setenv.sh
218 echo "version=$version" >> debian/setenv.sh
219 echo "build=$build" >> debian/setenv.sh
221 # get repository name
225 # echo "pwd=$pwd" >> debian/rules.pre
227 echo "building $paket with build $version-$build"
229 pushd debian >/dev/null
230 # ./debian -------------------------------------
232 ln -sf /usr/share/mbuild/rules .
239 # check for pre/post installation scripts
240 if [ -f $paket.preinst ]
242 echo "add_inst_tgt += debian/tmp/DEBIAN/preinst" >> rules.pre
244 if [ -f $paket.postinst ]
246 echo "add_inst_tgt += debian/tmp/DEBIAN/postinst" >> rules.pre
248 if [ -f $paket.prerm ]
250 echo "add_inst_tgt += debian/tmp/DEBIAN/prerm" >> rules.pre
252 if [ -f $paket.postrm ]
254 echo "add_inst_tgt += debian/tmp/DEBIAN/postrm" >> rules.pre
257 # check for README.debian
258 if [ -f $paket.README.debian ]
260 cp $paket.README.debian README.debian
265 # add export to setenv.sh
266 sed -i "s/^/export /" setenv.sh
269 # ./. ---------------------------------------------
271 # copy package control
272 if [ -f debian/$paket.control ]
277 echo "warning: control file not found"
278 echo " this file is necessary for any package production."
282 if [ -x debian/$paket.prepare ]
285 debian/$paket.prepare
288 if [ -x debian/$paket.build -o -e debian/$paket.cmake ]
295 if grep -- "-prepare" debian/$paket.build >/dev/null
297 echo "prepare in <paket>.build no longer supported. Use <paket>.prebuild"
305 if [ -x debian/$paket.build ]
307 if [ -x debian/$paket.prebuild ]
309 pushd ../build >/dev/null
311 debian/$paket.prebuild
316 if [ -e debian/$paket.cmake ]
322 if [ -f debian/$paket.cp -a -f debian/$paket.control ]
324 echo "PACK=binary" >> debian/rules.pre
325 if grep "^Architecture: *all" debian/$paket.control >/dev/null
327 echo "arch = all" >> debian/rules.pre
328 echo "BINARY_INDEP = copy ../${paket}_$version-${build}_all.deb" >> debian/rules.pre
330 echo 'arch = ${DEB_HOST_ARCH}' >> debian/rules.pre
331 echo "BINARY_ARCH = copy ../${paket}_$version-${build}_"'$(arch).deb' >> debian/rules.pre
333 elif [ -f debian/$paket.cp ]
335 echo "PACK=zip" >> debian/rules.pre
337 echo "PACK=version" >> debian/rules.pre
341 if [ $compile -eq 1 ]
343 if [ -x debian/$paket.build -o -e debian/$paket.cmake ]
349 echo "skipping build step ..."