Remove unused variables
[wmaker-crm.git] / debian / nightly_build.sh
blob11ec73f1fc578e67ed3b6b0fee18af7049cb7089
1 #!/bin/sh
3 CHLOGBKP="/tmp/$$-chlog"
4 #BASEVERSION="0.94.0"
5 BASEVERSION="`head -1 debian/changelog | cut -d\( -f2 | cut -d\- -f1`"
6 REPOVERSION="git-`date +%Y%m%d-%H%M`"
8 CHANGELOG="Automatic build from the GIT on `date`"
9 BUILDLOG="${HOME}/log/wmaker-testing-nightly.log"
11 STATUSCMD="git log -1 --pretty=oneline"
12 PULLCMD="git pull --rebase"
13 if [ -n "${WMAKER_DISTRO}" ]; then
14 case ${WMAKER_DISTRO} in
15 unstable)
16 BUILDLOG="${HOME}/log/wmaker-unstable-nightly.log"
18 esac
21 FORCE="0"
23 if [ $# -gt 0 ]; then
24 case $1 in
25 -f|--force)
26 FORCE="1"
29 echo "Usage $0 [-f|--force]"
30 exit 0
32 esac
35 cleanup() {
36 test -f ${CHLOGBKP} && mv ${CHLOGBKP} debian/changelog
39 errorExit() {
40 echo "$@" 1>&2
41 cleanup
42 exit 2
45 doPull() {
46 RC="1"
47 LATEST="`$STATUSCMD`"
48 git reset --hard HEAD
49 git clean -f
50 $PULLCMD >>$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}-1 "${CHANGELOG}" || return 1
74 doTarball() {
75 echo tar -czf ../wmaker_${BASEVERSION}-${REPOVERSION}.orig.tar.gz .
76 tar -czf ../wmaker_${BASEVERSION}-${REPOVERSION}.orig.tar.gz .
79 doBuild() {
80 ARGS=""
81 if [ -n "${WM_GPG_KEY}" ]; then
82 ARGS="-k${WM_GPG_KEY}"
84 dpkg-buildpackage -rfakeroot $ARGS >>${BUILDLOG} 2>&1
87 install -d `dirname $BUILDLOG`
88 >$BUILDLOG
89 trap 'cleanup; exit 2' 2
90 trap 'cleanup; exit 2' 9
91 trap 'cleanup; exit 2' 15
93 test -d debian || errorExit "This script must be called from the toplevel source dir, ./debian must exist."
95 #git status | grep modified: | awk '{ print $3 }' | xargs git checkout
96 git checkout -f >/dev/null
97 RC=0
98 if doPull ; then
99 doEnv
100 doChlog || errorExit "Error adding new changelog entry."
101 doTarball || errorExit "Error building source tarball."
102 doBuild || errorExit "Error during build of .deb package."
103 else
104 RC=1
107 cleanup
108 exit $RC