at 18.09-beta 68 lines 1.8 kB view raw
1# NOTE: this script is deprecated. Use closureInfo instead. 2 3# Parses a /nix/store/*-closure file and prints 4# various information. 5# By default, the nodes in the graph are printed to stdout. 6# If printRegistration is set, then the graph is written 7# as a registration file for a manifest is written 8# in the `nix-store --load-db' format. 9 10use strict; 11use File::Basename; 12 13my %storePaths; 14my %refs; 15 16# Each argument on the command line is a graph file. 17# The graph file contains line-triples and a variable 18# number of references: 19# <store-path> 20# <deriver> 21# <count> 22# <ref-#1> 23# ... 24# <ref-#count> 25foreach my $graph (@ARGV) { 26 open GRAPH, "<$graph" or die; 27 28 while (<GRAPH>) { 29 chomp; 30 my $storePath = "$_"; 31 $storePaths{$storePath} = 1; 32 33 my $deriver = <GRAPH>; chomp $deriver; 34 my $count = <GRAPH>; chomp $count; 35 36 my @refs = (); 37 for (my $i = 0; $i < $count; ++$i) { 38 my $ref = <GRAPH>; chomp $ref; 39 push @refs, $ref; 40 } 41 $refs{$storePath} = \@refs; 42 43 } 44 45 close GRAPH; 46} 47 48 49if ($ENV{"printRegistration"} eq "1") { 50 # This is the format used by `nix-store --register-validity 51 # --hash-given' / `nix-store --load-db'. 52 foreach my $storePath (sort (keys %storePaths)) { 53 print "$storePath\n"; 54 print "0000000000000000000000000000000000000000000000000000000000000000\n"; # !!! fix 55 print "0\n"; # !!! fix 56 print "\n"; # don't care about preserving the deriver 57 print scalar(@{$refs{$storePath}}), "\n"; 58 foreach my $ref (@{$refs{$storePath}}) { 59 print "$ref\n"; 60 } 61 } 62} 63 64else { 65 foreach my $storePath (sort (keys %storePaths)) { 66 print "$storePath\n"; 67 } 68}