#!/bin/sh

checkport()
{
PORTNAME=$1
mkdir /tmp/distfiles-old /tmp/distfiles-new 1>/dev/null 2>&1

cvs -Q co -d $PORTNAME-new $PORTNAME
cvs -Q co -d $PORTNAME-old $PORTNAME

(cd $PORTNAME-new && make extract DISTDIR=/tmp/distfiles-new \
	MASTER_SITE_OVERRIDE= NO_DEPENDS=yes NO_CHECKSUM=yes)

(cd $PORTNAME-old && make extract DISTDIR=/tmp/distfiles-old \
	MASTER_SITE_OVERRIDE=ftp://ftp.freebsd.org/pub/FreeBSD/ports/distfiles/ \
	NO_DEPENDS=yes NO_CHECKSUM=yes)

ls -l $PORTNAME-old/work $PORTNAME-new/work

diff -urN $PORTNAME-old/work $PORTNAME-new/work > $PORTNAME.diff

if [ ! -s $PORTNAME.diff ]; then
	echo No changes found in diff.
fi

rm -rf $PORTNAME-old $PORTNAME-new /tmp/distfiles-*
}

for P in $@
do
checkport $P
done
