#!/bin/sh

# (c) 2006 Rohan Dhruva
# svn.sh for Frugalware
# distributed under GPL License

# Manages the pkgver and provides a default build()

if [ -z "$_F_svn_svntrunk" -o -z "$_F_svn_svnmod" ]; then
	Fmessage "No SVN variables found!"
	Fmessage "Please use _F_svn_svnroot and _F_svn_svnmod variables"
	Fmessage "for the server and the svn module name respectively."
	Fmessage "Aborting!"
	Fdie
fi

makedepends=(${makedepends[@]} 'subversion')

Fsvnget()
{
	pkgver=`svn log $_F_svn_svntrunk --limit 1 | grep -m 1 -o "r.*" | cut -d \| -f 1 | sed s@r@@g`
	Fmessage "Current SVN revision is: $pkgver"
	touch ~/.subversion # ensure that svn doesnt error out if never used before
	svn co -N $_F_svn_svntrunk/$_F_svn_svnmod
	if [ $? != 0 ]; then
		Fmessage "Error while checking out the repo!"
		Fdie
	fi
	Fmessage "Checkout done."
	cd $_F_svn_svnmod
	if [ "$_F_svn_autoconf" != "no" -a -x autogen.sh ]; then
		Fsed './configure' '#./configure' autogen.sh
		./autogen.sh || Fdie
	fi
}

build()
{
        Fsvnget
	Fbuild
}

unset _F_svn_svnroot _F_svn_svnmod _F_svn_autoconf

