#!/bin/sh

exclude=cat
quick=false
version=`cat VERSION`
out=pl-$version.tar.gz
compress=gzip


while [ ! -z "$1" ]; do
    case "$1" in
	-lite)
		exclude="grep -v ^./packages/"
		out="pl-lite-$version.tar.gz"
		shift
		;;
	-q)	quick=true
	        shift
		;;
	*)
		echo "Usage: `basename $0`: [-lite]"
		exit 1
		;;
    esac
done

rm -f pl-$version
if [ "$quick" = false ]; then
  cp /dev/null cvsfiles
  echo -n "Collecting distribution files "
  for d in `find . -name CVS -type d -print`; do
      echo -n "."
      dir=`dirname $d`
      grep '^/' $dir/CVS/Entries | \
          awk -F/ '{printf("%s/%s\n", "'$dir'", $2)}' >> cvsfiles
  done
  echo "done"

cat >> cvsfiles << _EOM_
./pl.spec
_EOM_
fi

cat cvsfiles | \
	  $exclude | \
	  sed "s@^\./@pl-$version/@" > tapefiles

cd ..
rm -f pl-$version
ln -s pl pl-$version
tar cvfT - pl/tapefiles | $compress > $out
rm -f pl-$version


