8 hashType
=$NIX_HASH_ALGO
9 if test -z "$hashType"; then
13 if test -z "$cvsRoot"; then
14 echo "syntax: nix-prefetch-cvs CVSROOT MODULE [TAG [HASH]]" >&2
16 elif test -z "$module"; then
17 echo "syntax: nix-prefetch-cvs CVSROOT MODULE [TAG [HASH]]" >&2
23 # nix>=2.20 rejects adding symlinked paths to the store, so use realpath
24 # to resolve to a physical path. https://github.com/NixOS/nix/issues/11941
25 tmpPath
="$(realpath "$
(mktemp
-d --tmpdir nix-prefetch-csv-XXXXXXXX
)")"
26 trap removeTempDir EXIT
34 # If the hash was given, a file with that hash may already be in the
36 if test -n "$expHash"; then
37 finalPath
=$
(nix-store
--print-fixed-path --recursive "$hashType" "$expHash" cvs-export
)
38 if ! nix-store
--check-validity "$finalPath" 2> /dev
/null
; then
45 # If we don't know the hash or a path with that hash doesn't exist,
46 # download the file and add it to the store.
47 if test -z "$finalPath"; then
50 tmpFile
=$tmpPath/cvs-export
53 # Perform the checkout.
54 if test -z "$tag"; then
56 elif test "$USE_DATE" = "1"; then
61 (cd "$tmpPath" && cvs
-f -z0 -d $cvsRoot export "${args[*]}" -d cvs-export
$module >&2)
64 hash=$
(nix-hash
--type $hashType ${hashFormat:-"--sri"} $tmpFile)
65 if ! test -n "$QUIET"; then echo "hash is $hash" >&2; fi
67 # Add the downloaded file to the Nix store.
68 finalPath
=$
(nix-store
--add-fixed --recursive "$hashType" $tmpFile)
70 if test -n "$expHash" -a "$expHash" != "$hash"; then
71 echo "hash mismatch for CVS root \`$cvsRoot'"
76 if ! test -n "$QUIET"; then echo "path is $finalPath" >&2; fi
80 if test -n "$PRINT_PATH"; then