From: Michael Wagner Date: Mon, 15 Oct 2018 20:37:01 +0000 (+0200) Subject: Merge branch 'master' of http://wagnertech.de/git/projects X-Git-Tag: sysd2sysv_0.2-2~10 X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/projects.git/commitdiff_plain/160d72dfc4b7fbcd9f075fe71fd607e43c7b48c7?hp=30de755c5340958dabcfe009d82322436cb9dc36 Merge branch 'master' of http://wagnertech.de/git/projects --- diff --git a/debian/mbuild.changelog b/debian/mbuild.changelog index 5346c34..43d7988 100644 --- a/debian/mbuild.changelog +++ b/debian/mbuild.changelog @@ -1,12 +1,11 @@ projects (0.2-%BUILD%) unstable; urgency=medium - * Build in svn-Umgebung - - -- Michael Wagner Mon, 18 Apr 2018 09:45:25 +0100 + * including build script + * new options + * including pre/post installation scripts + -- Michael Wagner Fr 10. Aug 22:54:48 CEST 2018 projects (0.1-%BUILD%) unstable; urgency=medium - * Build in neuer git-Umgebung - -- Michael Wagner Mon, 12 Feb 2018 09:45:25 +0100 diff --git a/debian/mbuild.cp b/debian/mbuild.cp index 0a78def..824975c 100755 --- a/debian/mbuild.cp +++ b/debian/mbuild.cp @@ -9,4 +9,9 @@ cp tools/make/treecopy $base/usr/bin/ mkdir -p $base/usr/share/mbuild/ cp tools/make/rules $base/usr/share/mbuild/ +cp tools/make/insert_build.sh $base/usr/share/mbuild/ + +mkdir -p $base/usr/share/man/man8 +gzip -c doc/mbuild.8 >$base/usr/share/man/man8/mbuild.8.gz +gzip -c doc/mconfigure.1 >$base/usr/share/man/man8/mconfigure.1.gz diff --git a/doc/mbuild.8 b/doc/mbuild.8 index 0f7b4f1..3209b7b 100644 --- a/doc/mbuild.8 +++ b/doc/mbuild.8 @@ -1,6 +1,6 @@ .\" Manpage for mbuild. .\" Contact mail@wagnertech.de to correct errors or typos. -.TH man 8 "12 Jul 2018" "0.1" "mbuild man page" +.TH mbuild 8 "Jul 2018" GNU "WagnerTech Utilities" .SH NAME mbuild \- build system of WagnerTech UG .SH SYNOPSIS @@ -13,25 +13,59 @@ consists of 3 phases: configuration - compile - pack configuration is done by the .B mconfigure -script. It determins the verion number from the git/subversion status. Per +script. It determins the verion number from the git/subversion status. A +.B PAKET.changelog +file is needed. Per default this script also performs compile and pack step. + +If a +.B PAKET.build +file is present in the debian directory, it is called with a -prepare parameter. .TP compile To perform the compile step a .B PAKET.build -script is needed in the debian directory. +script is needed in the +.B debian +directory. .TP pack To perform the pack step a .B PAKET.cp -script is needed in the debian directory. - +script and a +.B PAKET.control +file are needed in the debian directory. If pre/post installation scripts +are needed, these files must be also placed in the +.B debian +directory. .SH FILES +.TP +PAKET.changelog +Example: +.br +projects (0.2-%BUILD%) unstable; urgency=medium + * Build in svn-Umgebung + -- Michael Wagner Fr 10. Aug 22:54:48 CEST 2018 +.TP PAKET.build - +Any executable script file executing the build in the ../build directory +.TP PAKET.cp +An executable script file copying the artefacts to target paths preposed by $1: +.br +cp ../build/my_artefact $1/usr/bin/ +.TP +PAKET.preinst PAKET.postint PAKET.prerm PAKET.postrm +Optional pre/post installation scripts +.TP +PAKET.control +Debian control file +.PP +These files are expected in a +.B debian +directory, placed below the projects main directory. .SH SEE ALSO -make(1), mconfigure(8) +make(1), mconfigure(1) .SH BUGS No known bugs. .SH AUTHOR diff --git a/doc/mconfigure.1 b/doc/mconfigure.1 new file mode 100644 index 0000000..c5b2eb6 --- /dev/null +++ b/doc/mconfigure.1 @@ -0,0 +1,35 @@ +.\" Manpage for mconfigure. +.\" Contact mail@wagnertech.de to correct errors or typos. +.TH mconfigure 1 "Aug 2018" "GNU" "WagnerTech Utilities" +.SH NAME +mconfigure \- interface to build system of WagnerTech UG +.SH SYNOPSIS +.B mconfigure +.I paket +.B [-cdp] +.SH DESCRIPTION +mconfigure builds the package +.I paket. +mconfigure has to be called in the projects base directory containing a directoty named +.B debian, +that contains the files described in +.B mbuild(8). +.SH OPTIONS +.TP +-c +select configuration step +.TP +-d +select compile step +.TP +-p +select pack step +.PP +If no steps are selected all steps are performed. +.SH SEE ALSO +mbuild(8): Overview description +.SH BUGS +No known bugs. +.SH AUTHOR +Michael Wagner (michael@wagnertech.de) + diff --git a/tools/make/makefile b/tools/make/makefile index 57dc39d..9ade437 100644 --- a/tools/make/makefile +++ b/tools/make/makefile @@ -1,85 +1,34 @@ # Generic makefile for mBuild build process -# defile default operations - -NOP = @echo "No operation for target $@" -COMPILE = $(NOP) -COMPILE_TARGET = compile.stamp -COPY = $(NOP) -ZIP = zip -r $(project).zip $(project) -DEB = fakeroot dpkg-deb --build $(project) -INSERT_BUILD = projects/tools/make/insert_build.sh -#default parameters -project = default -SOURCES = -COPY_PRE = +# default parameters +CC = g++ +INSERT_BUILD = /usr/share/mbuild/insert_build.sh -# Load project specification include make.pre -.SUFFIXES: .stamp .zip - - -#----------------------------------------------------------------- -# Hauptziele: -# -# : ohne Parameter wird compiliert -# - zip : packt ZIP file -# - deb : packt Debian package -# -#----------------------------------------------------------------- - -compile: $(COMPILE_TARGET) - # compile ist fertig - -zip: $(project).zip - # ZIP file ready - -deb: $(project).deb - # Debian package ready - -version: $(COMPILE_TARGET) - $(INSERT_BUILD) $(COMPILE_TARGET) $(build) +# All Target +all: $(DEPS) $(SOURCE:%.cpp=%.o) $(TARGET) -#----------------------------------------------------------------- -# compile steps -#----------------------------------------------------------------- -compile.stamp: $(SOURCES) - $(COMPILE) - @touch compile.stamp +# Other Targets +clean: + -rm *.o + -rm $(TARGET) -#----------------------------------------------------------------- -# pack steps -#----------------------------------------------------------------- -copy.stamp: $(COPY_PRE) - $(COPY) $(project) $(version) ${arch} - @touch copy.stamp +.PHONY: all make.post -control.stamp: $(project).control - mkdir -p $(project)/DEBIAN - cp $(project).control $(project)/DEBIAN/control - if [ -f $(project).preinst ]; then cp $(project).preinst $(project)/DEBIAN/preinst; fi - if [ -f $(project).postinst ]; then cp $(project).postinst $(project)/DEBIAN/postinst; fi - if [ -f $(project).prerm ]; then cp $(project).prerm $(project)/DEBIAN/prerm; fi - if [ -f $(project).postrm ]; then cp $(project).postrm $(project)/DEBIAN/postrm; fi - @touch control.stamp +%.a: $(SOURCE:%.cpp=%.o) + ar r $(TARGET) *.o -$(project).zip: copy.stamp $(project) - $(ZIP) +%.so: $(SOURCE:%.cpp=%.o) $(LDLIBS) + $(CXX) -shared -o $(TARGET) *.o $(LDLIBS) $(EXTLIB) -$(project).deb: copy.stamp control.stamp - $(DEB) - cp $(project).deb $(project)_$(version)$(_arch).deb +make.pre: ~/build/debian/rules.pre + cp ~/build/debian/rules.pre make.pre -#----------------------------------------------------------------- -# utilities -#----------------------------------------------------------------- -clean: - -rm *.stamp 2>/dev/null - if [ -e $(project).zip ]; then rm $(project).zip; fi - if [ -e $(project) ]; then rm -rf $(project); fi +-include make.post +# defile default operations #----------------------------------------------------------------- # Build-Regeln diff --git a/tools/make/mconfigure b/tools/make/mconfigure index f745eff..c164f10 100755 --- a/tools/make/mconfigure +++ b/tools/make/mconfigure @@ -4,9 +4,9 @@ set -e function echo_usage { echo "usage: mconfigure [options]" echo " -a " - echo " -c : configure only, no compile, pack" - echo " -d : compile only" - echo " -p : pack only" + echo " -c : configure" + echo " -d : compile" + echo " -p : pack default: do all" } function set_build { @@ -30,6 +30,9 @@ function set_build { version=${tag%%-*} version=${version##*_} build=${tag#*-} + else + echo "No configuration system found. Cannot determine version." + exit 1 fi } @@ -66,21 +69,19 @@ fi paket=$1 -configure=1 -compile=1 -pack=1 -while getopts ":ap" opt; do +configure=0 +compile=0 +pack=0 +shift +while getopts ":acdp" opt; do case $opt in a) ARCH=$OPTARG ;; - c) compile=0 - pack=0 + c) configure=1 ;; - d) configure=0 - pack=0 + d) compile=1 ;; - p) configure=0 - compile=0 + p) pack=1 ;; \?) echo "Invalid option: -$OPTARG" echo_usage @@ -93,27 +94,36 @@ while getopts ":ap" opt; do esac done +# if nothing is selected, select all +if [ $configure -eq 0 -a $compile -eq 0 -a $pack -eq 0 ] +then + configure=1 + compile=1 + pack=1 +fi + if [ $configure -eq 1 ] then - echo "export paket=$1" > debian/setenv.sh - shift + echo "paket=$paket" > debian/rules.pre +# shift ARCH="" cpp_build=0 set_build check_version - echo "export version=$version" >> debian/setenv.sh - echo "export build=$build" >> debian/setenv.sh + echo "version=$version" >> debian/rules.pre + echo "build=$build" >> debian/rules.pre # get repository name - tmp=$(pwd) - pwd=${tmp##*/} - pwd=${pwd,,*} - echo "export pwd=$pwd" >> debian/setenv.sh +# tmp=$(pwd) +# pwd=${tmp##*/} +# pwd=${pwd,,*} +# echo "pwd=$pwd" >> debian/rules.pre echo "building $paket with build $version-$build" pushd debian >/dev/null + # ./debian ------------------------------------- ln -sf /usr/share/mbuild/rules . @@ -121,8 +131,24 @@ then then rm -rf tmp fi - #rm *.stamp 2>/dev/null || true - #rm make.pre 2>/dev/null || true + + # check for pre/post installation scripts + if [ -f $paket.preinst ] + then + echo "add_inst_tgt += debian/tmp/DEBIAN/preinst" >> rules.pre + fi + if [ -f $paket.postinst ] + then + echo "add_inst_tgt += debian/tmp/DEBIAN/postinst" >> rules.pre + fi + if [ -f $paket.prerm ] + then + echo "add_inst_tgt += debian/tmp/DEBIAN/prerm" >> rules.pre + fi + if [ -f $paket.postrm ] + then + echo "add_inst_tgt += debian/tmp/DEBIAN/postrm" >> rules.pre + fi mkdir -p tmp/DEBIAN @@ -135,11 +161,15 @@ then fi popd >/dev/null + # ./. --------------------------------------------- # copy package control - if [ ! -f debian/control ] + if [ -f debian/$paket.control ] then - control=$(find etc -name $paket.control) + cp debian/$paket.control debian/control + else + # try old fashoned way + control=$(find etc -name $paket.control) || true if [ -z "$control" ] then echo "warning: control file not found" @@ -153,34 +183,44 @@ then grep -v "Version:" $control |grep -v "Maintainer:" >> debian/control fi fi + + # build prepare + if [ -e debian/$paket.build ] + then + if [ -e ../build ] + then + rm -rf ../build + mkdir ../build + fi + debian/$paket.build -prepare + fi + + # pack prepare + if [ -f debian/$paket.cp -a -f $paket.control ] + then + echo "PACK=binary" >> debian/rules.pre + elif [ -f debian/$paket.cp ] + then + echo "PACK=zip" >> debian/rules.pre + else + echo "PACK=version" >> debian/rules.pre + fi 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 - +if [ $compile -eq 1 -a ! -e debian/build.sh ] +then + echo "no debian/build.sh: skipping build step" + compile=0 +fi if [ $compile -eq 1 ] then # build artefacts - . debian/setenv.sh debian/rules build fi if [ $pack -eq 1 ] then # build package - . debian/setenv.sh - debian/rules binary + debian/rules pack fi diff --git a/tools/make/rules b/tools/make/rules index da98ee5..13b9e20 100755 --- a/tools/make/rules +++ b/tools/make/rules @@ -6,6 +6,8 @@ NOP = @echo "No operation for target $@" DEB = fakeroot dpkg-deb --build debian/tmp +include debian/rules.pre + default: echo "no default rule available" @@ -14,7 +16,12 @@ clean: -rm -rf debian/tmp # Bauen der kompilierten Programme und formatierten Dokumente aus den Quellen im Bauverzeichnis -build: +build: debian/$(paket).build sync + debian/$(paket).build + # Build succeeded + +pack: $(PACK) + # packing succeeded # Bauen der kompilierten architekturabhängigen Programme aus den Quellen im Bauverzeichnis build-arch: @@ -34,10 +41,19 @@ binary-arch: # Erstellen Architektur-unabhängiger (Architecture: all) Binärpakete im übergeordneten Verzeichnis binary-indep: copy ../$(paket)_$(version)-$(build)$(_arch).deb +version: $(TARGET) + $(INSERT_BUILD) $(TARGET) $(build) + +../build: + mkdir ../build + +sync: + bash -c 'for dirs in $$(ls); do rsync -av $$dirs ../build; done' + copy: debian/$(paket).cp debian/$(paket).cp debian/tmp -../$(paket)_$(version)-$(build)$(_arch).deb:debian/tmp/DEBIAN/control +../$(paket)_$(version)-$(build)$(_arch).deb:debian/tmp/DEBIAN/control $(add_inst_tgt) $(DEB) mv debian/tmp.deb ../$(paket)_$(version)-$(build)$(_arch).deb @@ -51,6 +67,18 @@ debian/changelog: debian/$(paket).changelog debian/setenv.sh # echo " -- Michael Wagner Sun, 11 Feb 2018 20:03:04 +0100" >> debian/changelog # mb_create_changelog +debian/tmp/DEBIAN/preinst: debian/$(paket).preinst + cp debian/$(paket).preinst debian/tmp/DEBIAN/preinst + +debian/tmp/DEBIAN/postinst: debian/$(paket).postinst + cp debian/$(paket).postinst debian/tmp/DEBIAN/postinst + +debian/tmp/DEBIAN/prerm: debian/$(paket).prerm + cp debian/$(paket).prerm debian/tmp/DEBIAN/prerm + +debian/tmp/DEBIAN/postrm: debian/$(paket).postrm + cp debian/$(paket).postrm debian/tmp/DEBIAN/postrm + # Load project specification -include rules.post