From: Michael Wagner Date: Tue, 6 Mar 2018 21:01:36 +0000 (+0100) Subject: Merge ../projects X-Git-Tag: sysd2sysv_0.1-1~4 X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/projects.git/commitdiff_plain/3f3c6abff0b443de6634f3fd7dea9c8bf5399f19?hp=58313e9db1554fa9e5f2a2476c4f28b282b347ed Merge ../projects --- diff --git a/README.md b/README.md index 402873d..b5bd55b 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,5 @@ # projects WagnerTech utility projects + +To build a debian package: +git checkout diff --git a/tools/make/c_configure.sh b/tools/make/c_configure.sh index f2e5bcd..c7b610a 100755 --- a/tools/make/c_configure.sh +++ b/tools/make/c_configure.sh @@ -16,8 +16,9 @@ function install_cpp_make { src=$(pwd); pushd $1 if [ -f makefile ]; then rm makefile; fi + if [ -L makefile ]; then rm makefile; fi if [ -f make.post ]; then rm make.post; fi - ln -s $cwd/Make/cpp.make makefile + ln -s $cwd/projects/tools/make/cpp.make makefile echo "SOURCE = \\" > make.pre for file in $(ls *.cpp) do @@ -50,6 +51,16 @@ function append_dependency { echo "" >> $1/make.post } +function add_include { +# adds a include directory +# parameter: +# $1: main directory +# $2: include dir + + src=$(pwd) + echo "CXXFLAGS += -I$src/$2" >> $1/make.pre +} + function append_library { # same as append_dependency. In addition a include statement + a link to the library is added to "main directory" # parameter: diff --git a/tools/make/configure b/tools/make/configure index e91b31a..a92ecbd 100755 --- a/tools/make/configure +++ b/tools/make/configure @@ -130,6 +130,11 @@ then 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 diff --git a/tools/make/makefile b/tools/make/makefile index 0dea151..57dc39d 100644 --- a/tools/make/makefile +++ b/tools/make/makefile @@ -54,7 +54,7 @@ compile.stamp: $(SOURCES) #----------------------------------------------------------------- copy.stamp: $(COPY_PRE) - $(COPY) $(project) + $(COPY) $(project) $(version) ${arch} @touch copy.stamp control.stamp: $(project).control diff --git a/tools/make/mconfigure b/tools/make/mconfigure new file mode 100755 index 0000000..a5e9297 --- /dev/null +++ b/tools/make/mconfigure @@ -0,0 +1,136 @@ +#!/bin/bash +set -e + +function echo_usage { + echo "usage: configure [options]" + echo " -a " +} + +function set_build { + if [ -e .svn ] + then + build=$(svnversion) + elif [ -e .git ] + then + build=$(git describe --tags 2>/dev/null) + test -n "$build" || build="TOP" + changes=$(git status -s |grep "^ *M") || true + test -z "$changes" || build="${build}M" + fi +} + +# to build a package you need ... +# .cp (optional): copy step for package production +# .cpp.sh (optional): commands to setup the C++ compile environment + +if [ $# -lt 1 ] +then + echo_usage + exit 1 +fi + +paket=$1 +shift +ARCH="" +cpp_build=0 +delete_src=1 + +set_build +echo "building $paket with build $build" + +while getopts ":a" opt; do + case $opt in + a) ARCH=$OPTARG + ;; + \?) echo "Invalid option: -$OPTARG" + echo_usage + exit 1 + ;; + :) echo "Option -$OPTARG requires an argument." + echo_usage + exit 1 + ;; + esac +done + +# clean dirs and check out +if [ -d build -a $delete_src -eq 1 ] +then + rm -rf build +fi + +mkdir -p build +pushd build >/dev/null + +ln -sf /usr/share/mbuild/makefile . + +if [ -e $paket ] +then + rm -rf $paket +fi +rm *.stamp || true +rm make.pre || true + +# load util functions for C/C++ - build +if [ -f $paket.cpp.sh ] +then + cpp_build=1 + . projects/tools/make/c_configure.sh + . $paket.cpp.sh +fi + +# copy package control +control=$(find -L src -name $paket.control) +build_number=${build#*_} +if [ -z "$control" ] +then + echo "warning: control file not found" + echo " this file is necessary for any package production." +else + sed "s/%BUILD%/$build_number/" $control |sed "s/%ARCH%/$ARCH/" >$paket.control + echo "$paket.control written." + + # extract version + version=$(grep Version $paket.control |sed "s/Version: //") +fi + +# check for copy file +copy=$(find -L src -name $paket.cp) +if [ -n "$copy" ] +then + ln -sf $copy . +else + echo "warning: file $paket.cp missing or not executable:" + echo " this file is necessary for any package production." +fi + +# check for installation scripts +files=$(find src -name $paket.preinst) +files="$files $(find -L src -name $paket.postinst)" +files="$files $(find -L src -name $paket.prerm)" +files="$files $(find -L src -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 + 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 + diff --git a/tools/make/treecopy b/tools/make/treecopy new file mode 100755 index 0000000..761bd87 --- /dev/null +++ b/tools/make/treecopy @@ -0,0 +1,34 @@ +#!/bin/bash + +# copy all files below ($1), that match ($3) +# into target ($2) + +function fcp +{ + rel_path=${3#$1} + + # create target dir, if necessary + rel_dir=${rel_path%/*} + mkdir -p $2/$rel_dir + cp -a $1/$rel_path $2/$rel_dir +} + +usage="usage: treecopy |-e" + +if [ $# -ne 3 ] +then + echo $usage + exit 1 +fi +if [ $3 == "-e" ] +then + for file in $(find $1 \( -type f -o -type l \) -executable) + do + fcp $1 $2 $file + done +else + for file in $(find $1 \( -type f -o -type l \) -name "$3") + do + fcp $1 $2 $file + done +fi