#! /bin/sh
#
# Copy selected baseline archives from this directory to the BBS portion
# of the CD.  The associated product info file is found by looking for
# a matching tree in the the source directory.  If it is not found, the
# copy is not done.

srcroot=/gnu/src/amiga
bbsdir=$1

# Check to see that the output BBS directory exists.  If not, exit.

if test ! -d $bbsdir ; then
	echo "$bbsdir does not exist!"
	exit 1
fi

for archive in *.lha *.tar.gz ; do
	case "$archive" in
		*.lha) toolname=`basename $archive .lha` ;;
		*.tar.gz) toolname=`basename $archive .tar.gz` ;;
	esac
	pifilein=""
	if test -f $archive.pi ; then
		pifilein="$archive.pi"
	elif test -f $srcroot/$toolname-src.lha.pi ; then
		pifilein="$srcroot/$toolname-src.lha.pi"
	fi
	if test -z "${pifilein}" ; then
		echo "WARNING - $archive ignored; missing product info file"
	else
		pifileout="$bbsdir/$archive.pi"
		echo "cp $pifilein $pifileout"
		cp $pifilein $pifileout
		echo "cp $archive $bbsdir/$archive"
		cp $archive $bbsdir/$archive
	fi
done
