+++ /dev/null
-Source: projects
-Section: main
-Priority: optional
-Maintainer: Michael Wagner <michael@wagnertech.de>
-Build-Depends: git
-
-Package: mbuild
-Architecture: all
-Depends: dpkg-dev
-Description: WagnerTech build environment
- Simple build environment for Debian packages
- .
- This package contains scripts and makefiles for
- script and C/C++ packages.
-projects (0.2-%BUILD%) unstable; urgency=medium
+projects (0.3-%BUILD%) unstable; urgency=medium
+ * new number due to version numbering problems
+ -- Michael Wagner <michael@wagnertech.de> Wed, 09 Jan 2019 22:54:48 +0100
+projects (0.2) unstable; urgency=medium
* Build in svn-Umgebung
+ * including build script
+ * new options
+ * including pre/post installation scripts
+ * packing for tgz and versioning
+ -- Michael Wagner <michael@wagnertech.de> Fri, 10 Aug 2018 22:54:48 +0100
- -- Michael Wagner <michael@wagnertech.de> Mon, 18 Apr 2018 09:45:25 +0100
-
-projects (0.1-%BUILD%) unstable; urgency=medium
-
+projects (0.1) unstable; urgency=medium
* Build in neuer git-Umgebung
-
-- Michael Wagner <michael@wagnertech.de> Mon, 12 Feb 2018 09:45:25 +0100
--- /dev/null
+Source: projects
+Section: main
+Priority: optional
+Maintainer: Michael Wagner <michael@wagnertech.de>
+Build-Depends: git
+
+Package: mbuild
+Architecture: all
+Depends: dpkg-dev
+Description: WagnerTech build environment
+ Simple build environment for Debian packages
+ .
+ This package contains scripts and makefiles for
+ script and C/C++ packages.
mkdir -p $base/usr/share/mbuild/
cp tools/make/rules $base/usr/share/mbuild/
+cp tools/make/insert_build.sh $base/usr/share/mbuild/
+cp tools/make/mMakefile $base/usr/share/mbuild/makefile
+
+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
-projects (0.1-%BUILD%) unstable; urgency=medium
+projects (0.2-%BUILD%) unstable; urgency=medium
+ * with template for init-script
+ -- Michael Wagner <info@wagnertech.de> Sun, 11 Feb 2018 20:03:04 +0100
+
+projects (0.1) unstable; urgency=medium
* initial version
-- Michael Wagner <info@wagnertech.de> Sun, 11 Feb 2018 20:03:04 +0100
+
--- /dev/null
+Source: projects
+Section: main
+Priority: optional
+Maintainer: Michael Wagner <michael@wagnertech.de>
+Build-Depends: git
+
+Package: sysd2sysv
+Architecture: all
+Description: System V init compatibility wrapper
+ .
+ System V init compatibility wrapper
+
mkdir -p $1/usr/bin/
cp sh/sysd2sysv $1/usr/bin/
+mkdir -p $1/var/sysd2sysv
+cp etc/sysd2sysv.tpl $1/var/sysd2sysv/
+
# copy man page
mkdir -p $1/usr/share/man/man8
gzip -c doc/sysd2sysv.8 >$1/usr/share/man/man8/sysd2sysv.8.gz
--- /dev/null
+#!/bin/bash
+set -e
+
+# delete init files created from template
+pushd /etc/init.d >/dev/null
+for file in $(ls)
+do
+ if grep "# sysd2sysv-template #" $file
+ then
+ rm $file
+ fi
+ # for downward compatibility
+ if [ -f mlistd ]
+ then
+ rm mlistd
+ fi
+done
+
.\" 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
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 <michael@wagnertech.de> 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
--- /dev/null
+.\" 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)
+
.SH DESCRIPTION
.PP
sysd2sysv checks, if the service is present in /etc/init.d. If not
-it is expected to be in /etc/sysd2sysv and copied to /etc/init.d.
+it builds one from /etc/init.d/sysd2sysv.tpl.
.PP
Do not install in a Systemd environment!
.SH AUTHOR
--- /dev/null
+#!/bin/bash
+set -e # end if anything fails
+
+# tag: if the next line is changed/removed a reinstall of sysd2sysv will keep this file
+# sysd2sysv-template #
+
+PROG=%PROG%
+PROG_PATH=$(which $PROG) || { echo "$PROG missing"; exit 1; }
+
+syslog=/dev/null
+syserr=/tmp/%PROG%.err
+
+RETVAL=0
+
+. /lib/lsb/init-functions
+
+usage() {
+ echo "$0 [options] start|restart|stop"
+ echo " -l <syslog> DEFAULT: $syslog"
+ echo " -e <errlog> DEFAULT: $syserr"
+}
+
+start () {
+
+ # check, if process is already running
+ if [ `ps -ef | grep $PROG_PATH | grep -v grep | grep -v bash | wc -l` -gt 0 ]
+ then
+ log_end_msg 1
+ exit 1
+ fi
+
+ log_daemon_msg $PROG || true
+ ($PROG &) 1>>$syslog 2>>$syserr
+ sleep 2
+ if status_of_proc $PROG
+ then
+ log_end_msg 0 || true
+ else
+ log_end_msg 1 || true
+ fi
+}
+
+status() {
+ if [ `ps -ef | grep $PROG_PATH | grep -v grep | grep -v bash | wc -l` -gt 0 ]
+ then
+ echo -n $PROG" is running..."
+ echo ""
+ else
+ echo -n $PROG" is stopped"
+ echo ""
+ fi
+}
+
+stop () {
+ log_daemon_msg "Stopping $PROG"
+ kill $(ps aux |grep $PROG_PATH |grep -v grep | awk '{print $2}') || true
+ return 0
+}
+
+# evaluate parameters
+
+operation="NOP"
+
+while [ -n "$1" ]
+do
+ case "$1" in
+ start)
+ operation=start
+ shift
+ ;;
+ restart)
+ operation=restart
+ shift
+ ;;
+ stop)
+ operation=stop
+ shift
+ ;;
+ -c)
+ configfile=$2
+ shift 2
+ ;;
+ -l)
+ syslog=$2
+ if [ -f $syslog ]; then rm $syslog; fi
+ shift 2
+ ;;
+ -e)
+ syserr=$2
+ shift 2
+ ;;
+ -h)
+ usage
+ exit 0
+ ;;
+ *)
+ usage
+ exit 1
+ ;;
+ esac
+done
+
+if [ -f $syserr ]; then rm $syserr; fi
+
+case $operation in
+start)
+ start
+ ;;
+stop)
+ stop
+ ;;
+restart)
+ stop
+ start
+ ;;
+*)
+ usage
+ exit 1
+ ;;
+esac
+
+exit 0
+
fi
if [ ! -f /etc/init.d/$2 ]
- cp /etc/sysd2sysv/$2 /etc/init.d/
+then
+ sed "s/%PROG%/$2/" /var/sysd2sysv/sysd2sysv.tpl > /etc/init.d/$2
+ chmod 755 /etc/init.d/$2
fi
if [ $1 = "enable" ]
then
- update-rc.d $2 defaults 100
+ update-rc.d $2 defaults 99
elif [ $1 = "disable" ]
then
update-rc.d -f $2 remove
--- /dev/null
+# Generic makefile for mBuild build process
+
+
+# default parameters
+CC = g++
+INSERT_BUILD = /usr/share/mbuild/insert_build.sh
+
+include make.pre
+
+# All Target
+all: $(DEPS) $(SOURCE:%.cpp=%.o) $(TARGET)
+
+# Other Targets
+clean:
+ -rm *.o
+ -rm $(TARGET)
+
+
+.PHONY: all make.post
+
+%.a: $(SOURCE:%.cpp=%.o)
+ ar r $(TARGET) *.o
+
+%.so: $(SOURCE:%.cpp=%.o) $(LDLIBS)
+ $(CXX) -shared -o $(TARGET) *.o $(LDLIBS) $(EXTLIB)
+
+make.pre: ~/build/debian/rules.pre
+ cp ~/build/debian/rules.pre make.pre
+
+-include make.post
+# defile default operations
+
+#-----------------------------------------------------------------
+# Build-Regeln
+#-----------------------------------------------------------------
+%.pdf : %.tex $(SOURCES)
+ pdflatex $< && pdflatex $<
+ cp $*.pdf ~/build
+
%.pdf : %.tex $(SOURCES)
pdflatex $< && pdflatex $<
+
function echo_usage {
echo "usage: mconfigure <package> [options]"
echo " -a <arch>"
- 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 {
then
tag="0.0-TOP"
fi
+ tag_paket=${tag%_*}
+ if [ "$tag_paket" != "$paket" ]
+ then
+ tag="0.0-TOP"
+ fi
changes=$(git status -s |grep "^ *M") || true
if test -n "$changes"
then
version=${tag%%-*}
version=${version##*_}
build=${tag#*-}
+ else
+ echo "No configuration system found. Cannot determine version."
+ exit 1
fi
}
function check_version {
+
vline=$(head -1 debian/$paket.changelog)
vline=${vline%-*}
clversion=${vline#*(}
version=$clversion
return
fi
+
+ # do no check on a modified git repos
+ if [ "${build: -1}" == "M" ]
+ then
+ return
+ fi
+
if [ "$clversion" != $version ]
then
echo "version mismatch: git: $version, changelog: $clversion"
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
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
+ # delete changelog and control
+ rm debian/changelog debian/control || true
+
+ 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 .
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
fi
popd >/dev/null
+ # ./. ---------------------------------------------
# copy package control
- if [ ! -f debian/control ]
+ if [ -f debian/$paket.control ]
then
- control=$(find etc -name $paket.control)
+ # proceed
+ echo
+ else
+ # try old fashoned way
+ control=$(find etc -name $paket.control) || true
if [ -z "$control" ]
then
echo "warning: control file not found"
echo " this file is necessary for any package production."
else
- echo "Source: $pwd
+ echo "Source: $paket
Section: main
Priority: optional
Maintainer: WagnerTech UG <mail@wagnertech.de>
- " > debian/control
- grep -v "Version:" $control |grep -v "Maintainer:" >> debian/control
+ " > debian/$paket.control
+ grep -v "Version:" $control |grep -v "Maintainer:" >> debian/$paket.control
+ fi
+ fi
+
+ # build prepare
+ if [ -e debian/$paket.build ]
+ then
+ if [ -e ../build ]
+ then
+ rm -rf ../build
+ mkdir ../build
+ fi
+ if grep -- "-prepare" debian/$paket.build >/dev/null
+ then
+ debian/rules sync
+ debian/$paket.build -prepare
fi
fi
+
+ # pack prepare
+ if [ -f debian/$paket.cp -a -f debian/$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
+ cp debian/rules.pre debian/setenv.sh
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/$paket.build ]
+then
+ echo "no debian/build.sh: skipping build step"
+ compile=0
+fi
if [ $compile -eq 1 ]
then
# build artefacts
then
# build package
. debian/setenv.sh
- debian/rules binary
+ debian/rules pack
fi
# defile default operations
NOP = @echo "No operation for target $@"
DEB = fakeroot dpkg-deb --build debian/tmp
+INSERT_BUILD = /usr/share/mbuild/insert_build.sh
+
+include debian/rules.pre
default:
echo "no default rule available"
-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:
# Erstellen Architektur-unabhängiger (Architecture: all) Binärpakete im übergeordneten Verzeichnis
binary-indep: copy ../$(paket)_$(version)-$(build)$(_arch).deb
+version: ~/build/$(TARGET)
+ $(INSERT_BUILD) ~/build/$(TARGET) $(build)
+ cp ~/build/*$(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
debian/tmp/DEBIAN/control: debian/control debian/changelog
dpkg-gencontrol
-debian/changelog: debian/$(paket).changelog debian/setenv.sh
+debian/control: debian/$(paket).control
+ cp debian/$(paket).control debian/control
+
+debian/changelog: debian/$(paket).changelog debian/rules.pre
sed "s/%BUILD%/$(build)/" debian/$(paket).changelog > debian/changelog
# echo "${pwd} (${build}) unstable; urgency=medium" > debian/changelog
# echo " * generated by mbuild" >> debian/changelog
# echo " -- Michael Wagner <info@wagnertech.de> 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