[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
90/376: Implement nix-copy-closure --from via nix-store --serve
From: |
Ludovic Courtès |
Subject: |
90/376: Implement nix-copy-closure --from via nix-store --serve |
Date: |
Wed, 28 Jan 2015 22:04:14 +0000 |
civodul pushed a commit to tag 1.8
in repository guix.
commit 03103c0a36cc94238542de2bdf6eedcb679cca49
Author: Eelco Dolstra <address@hidden>
Date: Thu Jul 24 16:00:29 2014 +0200
Implement nix-copy-closure --from via nix-store --serve
---
scripts/build-remote.pl.in | 3 ++-
scripts/nix-copy-closure.in | 36 ++++++++----------------------------
src/nix-store/nix-store.cc | 13 ++++++++++++-
src/nix-store/serve-protocol.hh | 1 +
4 files changed, 23 insertions(+), 30 deletions(-)
diff --git a/scripts/build-remote.pl.in b/scripts/build-remote.pl.in
index 337374c..a55d758 100755
--- a/scripts/build-remote.pl.in
+++ b/scripts/build-remote.pl.in
@@ -272,7 +272,8 @@ if ($res != 0) {
# Copy the output from the build machine.
my @outputs2 = grep { !isValidPath($_) } @outputs;
if (scalar @outputs2 > 0) {
- writeInt(5, $to) or die; # == cmdExportPaths
+ writeInt(5, $to); # == cmdExportPaths
+ writeInt(0, $to); # don't sign
writeStrings(address@hidden, $to);
$ENV{'NIX_HELD_LOCKS'} = "@outputs2"; # FIXME: ugly
importPaths(fileno($from));
diff --git a/scripts/nix-copy-closure.in b/scripts/nix-copy-closure.in
index 05faa63..3dde6e1 100755
--- a/scripts/nix-copy-closure.in
+++ b/scripts/nix-copy-closure.in
@@ -89,42 +89,22 @@ if ($toMode) { # Copy TO the remote machine.
else { # Copy FROM the remote machine.
- openSSHConnection $sshHost or die "$0: unable to start SSH\n";
+ my ($from, $to) = connectToRemoteNix($sshHost, [ @sshOpts ]);
# Query the closure of the given store paths on the remote
# machine. Paths are assumed to be store paths; there is no
# resolution (following of symlinks).
- my $extraOpts = $includeOutputs ? "--include-outputs" : "";
- my $pid = open(READ,
- "set -f; ssh @sshOpts $sshHost nix-store --query --requisites
$extraOpts @storePaths|") or die;
-
- while (<READ>) {
- chomp;
- die "bad: $_" unless /^\//;
- push @missing, $_ unless isValidPath($_);
- }
-
- close READ or die "nix-store on remote machine `$sshHost' failed: $?";
-
- my $missingSize = 0;
- if ($progressViewer ne "") {
- $missingSize = sum (split ' ', `set -f; ssh @sshOpts $sshHost
nix-store -q --size @missing`) or die;
- }
+ syswrite($to, pack("L<x4L<x4", 7, $includeOutputs ? 1 : 0)) or die;
+ writeStrings(address@hidden, $to);
+ my @missing = grep { !isValidPath($_) } readStrings($from);
# Export the store paths on the remote machine and import them locally.
if (scalar @missing > 0) {
print STDERR "copying ", scalar @missing, " missing paths from
‘$sshHost’...\n";
- unless ($dryRun) {
- if ($useSubstitutes) {
- system "$Nix::Config::binDir/nix-store -r --ignore-unknown
@missing";
- }
- $compressor = "| $compressor" if $compressor ne "";
- $decompressor = "$decompressor |" if $decompressor ne "";
- $progressViewer = "$progressViewer -s $missingSize |" if
$progressViewer ne "";
- my $extraOpts = $sign ? "--sign" : "";
- system("set -f; ssh $sshHost @sshOpts 'nix-store --export
$extraOpts @missing $compressor' | $decompressor $progressViewer
$Nix::Config::binDir/nix-store --import > /dev/null") == 0
- or die "copying store paths from remote machine `$sshHost'
failed: $?";
- }
+ writeInt(5, $to); # == cmdExportPaths
+ writeInt($sign ? 1 : 0, $to);
+ writeStrings(address@hidden, $to);
+ importPaths(fileno($from));
}
}
diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc
index f874ffe..f2621a9 100644
--- a/src/nix-store/nix-store.cc
+++ b/src/nix-store/nix-store.cc
@@ -993,9 +993,10 @@ static void opServe(Strings opFlags, Strings opArgs)
}
case cmdExportPaths: {
+ bool sign = readInt(in);
Paths sorted = topoSortPaths(*store,
readStorePaths<PathSet>(in));
reverse(sorted.begin(), sorted.end());
- exportPaths(*store, sorted, false, out);
+ exportPaths(*store, sorted, sign, out);
break;
}
@@ -1025,6 +1026,16 @@ static void opServe(Strings opFlags, Strings opArgs)
break;
}
+ case cmdQueryClosure: {
+ bool includeOutputs = readInt(in);
+ PathSet paths = readStorePaths<PathSet>(in);
+ PathSet closure;
+ for (auto & i : paths)
+ computeFSClosure(*store, i, closure, false,
includeOutputs);
+ writeStrings(closure, out);
+ break;
+ }
+
default:
throw Error(format("unknown serve command %1%") % cmd);
}
diff --git a/src/nix-store/serve-protocol.hh b/src/nix-store/serve-protocol.hh
index eb13b46..741b622 100644
--- a/src/nix-store/serve-protocol.hh
+++ b/src/nix-store/serve-protocol.hh
@@ -16,6 +16,7 @@ typedef enum {
cmdImportPaths = 4,
cmdExportPaths = 5,
cmdBuildPaths = 6,
+ cmdQueryClosure = 7,
} ServeCommand;
}
- 87/376: tests/remote-builds.nix: Test failing build, (continued)
- 87/376: tests/remote-builds.nix: Test failing build, Ludovic Courtès, 2015/01/28
- 89/376: build-remote.pl: Be less verbose on failing builds, Ludovic Courtès, 2015/01/28
- 86/376: nix-store --serve: Only monitor stdin during builds, Ludovic Courtès, 2015/01/28
- 77/376: nix-daemon: Less verbosity, Ludovic Courtès, 2015/01/28
- 74/376: nix-daemon: Use a thread instead of SIGPOLL to catch client disconnects, Ludovic Courtès, 2015/01/28
- 99/376: install-nix-from-closure.sh: Install cacert, Ludovic Courtès, 2015/01/28
- 93/376: nix-copy-closure: Implement --gzip via ssh's -C flag, Ludovic Courtès, 2015/01/28
- 91/376: Remove obsolete SSH master connection code, Ludovic Courtès, 2015/01/28
- 100/376: Rename nixPath to __nixPath, Ludovic Courtès, 2015/01/28
- 95/376: Change the default for use-ssh-substituter to ‘true’, Ludovic Courtès, 2015/01/28
- 90/376: Implement nix-copy-closure --from via nix-store --serve,
Ludovic Courtès <=
- 97/376: Remove outdated AUTHORS file, Ludovic Courtès, 2015/01/28
- 92/376: Fix NIX_SSHOPTS, Ludovic Courtès, 2015/01/28
- 103/376: Allow regular files as GC roots, Ludovic Courtès, 2015/01/28
- 94/376: nix-copy-closure: Drop --bzip2, --xz, --show-progress, Ludovic Courtès, 2015/01/28
- 84/376: Use pthread_cancel instead of a signal, Ludovic Courtès, 2015/01/28
- 102/376: Restore default SIGPIPE handler before invoking ‘man’, Ludovic Courtès, 2015/01/28
- 98/376: nix-profile.sh: Set $SSL_CERT_FILE, Ludovic Courtès, 2015/01/28
- 96/376: nix-daemon: Pass on the user's $SSH_AUTH_SOCK to the SSH substituter, Ludovic Courtès, 2015/01/28
- 101/376: make clean: Remove Makefile.config, Ludovic Courtès, 2015/01/28
- 105/376: findRoots(): Prevent a call to lstat(), Ludovic Courtès, 2015/01/28