* nix-copy-closure: force a login shell on the remote machine to make
sure that nix-store is in the PATH. * nix-copy-closure: option --gzip to compress data.
This commit is contained in:
		
							parent
							
								
									4c5e6d1a2f
								
							
						
					
					
						commit
						fa2be32034
					
				
					 1 changed files with 11 additions and 3 deletions
				
			
		| 
						 | 
					@ -15,10 +15,13 @@ EOF
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Get the target host.
 | 
					# Get the target host.
 | 
				
			||||||
my $sshHost = shift @ARGV;
 | 
					my $sshHost = shift @ARGV;
 | 
				
			||||||
my @sshOpts = split ' ', $ENV{"NIX_SSHOPTS"};
 | 
					my @sshOpts = split ' ', ($ENV{"NIX_SSHOPTS"} or "");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
my $sign = 0;
 | 
					my $sign = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					my $compressor = "cat";
 | 
				
			||||||
 | 
					my $decompressor = "cat";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# !!! Copied from nix-pack-closure, should put this in a module.
 | 
					# !!! Copied from nix-pack-closure, should put this in a module.
 | 
				
			||||||
my %storePathsSeen;
 | 
					my %storePathsSeen;
 | 
				
			||||||
| 
						 | 
					@ -30,6 +33,11 @@ while (@ARGV) {
 | 
				
			||||||
        $sign = 1;
 | 
					        $sign = 1;
 | 
				
			||||||
        next;
 | 
					        next;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    if ($storePath eq "--gzip") {
 | 
				
			||||||
 | 
					        $compressor = "gzip";
 | 
				
			||||||
 | 
					        $decompressor = "gunzip";
 | 
				
			||||||
 | 
					        next;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # $storePath might be a symlink to the store, so resolve it.
 | 
					    # $storePath might be a symlink to the store, so resolve it.
 | 
				
			||||||
    $storePath = (`$binDir/nix-store --query --resolve '$storePath'`
 | 
					    $storePath = (`$binDir/nix-store --query --resolve '$storePath'`
 | 
				
			||||||
| 
						 | 
					@ -54,7 +62,7 @@ while (@ARGV) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Ask the remote host which paths are invalid.
 | 
					# Ask the remote host which paths are invalid.
 | 
				
			||||||
open(READ, "-|", "ssh", @sshOpts, $sshHost, "nix-store", "--check-validity", "--print-invalid", @storePaths);
 | 
					open(READ, "ssh @sshOpts $sshHost sh --login -c '\"nix-store --check-validity --print-invalid @storePaths\"'|");
 | 
				
			||||||
my @missing = ();
 | 
					my @missing = ();
 | 
				
			||||||
while (<READ>) {
 | 
					while (<READ>) {
 | 
				
			||||||
    chomp;
 | 
					    chomp;
 | 
				
			||||||
| 
						 | 
					@ -68,6 +76,6 @@ close READ or die;
 | 
				
			||||||
if (scalar @missing > 0) {
 | 
					if (scalar @missing > 0) {
 | 
				
			||||||
    my $extraOpts = "";
 | 
					    my $extraOpts = "";
 | 
				
			||||||
    $extraOpts .= "--sign" if $sign == 1;
 | 
					    $extraOpts .= "--sign" if $sign == 1;
 | 
				
			||||||
    system("nix-store --export $extraOpts @missing | ssh @sshOpts $sshHost nix-store --import") == 0
 | 
					    system("nix-store --export $extraOpts @missing | $compressor | ssh @sshOpts $sshHost sh --login -c '\"$decompressor | nix-store --import\"'") == 0
 | 
				
			||||||
        or die "copying store paths to remote machine failed: $?";
 | 
					        or die "copying store paths to remote machine failed: $?";
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue