From fd30f52cfca861d109652b6ad5a533e5c108f3e9 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 5 Aug 2003 11:14:24 +0000 Subject: [PATCH] * Made nix-pull much faster by performing all Fix instantiations at the same time. --- scripts/nix-pull.in | 46 +++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/scripts/nix-pull.in b/scripts/nix-pull.in index ff85ff9a6..1fc5d863a 100644 --- a/scripts/nix-pull.in +++ b/scripts/nix-pull.in @@ -3,9 +3,15 @@ my $tmpfile = "@localstatedir@/nix/pull.tmp"; my $conffile = "@sysconfdir@/nix/prebuilts.conf"; +my @ids; my @subs; my @sucs; +my $fixfile = "/tmp/nix-pull-tmp.fix"; +open FIX, ">$fixfile"; +print FIX "["; +my $first = 1; + open CONFFILE, "<$conffile"; while () { @@ -41,7 +47,7 @@ while () { $outname = "unnamed"; } - print "registering $id -> $url/$fn\n"; + print STDERR "$id ($outname)\n"; # Construct a Fix expression that fetches and unpacks a # Nix archive from the network. @@ -55,23 +61,14 @@ while () { ", (\"id\", \"$id\")" . "])"; - my $fixfile = "/tmp/nix-pull-tmp.fix"; - open FIX, ">$fixfile"; - print FIX $fixexpr; - close FIX; + print FIX "," unless ($first); + $first = 0; + print FIX $fixexpr; - # 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})$/; - - push @subs, $id; - push @subs, $nid; + push @ids, $id; # Does the name encode a successor relation? if (defined $fsid) { - print "NORMAL $fsid -> $id\n"; push @sucs, $fsid; push @sucs, $id; } @@ -84,8 +81,29 @@ while () { } +print FIX "]"; +close FIX; + +# Instantiate Nix expressions from the Fix expressions we created above. +print STDERR "running fix...\n"; +open NIDS, "fix $fixfile |" or die "cannot run fix"; +my $i = 0; +while () { + chomp; + die unless /^([0-9a-z]{32})$/; + $nid = $1; + die unless ($i < scalar @ids); + $id = $ids[$i++]; + push @subs, $id; + push @subs, $nid; +} + +# Register all substitutes. +print STDERR "registering substitutes...\n"; system "nix --substitute @subs"; if ($?) { die "`nix --substitute' failed"; } +# Register all successors. +print STDERR "registering successors...\n"; system "nix --successor @sucs"; if ($?) { die "`nix --successor' failed"; }