#!/bin/sh
# 
# Gets the name of a file containing basename, pathname and revision numbers
# and uses buildrpms to generate a list of all rpms that are generated from it.
# buildrpms in itself rebuilds the rpms if needed.
#
#set -x
RPMBASE=empty
VERBOSE=0

TMP=`mktemp`

# Clear build.log
> $MYBUILDLOG

if [ -z "$1" ]
then
	echo usage: $0 filename
	exit 1
fi

if [ "$1" = "-v" ]
then
	VERBOSE=1
	shift
fi

while :
do
	read RPMBASE SVNPATH VERSION
	if [ -z $RPMBASE ]
	then
		break
	fi

	if [ `echo $RPMBASE| grep -c '^#'` -eq 1 ]
	then
		continue 1 
	fi

	if [ `echo $RPMBASE| grep -c '^-'` -eq 1 ]
	then
		continue 1 
	fi

	if [ `echo $RPMBASE| grep -c '^+'` -eq 1 ]
	then
		continue 1 
	fi

	if [ "$VERBOSE" -eq 1 ]
	then
		echo buildrpms $RPMBASE $SVNPATH $VERSION 1>&2
	fi

	# Build the svn package.
	buildrpms $RPMBASE $SVNPATH $VERSION

done < $1 > $TMP

cat $TMP
