* Made nix-push much faster.

This commit is contained in:
Eelco Dolstra 2003-08-05 12:30:06 +00:00
parent 4ce652640b
commit b9c9b461ea

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,30 +55,41 @@ 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;
close FIX;
# Instantiate a Nix expression from the Fix expression.
my $nid = `fix $fixfile`;
$? and die "instantiating Nix archive expression";
chomp $nid;
die unless $nid =~ /^([0-9a-z]{32})$/;
# Realise the Nix expression.
system "nix --install $nid";
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/*";
print "$path -> $npath\n";
} }
} }
print FIX "]";
close FIX;
# Instantiate a Nix expression from the Fix expression.
my @nids;
print STDERR "running fix...\n";
open NIDS, "fix $fixfile |" or die "cannot run fix";
while (<NIDS>) {
chomp;
die unless /^([0-9a-z]{32})$/;
push @nids, $1;
}
# Realise the Nix expression.
my @pushlist;
print STDERR "creating archives...\n";
system "nix --install @nids > /dev/null";
if ($?) { die "`nix --install' failed"; }
open NIDS, "nix --query --list @nids |" or die "cannot run nix";
while (<NIDS>) {
chomp;
die unless (/^\//);
print "$_\n";
push @pushlist, "$_/*";
}
# Push the prebuilts to the server. !!! FIXME # Push the prebuilts to the server. !!! FIXME
if (scalar @pushlist > 0) { if (scalar @pushlist > 0) {
system "rsync -av -e ssh @pushlist eelco\@losser.st-lab.cs.uu.nl:/home/eelco/public_html/nix-dist/"; system "rsync -av -e ssh @pushlist eelco\@losser.st-lab.cs.uu.nl:/home/eelco/public_html/nix-dist/";