#!/bin/bash

# Copyright (C) 2005-2006 Miklos Vajna <vmiklos@frugalware.org>
# fwmakepkg for Frugalware
# distributed under GPL License

if [ -e /etc/repoman.conf ]; then
	. /etc/repoman.conf
else
	echo "Can't find /etc/repoman.conf!"
	exit 1
fi
[ -z "$startdir" ] && startdir=`pwd`

### Include a scheme. They are in $fst_root/source/include/, and they have a \
 # .sh suffix. After including them, you can of course overwrite the \
 # initialized values, using only a part of the scheme.
 # @param scheme(s) to include (_without_ the .sh suffix)
 ##
Finclude ()
{
	if [ "$startdir" = `pwd` ]; then
		local i
		i=`git rev-parse --git-dir 2>/dev/null`
		if [ "`type -p git`" -a -n "$i" ]; then
			i=`dirname $i`
			F_makepkg_scm=git
		else
		i=`pwd`
		while true
		do
			if [ -e "$i/_darcs" ]; then
				break
			elif [ "$i" == "" ]; then
				break
			fi
			i=${i%/*}
		done
		F_makepkg_scm=darcs
		fi
		if [ "$i" -a -d "$i"/source/include ]; then
			Fincdir=$i/source/include
		elif [ -d /var/tmp/fst/include ]; then
			Fincdir=/var/tmp/fst/include
		elif [ -d $fst_root/$repos/source/include ]; then
			Fincdir=$fst_root/$repos/source/include
		fi
		if [ ! -z "$Fincdir" ]; then
			for i in "$@"
			do
				source $Fincdir/$i.sh || Fdie
			done
		else
			echo "Could not find the scheme dir! (\$fst/source/include)"
			echo "Please edit your /etc/repoman.conf or ~/.repoman.conf."
			exit 2
		fi
	fi
}

Finclude util
