From 8898e86b4fe1ecf8b34a5cca2a7b9b38d395678c Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 14 Jul 2003 10:45:04 +0000 Subject: [PATCH] * Get the garbage collector to work again. --- scripts/nix-collect-garbage | 22 ---------------------- scripts/nix-collect-garbage.in | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 22 deletions(-) delete mode 100755 scripts/nix-collect-garbage create mode 100755 scripts/nix-collect-garbage.in diff --git a/scripts/nix-collect-garbage b/scripts/nix-collect-garbage deleted file mode 100755 index adaba5b7c..000000000 --- a/scripts/nix-collect-garbage +++ /dev/null @@ -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 () { - chomp; - $alive{$_} = 1; -} -close HASHES; - -open HASHES, "nix listinst |"; -while () { - chomp; - if (!$alive{$_}) { - print "$_\n"; - } -} -close HASHES; diff --git a/scripts/nix-collect-garbage.in b/scripts/nix-collect-garbage.in new file mode 100755 index 000000000..1506416b2 --- /dev/null +++ b/scripts/nix-collect-garbage.in @@ -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 () { + 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"; + } +}