From 67617574280a5db534e5b5c643a3b880d1b9336c Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 11 Oct 2011 15:41:13 +0000 Subject: * Use the Store API bindings in nix-copy-closure. --- scripts/nix-copy-closure.in | 31 +++---------------------------- 1 file changed, 3 insertions(+), 28 deletions(-) (limited to 'scripts') diff --git a/scripts/nix-copy-closure.in b/scripts/nix-copy-closure.in index 966f860d0b51..db76b7165ee6 100755 --- a/scripts/nix-copy-closure.in +++ b/scripts/nix-copy-closure.in @@ -2,6 +2,7 @@ use Nix::SSH; use Nix::Config; +use Nix::Store; if (scalar @ARGV < 1) { @@ -57,19 +58,8 @@ openSSHConnection $sshHost or die "$0: unable to start SSH\n"; if ($toMode) { # Copy TO the remote machine. - my @allStorePaths; - # Get the closure of this path. - my $pid = open(READ, "set -f; $Nix::Config::binDir/nix-store --query --requisites @storePaths|") or die; - - while () { - chomp; - die "bad: $_" unless /^\//; - push @allStorePaths, $_; - } - - close READ or die "nix-store failed: $?"; - + my @allStorePaths = reverse(topoSortPaths(computeFSClosure(0, 0, map { followLinksToStorePath $_ } @storePaths))); # Ask the remote host which paths are invalid. open(READ, "set -f; ssh $sshHost @sshOpts nix-store --check-validity --print-invalid @allStorePaths|"); @@ -80,7 +70,6 @@ if ($toMode) { # Copy TO the remote machine. } close READ or die; - # Export the store paths and import them on the remote machine. if (scalar @missing > 0) { print STDERR "copying these missing paths:\n"; @@ -93,7 +82,6 @@ if ($toMode) { # Copy TO the remote machine. } - else { # Copy FROM the remote machine. # Query the closure of the given store paths on the remote @@ -102,27 +90,14 @@ else { # Copy FROM the remote machine. my $pid = open(READ, "set -f; ssh @sshOpts $sshHost nix-store --query --requisites @storePaths|") or die; - my @allStorePaths; - while () { chomp; die "bad: $_" unless /^\//; - push @allStorePaths, $_; + push @missing, $_ unless isValidPath($_); } close READ or die "nix-store on remote machine `$sshHost' failed: $?"; - - # What paths are already valid locally? - open(READ, "set -f; @bindir@/nix-store --check-validity --print-invalid @allStorePaths|"); - my @missing = (); - while () { - chomp; - push @missing, $_; - } - close READ or die; - - # Export the store paths on the remote machine and import them on locally. if (scalar @missing > 0) { print STDERR "copying these missing paths:\n"; -- cgit 1.4.1