* Made nix-push much faster.

This commit is contained in:
Eelco Dolstra 2003-08-05 12:30:06 +00:00
parent 4ce652640b
commit b9c9b461ea
1 changed files with 35 additions and 20 deletions

View File

@ -1,6 +1,9 @@
#! /usr/bin/perl -w #! /usr/bin/perl -w
my @pushlist; my $fixfile = "/tmp/nix-push-tmp.fix";
open FIX, ">$fixfile";
print FIX "[";
my $first = 1;
foreach my $id (@ARGV) { foreach my $id (@ARGV) {
@ -35,6 +38,7 @@ foreach my $id (@ARGV) {
foreach my $path (@paths) { foreach my $path (@paths) {
next unless ($path =~ /\/([0-9a-z]{32})[^\/]*/); next unless ($path =~ /\/([0-9a-z]{32})[^\/]*/);
print "$path\n";
my $pathid = $1; my $pathid = $1;
# Construct a name for the Nix archive. If the file is an # Construct a name for the Nix archive. If the file is an
@ -51,28 +55,39 @@ foreach my $id (@ARGV) {
"[ (\"path\", Slice([\"$pathid\"], [(\"$path\", \"$pathid\", [])]))" . "[ (\"path\", Slice([\"$pathid\"], [(\"$path\", \"$pathid\", [])]))" .
"])"; "])";
my $fixfile = "/tmp/nix-push-tmp.fix"; print FIX "," unless ($first);
open FIX, ">$fixfile"; $first = 0;
print FIX $fixexpr; print FIX $fixexpr;
}
}
print FIX "]";
close FIX; close FIX;
# Instantiate a Nix expression from the Fix expression. # Instantiate a Nix expression from the Fix expression.
my $nid = `fix $fixfile`; my @nids;
$? and die "instantiating Nix archive expression"; print STDERR "running fix...\n";
chomp $nid; open NIDS, "fix $fixfile |" or die "cannot run fix";
die unless $nid =~ /^([0-9a-z]{32})$/; while (<NIDS>) {
chomp;
die unless /^([0-9a-z]{32})$/;
push @nids, $1;
}
# Realise the Nix expression. # Realise the Nix expression.
system "nix --install $nid"; my @pushlist;
print STDERR "creating archives...\n";
system "nix --install @nids > /dev/null";
if ($?) { die "`nix --install' failed"; } if ($?) { die "`nix --install' failed"; }
my $npath = `nix --query --list $nid 2> /dev/null`;
$? and die "`nix --query --list' failed";
chomp $npath;
push @pushlist, "$npath/*"; open NIDS, "nix --query --list @nids |" or die "cannot run nix";
while (<NIDS>) {
print "$path -> $npath\n"; chomp;
} die unless (/^\//);
print "$_\n";
push @pushlist, "$_/*";
} }
# Push the prebuilts to the server. !!! FIXME # Push the prebuilts to the server. !!! FIXME