* Move SSH.pm.
This commit is contained in:
		
							parent
							
								
									7d314b8c95
								
							
						
					
					
						commit
						c362e4d718
					
				
					 5 changed files with 8 additions and 11 deletions
				
			
		|  | @ -13,7 +13,6 @@ install-exec-local: download-using-manifests.pl copy-from-other-stores.pl find-r | |||
| 	$(INSTALL) -d $(DESTDIR)$(sysconfdir)/profile.d | ||||
| 	$(INSTALL_PROGRAM) nix-profile.sh $(DESTDIR)$(sysconfdir)/profile.d/nix.sh | ||||
| 	$(INSTALL) -d $(DESTDIR)$(libexecdir)/nix | ||||
| 	$(INSTALL_DATA) SSH.pm $(DESTDIR)$(libexecdir)/nix  | ||||
| 	$(INSTALL_PROGRAM) find-runtime-roots.pl $(DESTDIR)$(libexecdir)/nix  | ||||
| 	$(INSTALL_PROGRAM) build-remote.pl $(DESTDIR)$(libexecdir)/nix  | ||||
| 	$(INSTALL) -d $(DESTDIR)$(libexecdir)/nix/substituters | ||||
|  | @ -27,7 +26,6 @@ EXTRA_DIST = nix-collect-garbage.in \ | |||
|   nix-pull.in nix-push.in nix-profile.sh.in \ | ||||
|   nix-prefetch-url.in nix-install-package.in \ | ||||
|   nix-channel.in \ | ||||
|   SSH.pm \ | ||||
|   nix-build.in \ | ||||
|   download-using-manifests.pl.in \ | ||||
|   copy-from-other-stores.pl.in \ | ||||
|  |  | |||
|  | @ -1,52 +0,0 @@ | |||
| use strict; | ||||
| use File::Temp qw(tempdir); | ||||
| 
 | ||||
| our @sshOpts = split ' ', ($ENV{"NIX_SSHOPTS"} or ""); | ||||
| 
 | ||||
| push @sshOpts, "-x"; | ||||
| 
 | ||||
| my $sshStarted = 0; | ||||
| my $sshHost; | ||||
| 
 | ||||
| # Open a master SSH connection to `host', unless there already is a | ||||
| # running master connection (as determined by `-O check'). | ||||
| sub openSSHConnection { | ||||
|     my ($host) = @_; | ||||
|     die if $sshStarted; | ||||
|     $sshHost = $host; | ||||
|     return 1 if system("ssh $sshHost @sshOpts -O check 2> /dev/null") == 0; | ||||
| 
 | ||||
|     my $tmpDir = tempdir("nix-ssh.XXXXXX", CLEANUP => 1, TMPDIR => 1) | ||||
|         or die "cannot create a temporary directory"; | ||||
|      | ||||
|     push @sshOpts, "-S", "$tmpDir/control"; | ||||
| 
 | ||||
|     # Start the master.  We can't use the `-f' flag (fork into | ||||
|     # background after establishing the connection) because then the | ||||
|     # child continues to run if we are killed.  So instead make SSH | ||||
|     # print "started" when it has established the connection, and wait | ||||
|     # until we see that. | ||||
|     open SSHPIPE, "ssh $sshHost @sshOpts -M -N -o LocalCommand='echo started' -o PermitLocalCommand=yes |" or die; | ||||
| 
 | ||||
|     while (<SSHPIPE>) { | ||||
|         chomp; | ||||
|         if ($_ eq "started") { | ||||
|             $sshStarted = 1; | ||||
|             return 1; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     return 0; | ||||
| } | ||||
| 
 | ||||
| # Tell the master SSH client to exit. | ||||
| sub closeSSHConnection { | ||||
|     if ($sshStarted) { | ||||
|         system("ssh $sshHost @sshOpts -O exit 2> /dev/null") == 0 | ||||
|             or warn "unable to stop SSH master: $?"; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| END { my $saved = $?; closeSSHConnection; $? = $saved; } | ||||
| 
 | ||||
| return 1; | ||||
|  | @ -1,9 +1,9 @@ | |||
| #! @perl@ -w -I@libexecdir@/nix | ||||
| #! @perl@ -w @perlFlags@ | ||||
| 
 | ||||
| use Fcntl ':flock'; | ||||
| use English '-no_match_vars'; | ||||
| use IO::Handle; | ||||
| use SSH qw/sshOpts openSSHConnection/; | ||||
| use Nix::SSH qw/sshOpts openSSHConnection/; | ||||
| no warnings('once'); | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,8 +1,7 @@ | |||
| #! @perl@ -w -I@libexecdir@/nix | ||||
| #! @perl@ -w @perlFlags@ | ||||
| 
 | ||||
| use SSH; | ||||
| 
 | ||||
| my $binDir = $ENV{"NIX_BIN_DIR"} || "@bindir@"; | ||||
| use Nix::SSH; | ||||
| use Nix::Config; | ||||
| 
 | ||||
| 
 | ||||
| if (scalar @ARGV < 1) { | ||||
|  | @ -61,7 +60,7 @@ if ($toMode) { # Copy TO the remote machine. | |||
|     my @allStorePaths; | ||||
| 
 | ||||
|     # Get the closure of this path. | ||||
|     my $pid = open(READ, "set -f; $binDir/nix-store --query --requisites @storePaths|") or die; | ||||
|     my $pid = open(READ, "set -f; $Nix::Config::binDir/nix-store --query --requisites @storePaths|") or die; | ||||
|      | ||||
|     while (<READ>) { | ||||
|         chomp; | ||||
|  | @ -130,7 +129,7 @@ else { # Copy FROM the remote machine. | |||
|         print STDERR "  $_\n" foreach @missing; | ||||
|         my $extraOpts = ""; | ||||
|         $extraOpts .= "--sign" if $sign == 1; | ||||
|         system("set -f; ssh $sshHost @sshOpts 'nix-store --export $extraOpts @missing $compressor' | $decompressor @bindir@/nix-store --import") == 0 | ||||
|         system("set -f; ssh $sshHost @sshOpts 'nix-store --export $extraOpts @missing $compressor' | $decompressor $Nix::Config::binDir/nix-store --import") == 0 | ||||
|             or die "copying store paths from remote machine `$sshHost' failed: $?"; | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue