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
29 echo "make" > debian/$paket.build
30 chmod 755 debian/$paket.build
34 function check_unversioned {
35 # has to be called in the projects base directory
36 # result: "M" in stdout or nothing
39 # check if build is running in a sandbox
40 if ! [ -f .cm.ignore ]
43 echo ".cm.ignore" > .cm.ignore
44 echo "debian.*" >> .cm.ignore
45 echo "up.*" >> .cm.ignore
49 project=${project##*/}
51 mCM $project -b -an > /dev/null
52 wc=$(wc $project.batch)
54 if [ "${wc:0:5}" != "0 0 0" ]
68 build="$build$(check_unversioned)"
71 tag=$(git describe --tags --match "${paket}_*" 2>/dev/null) || true
76 changes=$(check_unversioned)
79 version=${version%%-*}
82 echo "No configuration system found. Cannot determine version."
87 function check_version {
90 vline=$(head -1 debian/$paket.changelog)
93 if [ $version = "0.0" ]
99 # do no check on a modified git repos
100 if [ "${build: -1}" == "M" ]
105 if [ "$clversion" != $version ]
107 echo "version mismatch: git: $version, changelog: $clversion"
114 echo "run mconfigure in the project base directory with a debian directory in it!"
121 while getopts "a:cC:dpo" opt; do
135 \?) echo "Invalid option: -$OPTARG"
139 :) echo "Option -$OPTARG requires an argument."
155 if [ -n "$ARCH" -a -n "$cross" ]
157 echo "invalid options: supply -a for multiarch or -C for explicit cross compile environment"
161 # if nothing is selected, select all
162 if [ $configure -eq 0 -a $compile -eq 0 -a $pack -eq 0 ]
169 if [ $configure -eq 1 ]
171 # delete changelog and control
172 rm debian/changelog debian/control debian/README.debian debian/copyright 2>/dev/null || true
174 # mconfigure builds 2 environment files: setenv.sh + rules.pre
175 echo "" > debian/rules.pre
176 if [ -e debian/setenv.sh ]; then rm debian/setenv.sh; fi
184 if [ ${cross:0:1} != "/" ]
186 cross="/opt/cross/$cross"
189 cp $cross/setenv.sh debian/setenv.sh
191 dpkg-architecture $arch_opt >> debian/setenv.sh
193 echo "paket=$paket" >> debian/setenv.sh
194 echo "oldpack=\"$oldpack\"" >> debian/setenv.sh
198 echo "version=$version" >> debian/setenv.sh
199 echo "build=$build" >> debian/setenv.sh
201 # get repository name
205 # echo "pwd=$pwd" >> debian/rules.pre
207 echo "building $paket with build $version-$build"
209 pushd debian >/dev/null
210 # ./debian -------------------------------------
212 ln -sf /usr/share/mbuild/rules .
219 # check for pre/post installation scripts
220 if [ -f $paket.preinst ]
222 echo "add_inst_tgt += debian/tmp/DEBIAN/preinst" >> rules.pre
224 if [ -f $paket.postinst ]
226 echo "add_inst_tgt += debian/tmp/DEBIAN/postinst" >> rules.pre
228 if [ -f $paket.prerm ]
230 echo "add_inst_tgt += debian/tmp/DEBIAN/prerm" >> rules.pre
232 if [ -f $paket.postrm ]
234 echo "add_inst_tgt += debian/tmp/DEBIAN/postrm" >> rules.pre
237 # check for README.debian
238 if [ -f $paket.README.debian ]
240 cp $paket.README.debian README.debian
245 # add export to setenv.sh
246 sed -i "s/^/export /" setenv.sh
249 # ./. ---------------------------------------------
251 # copy package control
252 if [ -f debian/$paket.control ]
257 echo "warning: control file not found"
258 echo " this file is necessary for any package production."
262 if [ -x debian/$paket.prepare ]
265 debian/$paket.prepare
268 if [ -x debian/$paket.build -o -e debian/$paket.cmake ]
275 if grep -- "-prepare" debian/$paket.build >/dev/null
277 echo "prepare in <paket>.build no longer supported. Use <paket>.prebuild"
285 if [ -x debian/$paket.build ]
287 if [ -x debian/$paket.prebuild ]
289 pushd ../build >/dev/null
291 debian/$paket.prebuild
296 if [ -e debian/$paket.cmake ]
302 if [ -f debian/$paket.cp -a -f debian/$paket.control ]
304 echo "PACK=binary" >> debian/rules.pre
305 if grep "^Architecture: *all" debian/$paket.control >/dev/null
307 echo "arch = all" >> debian/rules.pre
308 echo "BINARY_INDEP = copy ../${paket}_$version-${build}_all.deb" >> debian/rules.pre
310 echo 'arch = ${DEB_HOST_ARCH}' >> debian/rules.pre
311 echo "BINARY_ARCH = copy ../${paket}_$version-${build}_"'$(arch).deb' >> debian/rules.pre
313 elif [ -f debian/$paket.cp ]
315 echo "PACK=zip" >> debian/rules.pre
317 echo "PACK=version" >> debian/rules.pre
321 if [ $compile -eq 1 ]
323 if [ -x debian/$paket.build -o -e debian/$paket.cmake ]
329 echo "skipping build step ..."