In hydra-evaluator, reuse an SVN working copy between runs (similar to what we do with Git and other input types). This reduces network traffic in the common case.
Also, don't use nix-prefetch-svn. It doesn't do anything useful.
ARD6Z67TDHK2XMW47CSVOXXF327YGOMYK3EAXTSVVXNDAFQYNO5AC
KX5L74EYLS4YVSFG5H6U5H5TB6BQUFHHFUMLHTUUU6WFJLSRF5ZAC
JZE7DC2FYU4TAGBTMZLXFTISJZ2FTCBLGUDUBKGH4UUIWXRIS3VAC
TM6XBAG2BHYF7HFIO6FRVGBZ6WVGZFPN5VGOA6WNLHZ56ICOOYXAC
L4AI5YL6CBMVS5GEPME3WIL2CHACMU7PGEKKNKLHHF5SP4ID3LCQC
O25D52TAMOPAK45N4II5XMWOBMPQJNHLW22M37COVY43EKNQBWJAC
OOQ2D3KCLFPYNAN253PHWLBQMB6OMO2KYQWQXLTP65SQAYZWQ5LAC
KQS7DSKJHTEHALCPTXMWRX2IBOVC5BWU7RWJ4GP5A2JJSBR7HPKAC
2WUNXJGWGHQRE24ZJT4VIP35OHO2E4VCKA65TCCKU55BNBIPABCAC
CHQEG6WY44VSOTLNH5KDZWJCCHNHRUCX6BEREXUUO56VOKHNSUZAC
BK24VA6QHPE6XLXUXPLJMOT75WEXHZ6PPOFLYFUP4U4NYS5FVGWAC
C7CXMZ66BZTI5ABDJNPL2JKSHSKDQ645GXUKN7OTQBPEQJ452KQAC
FXW2UR7FY7NPCEHSCAO4FTZHA47K5YACKHJJVKP6T3V42LJJTLAAC
3XTHEUMP2ZOMPQWE3S5QWHIHCEJNEXGDPQB3JUVZFPS3RFMY455QC
D5QIOJGPKQJIYBUCSC3MFJ3TXLPNZ2XMI37GXMFRVRFWWR2VMTFAC
DBPIYHMAHIV2ENFEWE474K5LV27WAHMR3ZZ5HF6FM7YVDM3MK4HQC
FV2M6MOTAP4BJMEKU5XUDVEACWEJGEIRCCE2MRY3F6SF2SFOE3MQC
FKTXLQVZSCCB4LCWV7SGVYRFG674YLCELRZWDNBOUI72V7CCAULQC
FGI75W53UYMOUBFP5HGSE7KVFAEZHIL6RWAY3FQ3HBQNWZYD4DKQC
# Then download this revision into the store.
print STDERR "checking out Subversion input ", $name, " from $uri revision $revision\n";
$ENV{"NIX_HASH_ALGO"} = "sha256";
$ENV{"PRINT_PATH"} = "1";
$ENV{"NIX_PREFETCH_SVN_LEAVE_DOT_SVN"} = "$checkout";
# No, do a checkout. The working copy is reused between
# invocations to speed things up.
mkpath(scmPath . "/svn");
my $wcPath = scmPath . "/svn" . sha256_hex($uri) . "/svn-checkout";
print STDERR "checking out Subversion input ", $name, " from $uri revision $revision into $wcPath\n";
("nix-prefetch-svn", $uri, $revision));
die "Cannot check out Subversion repository `$uri':\n$stderr" unless $res;
("svn", "checkout", $uri, "-r", $revision, $wcPath));
if ($checkout) {
$storePath = addToStore($wcPath, 1, "sha256");
} else {
# Hm, if the Nix Perl bindings supported filters in
# addToStore(), then we wouldn't need to make a copy here.
my $tmpDir = File::Temp->newdir("hydra-svn-export.XXXXXX", CLEANUP => 1, TMPDIR => 1) or die;
(system "svn", "export", $wcPath, "$tmpDir/svn-export", "--quiet") == 0 or die "svn export failed";
$storePath = addToStore("$tmpDir/svn-export", 1, "sha256");
}
#! /bin/sh -e
url=$1
rev=$2
expHash=$3
hashType=$NIX_HASH_ALGO
if test -z "$hashType"; then
hashType=sha256
fi
if test -z "$hashFormat"; then
hashFormat=--base32
fi
if test -z "$url"; then
echo "syntax: nix-prefetch-svn URL [REVISION [EXPECTED-HASH]]" >&2
exit 1
fi
test -n "$rev" || rev="HEAD"
repoName=$(echo $url | sed '
s,.*/\([^/]\+\)/trunk/*$,\1,;t
s,.*/\([^/]\+\)/branches/\([^/]\+\)/*$,\1-\2,;t
s,.*/\([^/]\+\)/tags/\([^/]\+\)/*$,\1-\2,;t
s,.*/\([^/]\+\)/*$,\1,;t
')
dstFile=$repoName-r$rev
# If the hash was given, a file with that hash may already be in the
# store.
if test -n "$expHash"; then
finalPath=$(nix-store --print-fixed-path --recursive "$hashType" "$expHash" $dstFile)
if ! nix-store --check-validity "$finalPath" 2> /dev/null; then
finalPath=
fi
hash=$expHash
fi
# If we don't know the hash or a path with that hash doesn't exist,
# download the file and add it to the store.
if test -z "$finalPath"; then
tmpPath=/tmp/svn-checkout-tmp-$$
tmpFile=$tmpPath/$dstFile
mkdir $tmpPath
trap "rm -rf $tmpPath" EXIT
# Perform the checkout.
if test "$NIX_PREFETCH_SVN_LEAVE_DOT_SVN" != 1
then
command="export"
else
command="checkout"
fi
echo p | svn "$command" --quiet -r "$rev" "$url" "$tmpFile" >&2
# Compute the hash.
hash=$(nix-hash --type $hashType $hashFormat $tmpFile)
if ! test -n "$QUIET"; then echo "hash is $hash" >&2; fi
# Add the downloaded file to the Nix store.
finalPath=$(nix-store --add-fixed --recursive "$hashType" $tmpFile)
if test -n "$expHash" -a "$expHash" != "$hash"; then
echo "hash mismatch for URL \`$url'"
exit 1
fi
fi
if ! test -n "$QUIET"; then echo "path is $finalPath" >&2; fi
echo $hash
if test -n "$PRINT_PATH"; then
echo $finalPath
fi