makespool 616 Bytes
#! /bin/sh

if [ "$1" = "-r"]; then
	shift
	rm -rf $*
	exit 0
fi

mkdirhier() {
	dir=""
	for d in `echo $1|sed 's,/, ,g'`
	do
		dir="$dir/$d"
		test -d $dir || mkdir $dir
	done
}

while [ $# -gt 0 ]
do
	SRCDIR=${1:?}
	DSTDIR=${2:?}
	shift 2

	if [ ! -d $SRCDIR ]; then
		echo "$SRCDIR not a directory" >&2
		exit 1
	fi
	if [ ! -r $SRCDIR/DISTFILES ]; then
		echo "$SRCDIR/DISTFILES does not exist" >&2
		exit 1
	fi
	mkdirhier $DSTDIR
	chmod -R u+w $DSTDIR

	cat $SRCDIR/DISTFILES |
	while read NAME
	do
		test -f $DSTDIR/$NAME && rm $DSTDIR/$NAME
		cp $SRCDIR/$NAME $DSTDIR/$NAME
		chmod u+w $DSTDIR/$NAME
	done
done