forked from lix-project/lix
* Don't use a temporary file.
This commit is contained in:
parent
163db7367f
commit
01e30360d4
|
@ -1,5 +1,7 @@
|
||||||
#! /usr/bin/perl -w
|
#! /usr/bin/perl -w
|
||||||
|
|
||||||
|
use IPC::Open2;
|
||||||
|
|
||||||
my $tmpfile = "@localstatedir@/nix/pull.tmp";
|
my $tmpfile = "@localstatedir@/nix/pull.tmp";
|
||||||
my $conffile = "@sysconfdir@/nix/prebuilts.conf";
|
my $conffile = "@sysconfdir@/nix/prebuilts.conf";
|
||||||
|
|
||||||
|
@ -7,9 +9,7 @@ my @ids;
|
||||||
my @subs;
|
my @subs;
|
||||||
my @sucs;
|
my @sucs;
|
||||||
|
|
||||||
my $fixfile = "/tmp/nix-pull-tmp.fix";
|
my $fullexpr = "[";
|
||||||
open FIX, ">$fixfile";
|
|
||||||
print FIX "[";
|
|
||||||
my $first = 1;
|
my $first = 1;
|
||||||
|
|
||||||
open CONFFILE, "<$conffile";
|
open CONFFILE, "<$conffile";
|
||||||
|
@ -61,9 +61,9 @@ while (<CONFFILE>) {
|
||||||
", (\"id\", \"$id\")" .
|
", (\"id\", \"$id\")" .
|
||||||
"])";
|
"])";
|
||||||
|
|
||||||
print FIX "," unless ($first);
|
if (!$first) { $fullexpr .= "," };
|
||||||
$first = 0;
|
$first = 0;
|
||||||
print FIX $fixexpr;
|
$fullexpr .= $fixexpr; # !!! O(n^2)?
|
||||||
|
|
||||||
push @ids, $id;
|
push @ids, $id;
|
||||||
|
|
||||||
|
@ -81,14 +81,16 @@ while (<CONFFILE>) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
print FIX "]";
|
$fullexpr .= "]";
|
||||||
close FIX;
|
|
||||||
|
|
||||||
# Instantiate Nix expressions from the Fix expressions we created above.
|
# Instantiate Nix expressions from the Fix expressions we created above.
|
||||||
print STDERR "running fix...\n";
|
print STDERR "running fix...\n";
|
||||||
open NIDS, "fix $fixfile |" or die "cannot run fix";
|
$pid = open2(\*READ, \*WRITE, "fix -") or die "cannot run fix";
|
||||||
|
|
||||||
|
print WRITE $fullexpr;
|
||||||
|
close WRITE;
|
||||||
my $i = 0;
|
my $i = 0;
|
||||||
while (<NIDS>) {
|
while (<READ>) {
|
||||||
chomp;
|
chomp;
|
||||||
die unless /^([0-9a-z]{32})$/;
|
die unless /^([0-9a-z]{32})$/;
|
||||||
$nid = $1;
|
$nid = $1;
|
||||||
|
@ -98,6 +100,9 @@ while (<NIDS>) {
|
||||||
push @subs, $nid;
|
push @subs, $nid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
waitpid $pid, 0;
|
||||||
|
$? == 0 or die "fix failed";
|
||||||
|
|
||||||
# Register all substitutes.
|
# Register all substitutes.
|
||||||
print STDERR "registering substitutes...\n";
|
print STDERR "registering substitutes...\n";
|
||||||
system "nix --substitute @subs";
|
system "nix --substitute @subs";
|
||||||
|
|
Loading…
Reference in a new issue