From 6fcdbcac202e40e5de7147ff64b34d6aaad16249 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 10 Oct 2011 21:11:08 +0000 Subject: * Install NixManifest.pm, NixConfig.pm and GeneratePatches.pm under the Nix:: namespace. --- scripts/Makefile.am | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'scripts/Makefile.am') diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 60bb0a9b8105..752fcd574025 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -3,20 +3,17 @@ bin_SCRIPTS = nix-collect-garbage \ nix-install-package nix-channel nix-build \ nix-copy-closure nix-generate-patches -noinst_SCRIPTS = nix-profile.sh GeneratePatches.pm \ +noinst_SCRIPTS = nix-profile.sh \ find-runtime-roots.pl build-remote.pl nix-reduce-build \ copy-from-other-stores.pl nix-http-export.cgi -nix-pull nix-push: NixManifest.pm NixConfig.pm download-using-manifests.pl +nix-pull nix-push: download-using-manifests.pl -install-exec-local: NixManifest.pm GeneratePatches.pm download-using-manifests.pl copy-from-other-stores.pl find-runtime-roots.pl +install-exec-local: download-using-manifests.pl copy-from-other-stores.pl find-runtime-roots.pl $(INSTALL) -d $(DESTDIR)$(sysconfdir)/profile.d $(INSTALL_PROGRAM) nix-profile.sh $(DESTDIR)$(sysconfdir)/profile.d/nix.sh $(INSTALL) -d $(DESTDIR)$(libexecdir)/nix - $(INSTALL_DATA) NixManifest.pm $(DESTDIR)$(libexecdir)/nix - $(INSTALL_DATA) NixConfig.pm $(DESTDIR)$(libexecdir)/nix $(INSTALL_DATA) SSH.pm $(DESTDIR)$(libexecdir)/nix - $(INSTALL_DATA) GeneratePatches.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 @@ -30,7 +27,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 \ - NixManifest.pm.in \ NixConfig.pm.in \ SSH.pm \ GeneratePatches.pm.in \ -- cgit 1.4.1 From cd6d02c366af43bccdd2ef345193e4fdeca78a13 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 10 Oct 2011 21:30:59 +0000 Subject: --- scripts/Makefile.am | 2 -- 1 file changed, 2 deletions(-) (limited to 'scripts/Makefile.am') diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 752fcd574025..42ed0158e9a9 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -27,9 +27,7 @@ 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 \ - NixConfig.pm.in \ SSH.pm \ - GeneratePatches.pm.in \ nix-build.in \ download-using-manifests.pl.in \ copy-from-other-stores.pl.in \ -- cgit 1.4.1 From 5090c34ee1251dd8f0a57332feff0c99489f7faa Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 10 Oct 2011 22:40:17 +0000 Subject: * Set the executable bit on scripts. --- scripts/Makefile.am | 3 +++ scripts/copy-from-other-stores.pl.in | 0 scripts/download-using-manifests.pl.in | 0 scripts/find-runtime-roots.pl.in | 0 scripts/nix-build.in | 0 scripts/nix-channel.in | 0 scripts/nix-collect-garbage.in | 0 scripts/nix-copy-closure.in | 0 scripts/nix-generate-patches.in | 0 scripts/nix-install-package.in | 0 scripts/nix-prefetch-url.in | 0 scripts/nix-pull.in | 0 scripts/nix-push.in | 0 scripts/nix-reduce-build.in | 0 14 files changed, 3 insertions(+) mode change 100644 => 100755 scripts/copy-from-other-stores.pl.in mode change 100644 => 100755 scripts/download-using-manifests.pl.in mode change 100644 => 100755 scripts/find-runtime-roots.pl.in mode change 100644 => 100755 scripts/nix-build.in mode change 100644 => 100755 scripts/nix-channel.in mode change 100644 => 100755 scripts/nix-collect-garbage.in mode change 100644 => 100755 scripts/nix-copy-closure.in mode change 100644 => 100755 scripts/nix-generate-patches.in mode change 100644 => 100755 scripts/nix-install-package.in mode change 100644 => 100755 scripts/nix-prefetch-url.in mode change 100644 => 100755 scripts/nix-pull.in mode change 100644 => 100755 scripts/nix-push.in mode change 100644 => 100755 scripts/nix-reduce-build.in (limited to 'scripts/Makefile.am') diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 42ed0158e9a9..5f80d351ac61 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -37,3 +37,6 @@ EXTRA_DIST = nix-collect-garbage.in \ nix-reduce-build.in \ nix-http-export.cgi.in \ nix-generate-patches.in + +clean: + rm -f $(bin_SCRIPTS) $(noinst_SCRIPTS) diff --git a/scripts/copy-from-other-stores.pl.in b/scripts/copy-from-other-stores.pl.in old mode 100644 new mode 100755 diff --git a/scripts/download-using-manifests.pl.in b/scripts/download-using-manifests.pl.in old mode 100644 new mode 100755 diff --git a/scripts/find-runtime-roots.pl.in b/scripts/find-runtime-roots.pl.in old mode 100644 new mode 100755 diff --git a/scripts/nix-build.in b/scripts/nix-build.in old mode 100644 new mode 100755 diff --git a/scripts/nix-channel.in b/scripts/nix-channel.in old mode 100644 new mode 100755 diff --git a/scripts/nix-collect-garbage.in b/scripts/nix-collect-garbage.in old mode 100644 new mode 100755 diff --git a/scripts/nix-copy-closure.in b/scripts/nix-copy-closure.in old mode 100644 new mode 100755 diff --git a/scripts/nix-generate-patches.in b/scripts/nix-generate-patches.in old mode 100644 new mode 100755 diff --git a/scripts/nix-install-package.in b/scripts/nix-install-package.in old mode 100644 new mode 100755 diff --git a/scripts/nix-prefetch-url.in b/scripts/nix-prefetch-url.in old mode 100644 new mode 100755 diff --git a/scripts/nix-pull.in b/scripts/nix-pull.in old mode 100644 new mode 100755 diff --git a/scripts/nix-push.in b/scripts/nix-push.in old mode 100644 new mode 100755 diff --git a/scripts/nix-reduce-build.in b/scripts/nix-reduce-build.in old mode 100644 new mode 100755 -- cgit 1.4.1 From c362e4d718cb31e532a4e2d708d07a57bc3bdf55 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 11 Oct 2011 11:45:36 +0000 Subject: * Move SSH.pm. --- perl/Makefile.am | 2 +- perl/lib/Nix/SSH.pm | 52 +++++++++++++++++++++++++++++++++++++++++++++ scripts/Makefile.am | 2 -- scripts/SSH.pm | 52 --------------------------------------------- scripts/build-remote.pl.in | 4 ++-- scripts/nix-copy-closure.in | 11 +++++----- 6 files changed, 60 insertions(+), 63 deletions(-) create mode 100644 perl/lib/Nix/SSH.pm delete mode 100644 scripts/SSH.pm (limited to 'scripts/Makefile.am') diff --git a/perl/Makefile.am b/perl/Makefile.am index d41340af03eb..e6a5f9b5e71c 100644 --- a/perl/Makefile.am +++ b/perl/Makefile.am @@ -2,7 +2,7 @@ perlversion := $(shell perl -e 'use Config; print $$Config{version};') perlarchname := $(shell perl -e 'use Config; print $$Config{archname};') perllibdir = $(libdir)/perl5/site_perl/$(perlversion)/$(perlarchname) -PERL_MODULES = lib/Nix/Store.pm lib/Nix/Manifest.pm lib/Nix/GeneratePatches.pm lib/Nix/Config.pm.in +PERL_MODULES = lib/Nix/Store.pm lib/Nix/Manifest.pm lib/Nix/GeneratePatches.pm lib/Nix/SSH.pm lib/Nix/Config.pm.in all: $(PERL_MODULES:.in=) diff --git a/perl/lib/Nix/SSH.pm b/perl/lib/Nix/SSH.pm new file mode 100644 index 000000000000..68f4a628b072 --- /dev/null +++ b/perl/lib/Nix/SSH.pm @@ -0,0 +1,52 @@ +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 () { + 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; diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 5f80d351ac61..a5703760d1f7 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -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 \ diff --git a/scripts/SSH.pm b/scripts/SSH.pm deleted file mode 100644 index 68f4a628b072..000000000000 --- a/scripts/SSH.pm +++ /dev/null @@ -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 () { - 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; diff --git a/scripts/build-remote.pl.in b/scripts/build-remote.pl.in index e943b0d9e304..e8c76086dae2 100755 --- a/scripts/build-remote.pl.in +++ b/scripts/build-remote.pl.in @@ -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'); diff --git a/scripts/nix-copy-closure.in b/scripts/nix-copy-closure.in index c037f003f0d0..966f860d0b51 100755 --- a/scripts/nix-copy-closure.in +++ b/scripts/nix-copy-closure.in @@ -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 () { 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: $?"; } -- cgit 1.4.1