2005-02-15 14:32:55 +00:00
|
|
|
#! /bin/sh -e
|
|
|
|
|
2007-09-10 23:47:22 +01:00
|
|
|
distDir=/data/webserver/dist/tarballs
|
2005-02-15 14:32:55 +00:00
|
|
|
|
2007-09-10 23:47:22 +01:00
|
|
|
find "$1" -name "*.nix" | while read fn; do
|
2005-02-15 14:32:55 +00:00
|
|
|
|
2007-09-10 23:47:22 +01:00
|
|
|
grep -E '^ *url = ' "$fn" | while read line; do
|
2005-02-15 14:32:55 +00:00
|
|
|
|
2007-09-10 23:47:22 +01:00
|
|
|
if url=$(echo "$line" | sed 's^url = \(.*\);^\1^'); then
|
2005-02-15 14:32:55 +00:00
|
|
|
|
2008-11-14 16:57:19 +00:00
|
|
|
if ! echo "$url" | grep -q -E "www.cs.uu.nl|nixos.org|.stratego-language.org|java.sun.com|ut2004|linuxq3a|RealPlayer|Adbe|belastingdienst|microsoft|armijn/.nix|sun.com|archive.eclipse.org"; then
|
2007-09-11 12:15:37 +01:00
|
|
|
base="$(basename "$url")"
|
2007-09-10 23:47:22 +01:00
|
|
|
newPath="$distDir/$base"
|
2006-01-30 16:20:35 +00:00
|
|
|
|
2006-10-12 16:59:15 +01:00
|
|
|
if test -e "$newPath"; then
|
2007-09-10 23:47:22 +01:00
|
|
|
|
|
|
|
#echo "$fn: checking hash of existing $newPath"
|
|
|
|
hash=$(fgrep -A 1 "$url" "$fn" | grep md5 | sed 's^.*md5 = \"\(.*\)\";.*^\1^')
|
2007-05-15 14:33:14 +01:00
|
|
|
hashType=md5
|
|
|
|
if test -z "$hash"; then
|
2007-09-10 23:47:22 +01:00
|
|
|
hash=$(fgrep -A 1 "$url" "$fn" | grep sha256 | sed 's^.*sha256 = \"\(.*\)\";.*^\1^')
|
2007-05-15 14:33:14 +01:00
|
|
|
hashType="sha256 --base32"
|
2007-09-11 12:15:37 +01:00
|
|
|
if test -n "$hash"; then
|
|
|
|
if test "${#hash}" = 64; then
|
|
|
|
hash=$(nix-hash --to-base32 --type sha256 $hash)
|
|
|
|
fi
|
|
|
|
else
|
2007-09-10 23:47:22 +01:00
|
|
|
hash=$(fgrep -A 1 "$url" "$fn" | grep sha1 | sed 's^.*sha1 = \"\(.*\)\";.*^\1^')
|
|
|
|
hashType="sha1"
|
|
|
|
if test -z "$hash"; then
|
|
|
|
echo "WARNING: $fn: cannot figure out the hash for $url"
|
|
|
|
continue
|
|
|
|
fi
|
2007-05-15 14:33:14 +01:00
|
|
|
fi
|
|
|
|
fi
|
2007-09-10 23:47:22 +01:00
|
|
|
#echo "HASH = $hash"
|
2007-05-15 14:33:14 +01:00
|
|
|
if ! test "$(nix-hash --type $hashType --flat "$newPath")" = "$hash"; then
|
2007-09-11 12:15:37 +01:00
|
|
|
echo "WARNING: $fn: $newPath exists and differs, hash should be $hash!"
|
2007-09-10 23:47:22 +01:00
|
|
|
continue
|
2006-10-12 16:59:15 +01:00
|
|
|
fi
|
2006-10-12 14:50:54 +01:00
|
|
|
|
2007-09-10 23:47:22 +01:00
|
|
|
else
|
2006-01-30 16:20:35 +00:00
|
|
|
|
2007-09-11 12:15:37 +01:00
|
|
|
if echo $url | grep -q 'mirror://'; then
|
2007-09-10 23:47:22 +01:00
|
|
|
#echo "$fn: skipping mirrored $url"
|
|
|
|
continue
|
2006-10-12 14:50:54 +01:00
|
|
|
fi
|
2006-01-30 16:20:35 +00:00
|
|
|
|
2007-09-10 23:47:22 +01:00
|
|
|
echo "$fn: $url -> $newPath"
|
|
|
|
|
|
|
|
if test -n "$doCopy"; then
|
|
|
|
if ! curl --disable-epsv --fail --location --max-redirs 20 --remote-time \
|
|
|
|
"$url" --output "$newPath".tmp; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
mv -f "$newPath".tmp "$newPath"
|
|
|
|
fi
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test -n "$doCopy" -a -e "$newPath"; then
|
|
|
|
|
|
|
|
md5=$(nix-hash --flat --type md5 "$newPath")
|
|
|
|
ln -sfn "../$base" $distDir/md5/$md5
|
|
|
|
|
|
|
|
sha1=$(nix-hash --flat --type sha1 "$newPath")
|
|
|
|
ln -sfn "../$base" $distDir/sha1/$sha1
|
|
|
|
|
|
|
|
sha256=$(nix-hash --flat --type sha256 "$newPath")
|
|
|
|
ln -sfn "../$base" $distDir/sha256/$sha256
|
|
|
|
ln -sfn "../$base" $distDir/sha256/$(nix-hash --type sha256 --to-base32 "$sha256")
|
2006-10-12 16:59:15 +01:00
|
|
|
|
2006-10-12 14:50:54 +01:00
|
|
|
fi
|
2005-02-15 14:32:55 +00:00
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
done
|
|
|
|
|
2007-09-11 12:15:37 +01:00
|
|
|
done
|
|
|
|
|
2008-11-14 16:57:19 +00:00
|
|
|
echo DONE
|