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-bzr URL [REVISION [EXPECTED-HASH]]" >&2
21 test -n "$rev" || revarg
=""
23 repoName
=$
(echo $url |
sed '
24 s,.*/\([^/]\+\)/trunk/*$,\1,;t
25 s,.*/\([^/]\+\)/branches/\([^/]\+\)/*$,\1-\2,;t
26 s,.*/\([^/]\+\)/tags/\([^/]\+\)/*$,\1-\2,;t
27 s,.*/\([^/]\+\)/*$,\1,;t
31 # If the hash was given, a file with that hash may already be in the
33 if test -n "$expHash"; then
34 finalPath
=$
(nix-store
--print-fixed-path --recursive "$hashType" "$expHash" $dstFile)
35 if ! nix-store
--check-validity "$finalPath" 2> /dev
/null
; then
42 # If we don't know the hash or a path with that hash doesn't exist,
43 # download the file and add it to the store.
44 if test -z "$finalPath"; then
45 tmpPath
="$(mktemp -d "${TMPDIR:-/tmp}/bzr-checkout-tmp-XXXXXXXX
")"
46 trap "rm -rf \"$tmpPath\"" EXIT
48 tmpFile
="$tmpPath/$dstFile"
50 # Perform the checkout.
51 bzr
-Ossl.cert_reqs
=none
export $revarg --format=dir
"$tmpFile" "$url"
53 echo "bzr revision is $(bzr revno $revarg "$url")"
56 hash=$
(nix-hash
--type $hashType $hashFormat $tmpFile)
57 if ! test -n "$QUIET"; then echo "hash is $hash" >&2; fi
59 # Add the downloaded file to the Nix store.
60 finalPath
=$
(nix-store
--add-fixed --recursive "$hashType" $tmpFile)
62 if test -n "$expHash" -a "$expHash" != "$hash"; then
63 echo "hash mismatch for URL \`$url'"
68 if ! test -n "$QUIET"; then echo "path is $finalPath" >&2; fi
72 if test -n "$PRINT_PATH"; then