2018-02-08 12:56:54 +00:00
|
|
|
# NOTE: this script is deprecated. Use closureInfo instead.
|
|
|
|
|
2014-04-22 11:02:43 +00:00
|
|
|
# Parses a /nix/store/*-closure file and prints
|
|
|
|
# various information.
|
|
|
|
# By default, the nodes in the graph are printed to stdout.
|
|
|
|
# If printRegistration is set, then the graph is written
|
|
|
|
# as a registration file for a manifest is written
|
|
|
|
# in the `nix-store --load-db' format.
|
|
|
|
|
2008-03-17 10:40:47 +00:00
|
|
|
use strict;
|
|
|
|
use File::Basename;
|
|
|
|
|
|
|
|
my %storePaths;
|
|
|
|
my %refs;
|
|
|
|
|
2014-04-22 11:02:43 +00:00
|
|
|
# Each argument on the command line is a graph file.
|
|
|
|
# The graph file contains line-triples and a variable
|
|
|
|
# number of references:
|
|
|
|
# <store-path>
|
|
|
|
# <deriver>
|
|
|
|
# <count>
|
|
|
|
# <ref-#1>
|
|
|
|
# ...
|
|
|
|
# <ref-#count>
|
2008-03-17 10:40:47 +00:00
|
|
|
foreach my $graph (@ARGV) {
|
|
|
|
open GRAPH, "<$graph" or die;
|
|
|
|
|
|
|
|
while (<GRAPH>) {
|
|
|
|
chomp;
|
|
|
|
my $storePath = "$_";
|
|
|
|
$storePaths{$storePath} = 1;
|
|
|
|
|
|
|
|
my $deriver = <GRAPH>; chomp $deriver;
|
|
|
|
my $count = <GRAPH>; chomp $count;
|
|
|
|
|
|
|
|
my @refs = ();
|
|
|
|
for (my $i = 0; $i < $count; ++$i) {
|
|
|
|
my $ref = <GRAPH>; chomp $ref;
|
|
|
|
push @refs, $ref;
|
|
|
|
}
|
|
|
|
$refs{$storePath} = \@refs;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
close GRAPH;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-25 12:27:59 +00:00
|
|
|
if ($ENV{"printRegistration"} eq "1") {
|
2008-03-17 10:40:47 +00:00
|
|
|
# This is the format used by `nix-store --register-validity
|
|
|
|
# --hash-given' / `nix-store --load-db'.
|
|
|
|
foreach my $storePath (sort (keys %storePaths)) {
|
|
|
|
print "$storePath\n";
|
|
|
|
print "0000000000000000000000000000000000000000000000000000000000000000\n"; # !!! fix
|
2011-02-16 11:49:08 +00:00
|
|
|
print "0\n"; # !!! fix
|
2008-03-17 10:40:47 +00:00
|
|
|
print "\n"; # don't care about preserving the deriver
|
|
|
|
print scalar(@{$refs{$storePath}}), "\n";
|
|
|
|
foreach my $ref (@{$refs{$storePath}}) {
|
|
|
|
print "$ref\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
foreach my $storePath (sort (keys %storePaths)) {
|
|
|
|
print "$storePath\n";
|
|
|
|
}
|
|
|
|
}
|