From fa2be32034dcb25f9382dda91514a7785211f443 Mon Sep 17 00:00:00 2001
From: Eelco Dolstra <e.dolstra@tudelft.nl>
Date: Thu, 22 Feb 2007 16:42:01 +0000
Subject: * 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.

---
 scripts/nix-copy-closure.in | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/scripts/nix-copy-closure.in b/scripts/nix-copy-closure.in
index 80a6a80518b5..13b9694656fd 100644
--- a/scripts/nix-copy-closure.in
+++ b/scripts/nix-copy-closure.in
@@ -15,10 +15,13 @@ EOF
 
 # Get the target host.
 my $sshHost = shift @ARGV;
-my @sshOpts = split ' ', $ENV{"NIX_SSHOPTS"};
+my @sshOpts = split ' ', ($ENV{"NIX_SSHOPTS"} or "");
 
 my $sign = 0;
 
+my $compressor = "cat";
+my $decompressor = "cat";
+
 
 # !!! Copied from nix-pack-closure, should put this in a module.
 my %storePathsSeen;
@@ -30,6 +33,11 @@ while (@ARGV) {
         $sign = 1;
         next;
     }
+    if ($storePath eq "--gzip") {
+        $compressor = "gzip";
+        $decompressor = "gunzip";
+        next;
+    }
 
     # $storePath might be a symlink to the store, so resolve it.
     $storePath = (`$binDir/nix-store --query --resolve '$storePath'`
@@ -54,7 +62,7 @@ while (@ARGV) {
 
 
 # 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 = ();
 while (<READ>) {
     chomp;
@@ -68,6 +76,6 @@ close READ or die;
 if (scalar @missing > 0) {
     my $extraOpts = "";
     $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: $?";
 }
-- 
cgit 1.4.1