2005-02-15 15:32:55 +01:00
|
|
|
#! /bin/sh -e
|
|
|
|
|
|
|
|
find . -name "*.nix" | while read fn; do
|
|
|
|
|
|
|
|
grep -E '^ *url = ' "$fn" | while read line; do
|
|
|
|
|
|
|
|
if oldURL=$(echo "$line" | sed 's^url = \(.*\);^\1^'); then
|
|
|
|
|
2006-10-12 17:59:15 +02:00
|
|
|
if ! echo "$oldURL" | grep -q -E "www.cs.uu.nl|nix.cs.uu.nl|.stratego-language.org|java.sun.com|ut2004|linuxq3a|RealPlayer|Adbe|belastingdienst|microsoft|armijn/.nix|sun.com|archive.eclipse.org"; then
|
2005-02-15 15:32:55 +01:00
|
|
|
base=$(basename $oldURL)
|
2006-01-30 17:20:35 +01:00
|
|
|
newURL="http://nix.cs.uu.nl/dist/tarballs/$base"
|
|
|
|
newPath="/data/webserver/dist/tarballs/$base"
|
2005-02-15 15:32:55 +01:00
|
|
|
echo "$fn: $oldURL -> $newURL"
|
|
|
|
|
2006-10-12 17:59:15 +02:00
|
|
|
isSafe=1
|
2006-01-30 17:20:35 +01:00
|
|
|
|
2006-10-12 17:59:15 +02:00
|
|
|
if test -e "$newPath"; then
|
|
|
|
hash=$(fgrep -A 1 "$oldURL" "$fn" | grep md5 | sed 's^.*md5 = \"\(.*\)\";.*^\1^')
|
|
|
|
echo "HASH = $hash"
|
|
|
|
if ! test "$(nix-hash --type md5 --flat "$newPath")" = "$hash"; then
|
|
|
|
echo "WARNING: $newPath exists and differs!"
|
|
|
|
isSafe=
|
|
|
|
fi
|
|
|
|
fi
|
2006-10-12 15:50:54 +02:00
|
|
|
|
2006-10-12 17:59:15 +02:00
|
|
|
if test -n "$doMove" -a -n "$isSafe"; then
|
2006-01-30 17:20:35 +01:00
|
|
|
|
2006-10-12 17:59:15 +02:00
|
|
|
if ! test -e "$newPath"; then
|
|
|
|
curl --disable-epsv --fail --location --max-redirs 20 "$oldURL" > "$newPath".tmp
|
|
|
|
mv -f "$newPath".tmp "$newPath"
|
2006-10-12 15:50:54 +02:00
|
|
|
fi
|
2006-01-30 17:20:35 +01:00
|
|
|
|
2006-10-12 17:59:15 +02:00
|
|
|
sed "s^$oldURL^$newURL^" < "$fn" > "$fn".tmp
|
|
|
|
mv -f "$fn".tmp "$fn"
|
|
|
|
|
2006-10-12 15:50:54 +02:00
|
|
|
fi
|
2005-02-15 15:32:55 +01:00
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
done
|
|
|
|
|
|
|
|
done
|