#!/bin/bash
# pkg-urlcheck: Checks URIs in PKGBUILDs
# Written by Abhishek Dasgupta <abhidg@gmail.com>
# Last updated: 9 October 2008

# BUGS
#  Redirects are not yet understood by wget, so
#  they show up as false positives.

readonly prog_name="pkg-urlcheck"
readonly prog_ver="0.1"

COMMUNITY_ROOT=$HOME/arch/community

cd "$COMMUNITY_ROOT"
echo -n "started: "; date
pprint() {
	echo -n "${1//\/PKGBUILD} ($2)"
}

for p in $(find . | grep PKGBUILD); do
	source "$p"
	/opt/local/bin/wget --spider "$url" --tries=1 --timeout=30 -a wget.log
	if [ $? -gt 0 ]; then
		pprint $p fail
	else
		pprint $p ok
	fi
done
echo -n "finished: "; date

