blob: 04fdfd89bde313907a1e6e5e89e57871b68392d1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
#! /bin/sh -e
distDir=/data/webserver/dist/tarballs
find "$1" -name "*.nix" | while read fn; do
grep -E '^ *url = ' "$fn" | while read line; do
if url=$(echo "$line" | sed 's^url = \(.*\);^\1^'); then
if ! echo "$url" | 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
base=$(basename $url)
newPath="$distDir/$base"
if test -e "$newPath"; then
#echo "$fn: checking hash of existing $newPath"
hash=$(fgrep -A 1 "$url" "$fn" | grep md5 | sed 's^.*md5 = \"\(.*\)\";.*^\1^')
hashType=md5
if test -z "$hash"; then
hash=$(fgrep -A 1 "$url" "$fn" | grep sha256 | sed 's^.*sha256 = \"\(.*\)\";.*^\1^')
hashType="sha256 --base32"
if test -z "$hash"; then
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
fi
fi
#echo "HASH = $hash"
if ! test "$(nix-hash --type $hashType --flat "$newPath")" = "$hash"; then
echo "WARNING: $fn: $newPath exists and differs!"
continue
fi
else
if echo $url | grep -q '^mirror://'; then
#echo "$fn: skipping mirrored $url"
continue
fi
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")
fi
fi
fi
done
done
|