forked from lix-project/lix
* nix-copy-closure: option --sign.
* nix-copy-closure: set SSH options through NIX_SSHOPTS..
This commit is contained in:
parent
024a8ed382
commit
4c5e6d1a2f
|
@ -4,8 +4,20 @@ my $binDir = $ENV{"NIX_BIN_DIR"};
|
||||||
$binDir = "@bindir@" unless defined $binDir;
|
$binDir = "@bindir@" unless defined $binDir;
|
||||||
|
|
||||||
|
|
||||||
|
if (scalar @ARGV < 1) {
|
||||||
|
print STDERR <<EOF
|
||||||
|
Usage: nix-copy-closure HOSTNAME [--sign] PATHS...
|
||||||
|
EOF
|
||||||
|
;
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# Get the target host.
|
# Get the target host.
|
||||||
my $sshHost = shift @ARGV;
|
my $sshHost = shift @ARGV;
|
||||||
|
my @sshOpts = split ' ', $ENV{"NIX_SSHOPTS"};
|
||||||
|
|
||||||
|
my $sign = 0;
|
||||||
|
|
||||||
|
|
||||||
# !!! Copied from nix-pack-closure, should put this in a module.
|
# !!! Copied from nix-pack-closure, should put this in a module.
|
||||||
|
@ -14,6 +26,10 @@ my @storePaths = ();
|
||||||
|
|
||||||
while (@ARGV) {
|
while (@ARGV) {
|
||||||
my $storePath = shift @ARGV;
|
my $storePath = shift @ARGV;
|
||||||
|
if ($storePath eq "--sign") {
|
||||||
|
$sign = 1;
|
||||||
|
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'`
|
||||||
|
@ -38,7 +54,7 @@ while (@ARGV) {
|
||||||
|
|
||||||
|
|
||||||
# Ask the remote host which paths are invalid.
|
# Ask the remote host which paths are invalid.
|
||||||
open(READ, "-|", "ssh", $sshHost, "nix-store", "--check-validity", "--print-invalid", @storePaths);
|
open(READ, "-|", "ssh", @sshOpts, $sshHost, "nix-store", "--check-validity", "--print-invalid", @storePaths);
|
||||||
my @missing = ();
|
my @missing = ();
|
||||||
while (<READ>) {
|
while (<READ>) {
|
||||||
chomp;
|
chomp;
|
||||||
|
@ -50,6 +66,8 @@ close READ or die;
|
||||||
|
|
||||||
# Export the store paths and import them on the remote machine.
|
# Export the store paths and import them on the remote machine.
|
||||||
if (scalar @missing > 0) {
|
if (scalar @missing > 0) {
|
||||||
system("nix-store --export @missing | ssh $sshHost nix-store --import") == 0
|
my $extraOpts = "";
|
||||||
|
$extraOpts .= "--sign" if $sign == 1;
|
||||||
|
system("nix-store --export $extraOpts @missing | ssh @sshOpts $sshHost nix-store --import") == 0
|
||||||
or die "copying store paths to remote machine failed: $?";
|
or die "copying store paths to remote machine failed: $?";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue