forked from lix-project/lix
* Changed nix-pull to match nix-push.
This commit is contained in:
parent
c7bdb76fe4
commit
d84931ee56
|
@ -5,7 +5,7 @@ my $storedir = "@prefix@/store";
|
||||||
|
|
||||||
my %alive;
|
my %alive;
|
||||||
|
|
||||||
open HASHES, "nix -qrh \$(cat $linkdir/*.hash) |" or die "in `nix -qrh'";
|
open HASHES, "nix --query --refs \$(cat $linkdir/*.hash) |" or die "in `nix -qrh'";
|
||||||
while (<HASHES>) {
|
while (<HASHES>) {
|
||||||
chomp;
|
chomp;
|
||||||
$alive{$_} = 1;
|
$alive{$_} = 1;
|
||||||
|
|
|
@ -28,21 +28,22 @@ while (<CONFFILE>) {
|
||||||
my $fn = $1;
|
my $fn = $1;
|
||||||
next if $fn =~ /\.\./;
|
next if $fn =~ /\.\./;
|
||||||
next if $fn =~ /\//;
|
next if $fn =~ /\//;
|
||||||
next unless $fn =~ /-([0-9a-z]{32})(-s-([0-9a-z]{32}))?\.nar.bz2$/;
|
next unless $fn =~ /^([0-9a-z]{32})-([0-9a-z]{32})(-s-([0-9a-z]{32}))?.*\.nar\.bz2$/;
|
||||||
my $hash = $1;
|
my $hash = $1;
|
||||||
my $fshash = $3;
|
my $id = $2;
|
||||||
|
my $fsid = $4;
|
||||||
|
|
||||||
print "registering $hash -> $url/$fn\n";
|
print "registering $id -> $url/$fn\n";
|
||||||
|
|
||||||
# Construct a Fix expression that fetches and unpacks a
|
# Construct a Fix expression that fetches and unpacks a
|
||||||
# Nix archive from the network.
|
# Nix archive from the network.
|
||||||
my $fetch =
|
my $fetch =
|
||||||
"App(IncludeFix(\"fetchurl/fetchurl.fix\"), " .
|
"App(IncludeFix(\"fetchurl/fetchurl.fix\"), " .
|
||||||
"[(\"url\", \"$url/$fn\"), (\"md5\", \"ignore\")])";
|
"[(\"url\", \"$url/$fn\"), (\"md5\", \"$hash\")])";
|
||||||
my $fixexpr =
|
my $fixexpr =
|
||||||
"App(IncludeFix(\"nar/unnar.fix\"), " .
|
"App(IncludeFix(\"nar/unnar.fix\"), " .
|
||||||
"[ (\"nar\", $fetch)" .
|
"[ (\"nar\", $fetch)" .
|
||||||
", (\"name\", \"fetched-$hash\")" .
|
", (\"name\", \"fetched-$id\")" .
|
||||||
"])";
|
"])";
|
||||||
|
|
||||||
my $fixfile = "/tmp/nix-pull-tmp.fix";
|
my $fixfile = "/tmp/nix-pull-tmp.fix";
|
||||||
|
@ -51,19 +52,19 @@ while (<CONFFILE>) {
|
||||||
close FIX;
|
close FIX;
|
||||||
|
|
||||||
# Instantiate a Nix expression from the Fix expression.
|
# Instantiate a Nix expression from the Fix expression.
|
||||||
my $nhash = `fix $fixfile`;
|
my $nid = `fix $fixfile`;
|
||||||
$? and die "instantiating Nix archive expression";
|
$? and die "instantiating Nix archive expression";
|
||||||
chomp $nhash;
|
chomp $nid;
|
||||||
die unless $nhash =~ /^([0-9a-z]{32})$/;
|
die unless $nid =~ /^([0-9a-z]{32})$/;
|
||||||
|
|
||||||
push @subs, $hash;
|
push @subs, $id;
|
||||||
push @subs, $nhash;
|
push @subs, $nid;
|
||||||
|
|
||||||
# Does the name encode a successor relation?
|
# Does the name encode a successor relation?
|
||||||
if (defined $fshash) {
|
if (defined $fsid) {
|
||||||
print "NORMAL $fshash -> $hash\n";
|
print "NORMAL $fsid -> $id\n";
|
||||||
push @sucs, $fshash;
|
push @sucs, $fsid;
|
||||||
push @sucs, $hash;
|
push @sucs, $id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue