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 # nix>=2.20 rejects adding symlinked paths to the store, so use realpath
45 # to resolve to a physical path. https://github.com/NixOS/nix/issues/11941
46 tmpPath
="$(realpath "$
(mktemp
-d --tmpdir svn-checkout-tmp-XXXXXXXX
)")"
47 trap "rm -rf \"$tmpPath\"" EXIT
49 tmpFile
="$tmpPath/$dstFile"
51 # Perform the checkout.
52 if test "$NIX_PREFETCH_SVN_LEAVE_DOT_SVN" != 1
59 echo p | svn
"$command" --quiet -r "$rev" "$url" "$tmpFile" >&2
60 echo "svn revision is $(svn info -r "$rev" "$url" | grep "Revision
: " | cut -d' ' -f2)"
63 hash=$
(nix-hash
--type $hashType $hashFormat $tmpFile)
64 if ! test -n "$QUIET"; then echo "hash is $hash" >&2; fi
66 # Add the downloaded file to the Nix store.
67 finalPath
=$
(nix-store
--add-fixed --recursive "$hashType" $tmpFile)
69 if test -n "$expHash" -a "$expHash" != "$hash"; then
70 echo "hash mismatch for URL \`$url'"
75 if ! test -n "$QUIET"; then echo "path is $finalPath" >&2; fi
79 if test -n "$PRINT_PATH"; then