Adapted nightly build script to coexist with new 'next' branch.
[wmaker-crm.git] / debian / nightly_build.sh
blob76fcbcf6c57646681bf894acdc71bc58fab1d598
1 #!/bin/sh
3 CHLOGBKP="/tmp/$$-chlog"
4 BASEVERSION="0.93.0"
5 REPOVERSION="git-`date +%Y%m%d-%H%M`"
7 CHANGELOG="Automatic build from the GIT on `date`"
8 BUILDLOG="${HOME}/log/wmaker-testing-nightly.log"
10 STATUSCMD="git log -1 --pretty=oneline"
11 PULLCMD="git pull"
12 FORCE="0"
14 if [ $# -gt 0 ]; then
15 case $1 in
16 -f|--force)
17 FORCE="1"
20 echo "Usage $0 [-f|--force]"
21 exit 0
23 esac
26 cleanup() {
27 test -f ${CHLOGBKP} && mv ${CHLOGBKP} debian/changelog
30 errorExit() {
31 echo "$@" 1>&2
32 cleanup
33 exit 2
36 doPull() {
37 RC="1"
38 LATEST="`$STATUSCMD`"
39 $PULLCMD >>$BUILDLOG 2>&1 || errorExit "Error pulling from the repo"
40 CURRENT="`$STATUSCMD`"
41 if [ "$FORCE" = "1" -o "$LATEST" != "$CURRENT" ]; then
42 echo "last revision: $LATEST" >>$BUILDLOG
43 echo "new revision: $CURRENT" >>$BUILDLOG
44 echo "FORCE: $FORCE" >>$BUILDLOG
45 RC="0"
46 else
47 echo "No changes to build, and FORCE not given." >>$BUILDLOG
49 return $RC
52 doEnv() {
53 for var in `env | grep GNUSTEP | sed "s/=.*//"`; do
54 unset $var
55 done
58 doChlog() {
59 cp debian/changelog ${CHLOGBKP}
60 debchange -v ${BASEVERSION}-${REPOVERSION} "${CHANGELOG}" || return 1
63 doBuild() {
64 ARGS=""
65 if [ -n "${WM_GPG_KEY}" ]; then
66 ARGS="-k${WM_GPG_KEY}"
68 fakeroot dpkg-buildpackage $ARGS >>${BUILDLOG} 2>&1
71 install -d `dirname $BUILDLOG`
72 >$BUILDLOG
73 trap 'cleanup; exit 2' 2
74 trap 'cleanup; exit 2' 9
75 trap 'cleanup; exit 2' 15
77 test -d debian || errorExit "This script must be called from the toplevel source dir, ./debian must exist."
79 RC=0
80 if doPull ; then
81 doEnv
82 doChlog || errorExit "Error adding new changelog entry."
83 doBuild || errorExit "Error during build of .deb package."
84 else
85 RC=1
88 cleanup
89 exit $RC