#!/bin/bash
# Source release

# Copyright (C) 2008  Sylvain Beucler

# This file is part of GNU FreeDink

# GNU FreeDink is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.

# GNU FreeDink is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see
# <http://www.gnu.org/licenses/>.

set -ex

cd /usr/src/
if [ ! -e freedink.git ]; then
  git clone -n git://git.savannah.gnu.org/freedink freedink.git
fi
(cd freedink.git && git pull)

if [ ! -e freedink ]; then
    git clone freedink.git freedink
fi
cd freedink/
git checkout .
git pull
sh bootstrap clean

VERSION=1.08.$(date +%Y%m%d)
sed -i -e 's/^AC_INIT(\([^,]\+\),[^,]\+,\([^,]\+\))/AC_INIT(\1,['$VERSION'],\2)/' configure.ac
sed -i -e '1s/^[^:]\+:/'$VERSION':/' NEWS
sed -i -e '1s/^\([^ ]\+\) ([^)]\+)/\1 ('$VERSION'-1)/' debian/changelog

sh bootstrap
rm -rf build/
mkdir build
cd build/
../configure
# 'help2man' needs ./freedink needs ../gnulib/lib/*.[ah]
# and this isn't simple to implement this dependency,
# especially for 'make dist'.
# Let's do a 'make check' while we're at recompiling everything
make check
make dist-gzip

#mv *.tar.gz *.tar.bz2 *.zip /mnt/snapshots/
mv *.tar.gz /mnt/snapshots/
