#!/bin/bash

. /usr/lib/frugalware/fwmakepkg

if [ "$1" == "--help" ]; then
	echo "packages with moved github url"
	exit 1
fi

cd ..

for i in `find source -name FrugalBuild`
do
	cd `dirname $i`
	startdir=`pwd`

	for j in `set|grep -E '^(_F_|USE_)'|sed 's/\(=.*\| ()\)//'`; do unset $j; done

	source ./FrugalBuild
	if [[ $url == "https://github.com"* ]]; then
		new_url=$(curl  -w "%{redirect_url}" -o /dev/null -s $url)
		if [ -n "$new_url" ]; then
			if [ "$url" != "$new_url" ]; then
				echo "`dirname $i`: url is $url but redirects to $new_url"
			fi
		fi
	fi
	unset url new_url
	cd - >/dev/null
done
