7 hashType
=$NIX_HASH_ALGO
8 if test -z "$hashType"; then
11 if test -z "$hashFormat"; then
15 if test -z "$url"; then
16 echo "syntax: nix-prefetch-svn URL [REVISION [EXPECTED-HASH]]" >&2
20 test -n "$rev" ||
rev="HEAD"
22 repoName
=$
(echo $url |
sed '
23 s,.*/\([^/]\+\)/trunk/*$,\1,;t
24 s,.*/\([^/]\+\)/branches/\([^/]\+\)/*$,\1-\2,;t
25 s,.*/\([^/]\+\)/tags/\([^/]\+\)/*$,\1-\2,;t
26 s,.*/\([^/]\+\)/*$,\1,;t
28 dstFile
=$repoName-r$rev
30 # If the hash was given, a file with that hash may already be in the
32 if test -n "$expHash"; then
33 finalPath
=$
(nix-store
--print-fixed-path --recursive "$hashType" "$expHash" $dstFile)
34 if ! nix-store
--check-validity "$finalPath" 2> /dev
/null
; then
41 # If we don't know the hash or a path with that hash doesn't exist,
42 # download the file and add it to the store.
43 if test -z "$finalPath"; then
44 tmpPath
="$(mktemp -d "${TMPDIR:-/tmp}/svn-checkout-tmp-XXXXXXXX
")"
45 trap "rm -rf \"$tmpPath\"" EXIT
47 tmpFile
="$tmpPath/$dstFile"
49 # Perform the checkout.
50 if test "$NIX_PREFETCH_SVN_LEAVE_DOT_SVN" != 1
57 echo p | svn
"$command" --quiet -r "$rev" "$url" "$tmpFile" >&2
58 echo "svn revision is $(svn info -r "$rev" "$url" | grep "Revision
: " | cut -d' ' -f2)"
61 hash=$
(nix-hash
--type $hashType $hashFormat $tmpFile)
62 if ! test -n "$QUIET"; then echo "hash is $hash" >&2; fi
64 # Add the downloaded file to the Nix store.
65 finalPath
=$
(nix-store
--add-fixed --recursive "$hashType" $tmpFile)
67 if test -n "$expHash" -a "$expHash" != "$hash"; then
68 echo "hash mismatch for URL \`$url'"
73 if ! test -n "$QUIET"; then echo "path is $finalPath" >&2; fi
77 if test -n "$PRINT_PATH"; then