set -e
function echo_usage {
- echo "usage: mconfigure <package> [options]"
- echo " -a <arch>"
- echo " -p : prepare build, but not do it"
+ echo "usage: mconfigure [options] <package>"
+ ./configure -I
}
-function set_build {
- if [ -e .svn ]
+function create_conf {
+ if [ -f "debian/$paket.cmake" ]
then
- version="0.0"
- build=$(svnversion)
- build=${build/:/-}
- elif [ -e .git ]
+ echo "compile_type=CMAKE" > debian/$paket.conf
+ elif [ -f "debian/$paket.build" ]
then
- tag=$(git describe --tags 2>/dev/null) || true
- if test -z "$tag"
+ if [ -f "debian/$paket.cpp" ]
then
- tag="0.0-TOP"
+ echo "compile_type=CPP" > debian/$paket.conf
+ else
+ echo "compile_type=ANY" > debian/$paket.conf
fi
- changes=$(git status -s |grep "^ *M") || true
- if test -n "$changes"
- then
- tag="${tag}M"
- fi
- version=${tag%%-*}
- build=${tag#*-}
- fi
-}
-
-function check_version {
- vline=$(head -1 debian/$paket.changelog)
- vline=${vline%-*}
- clversion=${vline#*(}
- if [ $version = "0.0" ]
- then
- version=$clversion
- return
+ else
+ echo "compile_type=NONE" > debian/$paket.conf
fi
- if [ "$clversion" != $version ]
+
+ if [ -f "$paket.control" -a -f "$paket.cp" ]
then
- echo "version mismatch: git: $version, changelog: $clversion"
- exit 1
+ echo "target_type=DEB" >> debian/$paket.conf
+ else
+ echo "target_type=FILE" >> debian/$paket.conf
fi
+ echo "$paket.conf created."
}
-# to build a package you need ...
-# <package>.cp (optional): copy step for package production
-# <package>.cpp.sh (optional): commands to setup the C++ compile environment
-if [ $# -lt 1 ]
-then
- echo_usage
- exit 1
-fi
+##############################################################################
+# Main program
+##############################################################################
if [ ! -d debian ]
then
- echo "run mconfigure in the project base directory!"
+ echo "run mconfigure in the project base directory with a debian directory in it!"
exit 2
fi
-paket=$1
-echo "export paket=$1" > debian/setenv.sh
-shift
-ARCH=""
-cpp_build=0
-
-set_build
-check_version
-echo "export version=$version" >> debian/setenv.sh
-echo "export build=$build" >> debian/setenv.sh
-
-# get repository name
-tmp=$(pwd)
-pwd=${tmp##*/}
-pwd=${pwd,,*}
-echo "export pwd=$pwd" >> debian/setenv.sh
-
-echo "building $paket with build $version-$build"
-
-prepare=0
-while getopts ":ap" opt; do
- case $opt in
- a) ARCH=$OPTARG
- ;;
- p) prepare=1
- ;;
- \?) echo "Invalid option: -$OPTARG"
- echo_usage
- exit 1
- ;;
- :) echo "Option -$OPTARG requires an argument."
- echo_usage
- exit 1
- ;;
- esac
+configure=0
+configure_args="-i debian/tmp"
+while [ $OPTIND -le "$#" ]
+do
+ if getopts "c" opt
+ then
+ case $opt in
+ \?) $confirure_args="$configure_ars -$OPTARG"
+ if [ $OPTARG="a" -o $OPTARG="C" -o $OPTARG="i" -o $OPTARG="v" ]
+ then
+ eval OPTIND=OPTIND+1
+ $confirure_args="$configure_ars ${!OPTIND}"
+ fi
+ ;;
+ :) echo "Option -$OPTARG requires an argument."
+ echo_usage
+ exit 3
+ ;;
+ esac
+ else
+ paket="${!OPTIND}"
+ eval OPTIND=OPTIND+1
+ fi
done
-#
-## clean dirs and check out
-#if [ -d build -a $delete_src -eq 1 ]
-#then
-# rm -rf build
-#fi
-#
-pushd debian >/dev/null
-
-ln -sf /usr/share/mbuild/rules .
-
-#if [ -e tmp ]
-#then
-# rm -rf tmp
-#fi
-#rm *.stamp 2>/dev/null || true
-#rm make.pre 2>/dev/null || true
+if [ -z "$paket" ]
+then
+ echo_usage
+ exit 4
+fi
-mkdir -p tmp/DEBIAN
+if [ ! -f debian/$paket.conf ]
+then
+ # check if any files for $paket are present
+ if ! ls debian/$paket.* 2>/dev/null
+ then
+ echo "$paket is no build target in this repository."
+ exit 5
+ fi
+
+ # build conf file
+ echo "$paket.conf missing. We create it ..."
+ create_conf
+fi
-# load util functions for C/C++ - build
-if [ -f $paket.cpp.sh ]
+if [ ! -e configure ]
then
- cpp_build=1
- . projects/tools/make/c_configure.sh
- . $paket.cpp.sh
+ ln -s /usr/share/mbuild/configure .
fi
-popd >/dev/null
+# clean build directory
+if [ "$compile_type" != "NONE" ]
+then
+ if [ -e ~/build ]
+ then
+ rm -rf ~/build
+ mkdir ~/build
+ fi
+ configure_args="$configure_args -d ~/build"
+fi
-# copy package control
-if [ ! -f debian/control ]
+# perform configure
+. debian/$paket.conf
+if [ "$compile_type" != "NONE" ]
then
- control=$(find etc -name $paket.control)
- if [ -z "$control" ]
+ configure_args="$configure_args -b"
+ if [ -n "$compile_dir" ]
then
- echo "warning: control file not found"
- echo " this file is necessary for any package production."
- else
- echo "Source: $pwd
-Section: main
-Priority: optional
-Maintainer: WagnerTech UG <mail@wagnertech.de>
-" > debian/control
- grep -v "Version:" $control |grep -v "Maintainer:" >> debian/control
+ configure_args="$configure_args -d $compile_dir"
fi
+ if [ -z "$compile_type" ]
+ then
+ echo "compile_type required in $paket.conf"
+ exit 51
+ fi
+fi
+if [ "$target_type" == "FILE" ]
+then
+ # no version needed
+ configure_args="$configure_args -V"
fi
+configure_args="$configure_args $paket"
+echo "Executing ./configure $configure_args ..."
+./configure $configure_args
-if [ $prepare = 1 ]
+if [ "$compile_type" != "NONE" ]
then
- exit 0
+ if grep -- "-prepare" debian/$paket.build >/dev/null
+ then
+ echo "prepare in <paket>.build no longer supported. Use <paket>.prebuild"
+ exit 6
+ fi
+ # sync build dir
+ . debian/setenv.sh
+ debian/rules sync
+ make
fi
-# check for copy file
-#if [ ! -f debian/$paket.cp ]
-#then
-# # search for copy file
-# copy=$(find . -name $paket.cp)
-# if [ -n "$copy" ]
-# then
-# echo "ln -sf ../$copy debian/"
-# ln -sf ../$copy debian/
-# else
-# echo "warning: file $paket.cp missing or not executable:"
-# echo " this file is necessary for any package production."
-# fi
-#fi
+# pack prepare
+if [ "$target_type" == "DEB" ]
+then
+ if [ ! -f debian/$paket.cp ]
+ then
+ echo "debian/$paket.cp missing for target type DEB"
+ exit 9
+ fi
+ if [ ! -f debian/$paket.control ]
+ then
+ echo "debian/$paket.control missing for target type DEB"
+ exit 10
+ fi
+
+ echo "PACK=binary" >> debian/rules.pre
+ if grep "^Architecture: *all" debian/$paket.control >/dev/null
+ then
+ echo "arch = all" >> debian/rules.pre
+ echo 'BINARY_INDEP = copy ../$(paket)_$(version)-$(build)_all.deb' >> debian/rules.pre
+ else
+ echo 'arch = ${DEB_HOST_ARCH}' >> debian/rules.pre
+ echo "BINARY_ARCH = copy ../${paket}_$version-${build}_"'$(arch).deb' >> debian/rules.pre
+ fi
+ if ! [ -f debian/$paket.changelog ]
+ then
+ echo "changelog_source = debian/default.changelog" >> debian/rules.pre
+ if [ -f debian/default.changelog ]
+ then
+ rm debian/default.changelog
+ fi
+ fi
+elif [ "$target_type" == "ZIP" ]
+then
+ echo "PACK=zip" >> debian/rules.pre
+ if [ ! -f debian/$paket.cp ]
+ then
+ echo "debian/$paket.cp missing for target type ZIP"
+ exit 11
+ fi
+elif [ "$target_type" == "FILE" ]
+then
+ echo "PACK=version" >> debian/rules.pre
+ if [ "$compile_type" != "ANY" ]
+ then
+ if [ -z "$compile_target" ]
+ then
+ echo "compile_target is needed for target_type FILE"
+ exit 12
+ fi
+ echo "COMPILE_TARGET = $compile_target" >> debian/rules.pre
+ if [ -n "$target_name" ]
+ then
+ echo "TARGET = $target_name" >> debian/rules.pre
+ else
+ echo "TARGET = $paket" >> debian/rules.pre
+ fi
+ fi
+else
+ echo "Unknown target type: $target_type"
+ exit 13
+fi
# build package
-. debian/setenv.sh
-debian/rules binary
-
-#
-## check for installation scripts
-#files=$(find .. -name $paket.preinst)
-#files="$files $(find .. -name $paket.postinst)"
-#files="$files $(find .. -name $paket.prerm)"
-#files="$files $(find .. -name $paket.postrm)"
-#for file in $files
-#do
-# ln -sf $file .
-#done
-
-# create generic make.pre, if not existing
-#if [ ! -f make.pre ]
-#then
-# cat >>make.pre <<MAKE_PRE
-## mBuild make.pre script (auto generated)
-#project = $paket
-#COPY = ./$paket.cp
-#MAKE_PRE
-# if [ -n "$ARCH" ]
-# then
-# echo "arch = $ARCH" >>make.pre
-# echo "_arch = _${ARCH}" >>make.pre
-# fi
-# echo "make.pre written."
-#fi
-#
-## append version to make.pre
-#echo "version = $version" >> make.pre
-#echo "build = $build" >> make.pre
+debian/rules pack