2003-07-14 10:45:04 +00:00
|
|
|
#! /usr/bin/perl -w
|
|
|
|
|
|
|
|
my $linkdir = "@localstatedir@/nix/links";
|
|
|
|
my $storedir = "@prefix@/store";
|
|
|
|
|
|
|
|
my %alive;
|
|
|
|
|
2003-07-29 14:28:17 +00:00
|
|
|
my $keepsuccessors = 0;
|
|
|
|
my $invert = 0;
|
|
|
|
|
|
|
|
foreach my $arg (@ARGV) {
|
|
|
|
if ($arg eq "--keep-successors") { $keepsuccessors = 1; }
|
2003-07-29 14:42:14 +00:00
|
|
|
elsif ($arg eq "--invert") { $invert = 1; }
|
2003-07-29 14:28:17 +00:00
|
|
|
else { die "unknown argument `$arg'" };
|
|
|
|
}
|
|
|
|
|
|
|
|
my $extraarg = "";
|
|
|
|
if ($keepsuccessors) { $extraarg = "--include-successors"; };
|
|
|
|
open HASHES, "nix --query --requisites $extraarg \$(cat $linkdir/*.id) |" or die "in `nix -qrh'";
|
2003-07-14 10:45:04 +00:00
|
|
|
while (<HASHES>) {
|
|
|
|
chomp;
|
|
|
|
$alive{$_} = 1;
|
2003-07-29 14:28:17 +00:00
|
|
|
if ($invert) { print "$_\n"; };
|
2003-07-14 10:45:04 +00:00
|
|
|
}
|
|
|
|
close HASHES;
|
|
|
|
|
2003-07-29 14:28:17 +00:00
|
|
|
exit 0 if ($invert);
|
|
|
|
|
2003-07-14 10:45:04 +00:00
|
|
|
opendir(DIR, $storedir) or die "cannot opendir $storedir: $!";
|
|
|
|
my @names = readdir(DIR);
|
|
|
|
closedir DIR;
|
|
|
|
|
|
|
|
foreach my $name (@names) {
|
|
|
|
next if ($name eq "." || $name eq "..");
|
|
|
|
$name = "$storedir/$name";
|
|
|
|
if (!$alive{$name}) {
|
|
|
|
print "$name\n";
|
|
|
|
}
|
|
|
|
}
|