diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2004-04-14 10:55:33 +0000 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2004-04-14 10:55:33 +0000 |
commit | 5c847a370a218390781296f1c63fead40a2e17e8 (patch) | |
tree | ab9a01a86b3572c342b55fad45892bd0ae5300c2 /pkgs/build-support/fetchsvn/nix-prefetch-svn | |
parent | f7561cf00ed8bd0c9278e363362e7f7ded5a990e (diff) | |
download | nixlib-5c847a370a218390781296f1c63fead40a2e17e8.tar nixlib-5c847a370a218390781296f1c63fead40a2e17e8.tar.gz nixlib-5c847a370a218390781296f1c63fead40a2e17e8.tar.bz2 nixlib-5c847a370a218390781296f1c63fead40a2e17e8.tar.lz nixlib-5c847a370a218390781296f1c63fead40a2e17e8.tar.xz nixlib-5c847a370a218390781296f1c63fead40a2e17e8.tar.zst nixlib-5c847a370a218390781296f1c63fead40a2e17e8.zip |
* `fetchsvn' now requires the MD5 hash (as computed by `nix-hash') of
the tree being fetched from a Subversion repository. The revision number is now optional (and defaults to HEAD). This makes `fetchsvn' more pure. First, a URL/revision tuple does not uniquely identify a file resource, since the repository itself might change. Second, `svn:external' attributes can cause arbitrary resources to be exported. A script `nix-prefetch-svn' has been provided to determine the hash of a URL. svn path=/nixpkgs/trunk/; revision=938
Diffstat (limited to 'pkgs/build-support/fetchsvn/nix-prefetch-svn')
-rwxr-xr-x | pkgs/build-support/fetchsvn/nix-prefetch-svn | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/pkgs/build-support/fetchsvn/nix-prefetch-svn b/pkgs/build-support/fetchsvn/nix-prefetch-svn new file mode 100755 index 000000000000..9d037032b1c7 --- /dev/null +++ b/pkgs/build-support/fetchsvn/nix-prefetch-svn @@ -0,0 +1,47 @@ +#! /bin/sh -e + +url=$1 +rev=$2 + +if test -z "$url"; then + echo "syntax: nix-prefetch-svn URL [REVISION]" >&2 + exit 1 +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 + +# !!! 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 + +# 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 + +# Create a Nix expression that does a fetchsvn. +nixExpr=$(dirname $(readlink -f $0))/../../system/i686-linux.nix +storeExpr=$( \ + echo "(import $nixExpr).fetchsvn {url=\"$url\"; rev=\"$rev\"; md5=\"$hash\";}" \ + | nix-instantiate -) + +# Realise it. +finalPath=$(nix-store -qnB --force-realise $storeExpr) + +echo "path is $finalPath" >&2 + +rm -rf $tmpPath2 || true + +echo $hash |