7d896e9181bce5fd245e15a5f1a2ec410223356e
[citadel.git] / webcit / buildpackages
1 #!/bin/bash
2 if test -x Makefile; then
3     make clean
4 fi
5 ./bootstrap
6 export `grep PACKAGE_VERSION= configure |sed -e "s;';;g" -e "s;PACKAGE;WEBCIT;"`
7
8 PACKAGE_VERSION=`cat packageversion`
9 DATE=`date '+%a, %d %b %Y %H:%I:00 %z'`
10 ACTUAL_DIR=`pwd`
11
12 if echo "$ACTUAL_DIR" |grep -q "$WEBCIT_VERSION"; then
13         echo "directory ($ACTUAL_DIR) naming scheme seems right. nothing done."
14 else
15         done=false
16         if test -L "$ACTUAL_DIR"; then 
17                 SYMLINK_=`pwd`
18                 SYMLINK=`ls -l $SYMLINK_|sed "s;.*-> ;;"`
19                 if ls -l $SYMLINK_|grep -q "$WEBCIT_VERSION"; then
20                         done=true
21                 fi
22         else
23                 SYMLINK=`pwd|sed "s;.*/;;"`
24         fi
25         if test "$done" = "false"; then 
26                 cd ..
27                 mv -- $SYMLINK "webcit-$WEBCIT_VERSION"
28                 ln -sf "webcit-$WEBCIT_VERSION" webcit
29                 cd "webcit-$WEBCIT_VERSION"
30         else
31                 cd "../webcit-$WEBCIT_VERSION"
32         fi
33         
34 fi
35
36 case $1 in
37     debian)
38         if grep -q "($WEBCIT_VERSION" debian/changelog; then
39             echo rebuilding package.
40         else
41             echo "Upstream Version higher than local."      
42         fi
43         if test "$2" == "src"; then
44             cd ..
45             rm -rf tmp
46             mkdir tmp
47             cp -a webcit-$WEBCIT_VERSION tmp
48             cd tmp/webcit-$WEBCIT_VERSION
49             rm -rf `find -name .svn ` svn*tmp* build-stamp configure-stamp *~ config.guess  config.log config.status autom4te.cache
50             cd ..
51             tar -czf webcit_${WEBCIT_VERSION}.orig.tar.gz webcit-${WEBCIT_VERSION}/ --exclude "debian/*"
52             pwd
53             cd  webcit-${WEBCIT_VERSION}; debuild -S -sa -kw.goesgens@outgesourced.org
54         else
55             fakeroot dpkg-buildpackage
56         fi
57         ;;
58     sourcedist)
59         cd ..; tar --exclude .svn --exclude "debian/*" -cvzf webcit-${WEBCIT_VERSION}.tar.gz webcit-${WEBCIT_VERSION}/
60         ;;
61     *)
62         echo "Not yet implemented. we have: debian "
63         ;;
64 esac