#!/bin/bash
#
# Celestia deb builder
#
# A cvs checkout is expected in ~/celestia-cvs
# A ~/debian directory must exist and hold a celestia.diff.gz patch
# (a copy of the latest diff.gz from
http://epicycle.free.fr/ubuntu/ )
#
DATE=`date +'%Y%m%d'`
CUR_VER=1.4.1
VER=1.4.99-cvs$DATE
# update the CVS checkout
cd ~/celestia-cvs
cvs up -PAd
cd ..
# make a copy, and update the version number
if [ -d celestia_$DATE ] ; then rm -rf celestia_$DATE ; fi
cp -a celestia-cvs celestia_$DATE
cd celestia_$DATE
sed -e "s/\[$CUR_VER\]/[$VER]/" < configure.in > configure.in_ && \
rm configure.in && \
mv configure.in_ configure.in
if [ -f Makefile.am.wo ] ; then rm Makefile.am.wo ; fi
# generate the configure script, run it and generate the distribution
make -f Makefile.cvs
cd ~/celestia_$DATE
./configure --with-kde
touch Makefile.am.wo
make dist
cd
# rename distribution, move it under ~/debian/ and remove the work directory
mv celestia_$DATE/celestia-$VER.tar.gz debian/celestia_$VER.orig.tar.gz
rm -rf celestia_$DATE
# untar the distribution and apply the debian patch
cd debian
tar xvzf celestia_$VER.orig.tar.gz
cd celestia-$VER
zcat ../celestia.diff.gz | patch -p1
# update the version number in Changelog
# (otherwise debuild complains about unmatching version numbers)
cd debian
sed -e "1 s/\\(.*\\)(.*)\\(.*\\)/\\1($VER-0ubuntu1~ppa1)\\2/" < changelog > changelog_ && \
rm changelog && \
mv changelog_ changelog
cd ..
#
# you can apply other changes to debian/ or the sources here
#
# generate the packages
debuild -S -sa
-kchris@teyssier.orgcd ..