#!/bin/bash
#
# build-all-pkgs.sh
# 
# Copyright (C) 2006  Josef Kufner <jk@myserver.cz>
# 
# This program 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 2 of the License, or
# (at your option) any later version.
#
# This program 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.
#
# 

url=$(svn info | awk '$1 == "URL:" {print $2}')
rev=$(svn info | awk '$1 == "Revision:" {print $2}')

name="netboard2-rev$rev"

if [ ! -z "$url" ]
then
	[ -d build ] || mkdir build
	cd build || exit

	(
	
	echo svn export ...
	svn export -q "$url" $name/ || exit
	
	echo making tarball ...
	tar cjf $name.tar.bz2 $name/

	echo building debian packages ...
	for d in $name/*/
	do
		[ -d "$d/debian" ] && ( cd "$d" ; pwd ; fakeroot dpkg-buildpackage )
	done

	echo cleaning ...
	mv $name/*.deb $name/*.tar.gz $name/*.dsc ./
	rm -rf $name/
	
	) 2>&1 | tee build.log

	echo
	echo
	echo "Build finished. Result is in 'build/' directory."
	echo
fi



