diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2004-12-17 11:04:18 +0000 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2004-12-17 11:04:18 +0000 |
commit | 60e7948db1fa335108cb43dc58d1c77859069896 (patch) | |
tree | 695722c98b0ad612664e7b9f9b3cc69dc291cccb /pkgs/build-support/fetchsvn/nix-prefetch-svn | |
parent | 2a3f5188b54e4bc202441ab54eced1f884ced5a3 (diff) | |
download | nixlib-60e7948db1fa335108cb43dc58d1c77859069896.tar nixlib-60e7948db1fa335108cb43dc58d1c77859069896.tar.gz nixlib-60e7948db1fa335108cb43dc58d1c77859069896.tar.bz2 nixlib-60e7948db1fa335108cb43dc58d1c77859069896.tar.lz nixlib-60e7948db1fa335108cb43dc58d1c77859069896.tar.xz nixlib-60e7948db1fa335108cb43dc58d1c77859069896.tar.zst nixlib-60e7948db1fa335108cb43dc58d1c77859069896.zip |
* Allow a known hash to be specified.
svn path=/nixpkgs/trunk/; revision=1892
Diffstat (limited to 'pkgs/build-support/fetchsvn/nix-prefetch-svn')
-rwxr-xr-x | pkgs/build-support/fetchsvn/nix-prefetch-svn | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/pkgs/build-support/fetchsvn/nix-prefetch-svn b/pkgs/build-support/fetchsvn/nix-prefetch-svn index 4ff17d7789de..7f5f6828941b 100755 --- a/pkgs/build-support/fetchsvn/nix-prefetch-svn +++ b/pkgs/build-support/fetchsvn/nix-prefetch-svn @@ -2,6 +2,7 @@ url=$1 rev=$2 +hash=$3 if test -z "$url"; then echo "syntax: nix-prefetch-svn URL [REVISION]" >&2 @@ -10,26 +11,31 @@ fi test -n "$rev" || rev="HEAD" -# !!! hacky; we should have a way to query the location of the store. -if storeDir=$(which nix-store); then - storeDir=$(dirname $(dirname "$storeDir"))/store -else - storeDir=/nix/store -fi +# Determine the hash, unless it was given. +if test -z "$hash"; then + + # !!! hacky; we should have a way to query the location of the store. + if storeDir=$(which nix-store); then + storeDir=$(dirname $(dirname "$storeDir"))/store + else + storeDir=/nix/store + fi -# !!! race? should be relatively safe, `svn export' barfs if $tmpPath exists. -tmpPath1=$storeDir/svn-checkout-tmp-$$ + # !!! race? should be relatively safe, `svn export' barfs if $tmpPath exists. + tmpPath1=$storeDir/svn-checkout-tmp-$$ -# Perform the checkout. -svn export -r "$rev" "$url" $tmpPath1 >&2 + # Perform the checkout. + svn export -r "$rev" "$url" $tmpPath1 >&2 -# Compute the hash. -hash=$(nix-hash $tmpPath1) -echo "hash is $hash" >&2 + # Compute the hash. + hash=$(nix-hash $tmpPath1) + echo "hash is $hash" >&2 -# Rename it so that the fetchsvn builder can find it. -tmpPath2=$storeDir/svn-checkout-tmp-$hash -test -e $tmpPath2 || mv $tmpPath1 $tmpPath2 # !!! race + # Rename it so that the fetchsvn builder can find it. + tmpPath2=$storeDir/svn-checkout-tmp-$hash + test -e $tmpPath2 || mv $tmpPath1 $tmpPath2 # !!! race + +fi # Create a Nix expression that does a fetchsvn. nixExpr=$(dirname $(readlink -f $0))/../../system/i686-linux.nix @@ -42,7 +48,9 @@ finalPath=$(nix-store -qnB --force-realise $storeExpr) echo "path is $finalPath" >&2 -rm -rf $tmpPath2 || true +if test -n "$tmpPath2"; then + rm -rf $tmpPath2 || true +fi echo $hash |