From a3d6585c5a1006d4f9ebd2163d06f86ab71a4a3e Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 23 Nov 2012 16:20:16 +0100 Subject: nix-copy-closure: Add flag ‘--use-substitutes’ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/nix-copy-closure.in | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'scripts') diff --git a/scripts/nix-copy-closure.in b/scripts/nix-copy-closure.in index 0eb7a4ed0c16..1a1684ed00ac 100755 --- a/scripts/nix-copy-closure.in +++ b/scripts/nix-copy-closure.in @@ -17,19 +17,14 @@ EOF # Get the target host. my $sshHost; - my $sign = 0; - my $compressor = ""; my $decompressor = ""; - my $progressViewer = ""; - my $toMode = 1; - my $includeOutputs = 0; - my $dryRun = 0; +my $useSubstitutes = 0; # !!! Copied from nix-pack-closure, should put this in a module. @@ -71,6 +66,9 @@ while (@ARGV) { elsif ($arg eq "--dry-run") { $dryRun = 1; } + elsif ($arg eq "--use-substitutes" || $arg eq "-s") { + $useSubstitutes = 1; + } elsif (!defined $sshHost) { $sshHost = $arg; } @@ -84,7 +82,9 @@ openSSHConnection $sshHost or die "$0: unable to start SSH\n"; if ($toMode) { # Copy TO the remote machine. - Nix::CopyClosure::copyTo($sshHost, [ @sshOpts ], [ @storePaths ], $compressor, $decompressor, $includeOutputs, $dryRun, $sign, $progressViewer); + Nix::CopyClosure::copyTo( + $sshHost, [ @sshOpts ], [ @storePaths ], $compressor, $decompressor, + $includeOutputs, $dryRun, $sign, $progressViewer, $useSubstitutes); } else { # Copy FROM the remote machine. @@ -107,10 +107,13 @@ else { # Copy FROM the remote machine. # Export the store paths on the remote machine and import them locally. if (scalar @missing > 0) { print STDERR "copying ", scalar @missing, " missing paths from ‘$sshHost’...\n"; - $compressor = "| $compressor" if $compressor ne ""; - $decompressor = "$decompressor |" if $decompressor ne ""; - $progressViewer = "$progressViewer |" if $progressViewer ne ""; unless ($dryRun) { + if ($useSubstitutes) { + system "$Nix::Config::binDir/nix-store -r --ignore-unknown @missing"; + } + $compressor = "| $compressor" if $compressor ne ""; + $decompressor = "$decompressor |" if $decompressor ne ""; + $progressViewer = "$progressViewer |" if $progressViewer ne ""; my $extraOpts = $sign ? "--sign" : ""; system("set -f; ssh $sshHost @sshOpts 'nix-store --export $extraOpts @missing $compressor' | $progressViewer $decompressor $Nix::Config::binDir/nix-store --import > /dev/null") == 0 or die "copying store paths from remote machine `$sshHost' failed: $?"; -- cgit 1.4.1