diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-08-05 11:14:24 +0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-08-05 11:14:24 +0000 |
commit | fd30f52cfca861d109652b6ad5a533e5c108f3e9 (patch) | |
tree | 259df4ca17365b21cc5f0f09c72e85c7cdd50986 /scripts/nix-pull.in | |
parent | 17f05dba775bb95858d9ac60ab9a9abcbe88b2fc (diff) | |
download | guix-fd30f52cfca861d109652b6ad5a533e5c108f3e9.tar.gz |
* Made nix-pull much faster by performing all Fix instantiations at
the same time.
Diffstat (limited to 'scripts/nix-pull.in')
-rw-r--r-- | scripts/nix-pull.in | 46 |
1 files changed, 32 insertions, 14 deletions
diff --git a/scripts/nix-pull.in b/scripts/nix-pull.in index ff85ff9a69..1fc5d863a2 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 (<CONFFILE>) { @@ -41,7 +47,7 @@ while (<CONFFILE>) { $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 (<CONFFILE>) { ", (\"id\", \"$id\")" . "])"; - my $fixfile = "/tmp/nix-pull-tmp.fix"; - open FIX, ">$fixfile"; - 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})$/; + print FIX "," unless ($first); + $first = 0; + print FIX $fixexpr; - 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 (<CONFFILE>) { } +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 (<NIDS>) { + 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"; } |