* Get the garbage collector to work again.

This commit is contained in:
Eelco Dolstra 2003-07-14 10:45:04 +00:00
parent 3509299aca
commit 8898e86b4f
2 changed files with 25 additions and 22 deletions

View file

@ -1,22 +0,0 @@
#! /usr/bin/perl -w
my $prefix = $ENV{"NIX"} || "/nix"; # !!! use prefix
my $linkdir = "$prefix/var/nix/links";
my %alive;
open HASHES, "nix closure \$(cat $linkdir/*.hash) |";
while (<HASHES>) {
chomp;
$alive{$_} = 1;
}
close HASHES;
open HASHES, "nix listinst |";
while (<HASHES>) {
chomp;
if (!$alive{$_}) {
print "$_\n";
}
}
close HASHES;

25
scripts/nix-collect-garbage.in Executable file
View file

@ -0,0 +1,25 @@
#! /usr/bin/perl -w
my $linkdir = "@localstatedir@/nix/links";
my $storedir = "@prefix@/store";
my %alive;
open HASHES, "nix -qrh \$(cat $linkdir/*.hash) |" or die "in `nix -qrh'";
while (<HASHES>) {
chomp;
$alive{$_} = 1;
}
close HASHES;
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";
}
}