A few trivial code style cleanups
[wmaker-crm.git] / debian / nightly_build.sh
blobe899a9e2c8a80f16fa2a5e5fb65b50d91049250a
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 PULLCMD1="git fetch"
12 PULLCMD2="git checkout origin/master"
13 if [ -n "${WMAKER_DISTRO}" ]; then
14 case ${WMAKER_DISTRO} in
15 unstable)
16 PULLCMD2="git checkout origin/next"
17 BUILDLOG="${HOME}/log/wmaker-unstable-nightly.log"
19 esac
22 FORCE="0"
24 if [ $# -gt 0 ]; then
25 case $1 in
26 -f|--force)
27 FORCE="1"
30 echo "Usage $0 [-f|--force]"
31 exit 0
33 esac
36 cleanup() {
37 test -f ${CHLOGBKP} && mv ${CHLOGBKP} debian/changelog
40 errorExit() {
41 echo "$@" 1>&2
42 cleanup
43 exit 2
46 doPull() {
47 RC="1"
48 LATEST="`$STATUSCMD`"
49 $PULLCMD1 >>$BUILDLOG 2>&1 || errorExit "Error pulling from the repo"
50 $PULLCMD2 >>$BUILDLOG 2>&1 || errorExit "Error pulling from the repo"
51 CURRENT="`$STATUSCMD`"
52 if [ "$FORCE" = "1" -o "$LATEST" != "$CURRENT" ]; then
53 echo "last revision: $LATEST" >>$BUILDLOG
54 echo "new revision: $CURRENT" >>$BUILDLOG
55 echo "FORCE: $FORCE" >>$BUILDLOG
56 RC="0"
57 else
58 echo "No changes to build, and FORCE not given." >>$BUILDLOG
60 return $RC
63 doEnv() {
64 for var in `env | grep GNUSTEP | sed "s/=.*//"`; do
65 unset $var
66 done
69 doChlog() {
70 cp debian/changelog ${CHLOGBKP}
71 debchange -v ${BASEVERSION}-${REPOVERSION} "${CHANGELOG}" || return 1
74 doBuild() {
75 ARGS=""
76 if [ -n "${WM_GPG_KEY}" ]; then
77 ARGS="-k${WM_GPG_KEY}"
79 fakeroot dpkg-buildpackage $ARGS >>${BUILDLOG} 2>&1
82 install -d `dirname $BUILDLOG`
83 >$BUILDLOG
84 trap 'cleanup; exit 2' 2
85 trap 'cleanup; exit 2' 9
86 trap 'cleanup; exit 2' 15
88 test -d debian || errorExit "This script must be called from the toplevel source dir, ./debian must exist."
90 RC=0
91 if doPull ; then
92 doEnv
93 doChlog || errorExit "Error adding new changelog entry."
94 doBuild || errorExit "Error during build of .deb package."
95 else
96 RC=1
99 cleanup
100 exit $RC