WUtil: Added 'const' attribute on non-modified arguments to functions
[wmaker-crm.git] / debian / nightly_build.sh
blob5a7995714e4403c2ae19a2bd40af70796bb2cfbc
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 dh_clean
49 git reset --hard HEAD
50 git clean -f
51 $PULLCMD >>$BUILDLOG 2>&1 || errorExit "Error pulling from the repo"
52 CURRENT="`$STATUSCMD`"
53 if [ "$FORCE" = "1" -o "$LATEST" != "$CURRENT" ]; then
54 echo "last revision: $LATEST" >>$BUILDLOG
55 echo "new revision: $CURRENT" >>$BUILDLOG
56 echo "FORCE: $FORCE" >>$BUILDLOG
57 RC="0"
58 else
59 echo "No changes to build, and FORCE not given." >>$BUILDLOG
61 return $RC
64 doEnv() {
65 for var in `env | grep GNUSTEP | sed "s/=.*//"`; do
66 unset $var
67 done
70 doChlog() {
71 cp debian/changelog ${CHLOGBKP}
72 debchange -v ${BASEVERSION}-${REPOVERSION}-1 "${CHANGELOG}" || return 1
75 doTarball() {
76 echo tar -czf ../wmaker_${BASEVERSION}-${REPOVERSION}.orig.tar.gz .
77 tar -czf ../wmaker_${BASEVERSION}-${REPOVERSION}.orig.tar.gz .
80 doBuild() {
81 ARGS=""
82 if [ -n "${WM_GPG_KEY}" ]; then
83 ARGS="-k${WM_GPG_KEY}"
85 dpkg-buildpackage -rfakeroot $ARGS >>${BUILDLOG} 2>&1
88 install -d `dirname $BUILDLOG`
89 >$BUILDLOG
90 trap 'cleanup; exit 2' 2
91 trap 'cleanup; exit 2' 9
92 trap 'cleanup; exit 2' 15
94 test -d debian || errorExit "This script must be called from the toplevel source dir, ./debian must exist."
96 #git status | grep modified: | awk '{ print $3 }' | xargs git checkout
97 git checkout -f >/dev/null
98 RC=0
99 if doPull ; then
100 doEnv
101 doChlog || errorExit "Error adding new changelog entry."
102 doTarball || errorExit "Error building source tarball."
103 doBuild || errorExit "Error during build of .deb package."
104 else
105 RC=1
108 cleanup
109 exit $RC