* When copying tarballs to nix.cs.uu.nl, don't rewrite the URLs in the
Nix expressions anymore. The content-addressable mirror mechanism in fetchurl makes it unnecessary. svn path=/nixpkgs/trunk/; revision=9289
This commit is contained in:
parent
f45f9a71e1
commit
8b4a66c242
@ -1,46 +1,70 @@
|
||||
#! /bin/sh -e
|
||||
|
||||
find . -name "*.nix" | while read fn; do
|
||||
distDir=/data/webserver/dist/tarballs
|
||||
|
||||
find "$1" -name "*.nix" | while read fn; do
|
||||
|
||||
grep -E '^ *url = ' "$fn" | while read line; do
|
||||
|
||||
if oldURL=$(echo "$line" | sed 's^url = \(.*\);^\1^'); then
|
||||
if url=$(echo "$line" | sed 's^url = \(.*\);^\1^'); then
|
||||
|
||||
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
|
||||
base=$(basename $oldURL)
|
||||
newURL="http://nix.cs.uu.nl/dist/tarballs/$base"
|
||||
newPath="/data/webserver/dist/tarballs/$base"
|
||||
echo "$fn: $oldURL -> $newURL"
|
||||
|
||||
isSafe=1
|
||||
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
|
||||
hash=$(fgrep -A 1 "$oldURL" "$fn" | grep md5 | sed 's^.*md5 = \"\(.*\)\";.*^\1^')
|
||||
|
||||
#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 "$oldURL" "$fn" | grep sha256 | sed 's^.*sha256 = \"\(.*\)\";.*^\1^')
|
||||
hash=$(fgrep -A 1 "$url" "$fn" | grep sha256 | sed 's^.*sha256 = \"\(.*\)\";.*^\1^')
|
||||
hashType="sha256 --base32"
|
||||
if test -z "$hash"; then
|
||||
echo "WARNING: cannot figure out the hash for $oldURL"
|
||||
isSafe=
|
||||
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"
|
||||
#echo "HASH = $hash"
|
||||
if ! test "$(nix-hash --type $hashType --flat "$newPath")" = "$hash"; then
|
||||
echo "WARNING: $newPath exists and differs!"
|
||||
isSafe=
|
||||
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 "$doMove" -a -n "$isSafe"; then
|
||||
if test -n "$doCopy" -a -e "$newPath"; then
|
||||
|
||||
if ! test -e "$newPath"; then
|
||||
curl --disable-epsv --fail --location --max-redirs 20 "$oldURL" > "$newPath".tmp
|
||||
mv -f "$newPath".tmp "$newPath"
|
||||
fi
|
||||
md5=$(nix-hash --flat --type md5 "$newPath")
|
||||
ln -sfn "../$base" $distDir/md5/$md5
|
||||
|
||||
sed "s^$oldURL^$newURL^" < "$fn" > "$fn".tmp
|
||||
mv -f "$fn".tmp "$fn"
|
||||
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user