about summary refs log tree commit diff
path: root/scripts
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2003-11-22T15·58+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2003-11-22T15·58+0000
commit40d9eb14dfb842c51e9f86818b43ae7711e1a5d6 (patch)
treebf7f5cbee76a95e72682c5f65baecad4d6173ce0 /scripts
parent7a02d954186d6ba1ea41d9917d63f9fab84736b3 (diff)
* Fix the garbage collector.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/nix-collect-garbage.in21
1 files changed, 18 insertions, 3 deletions
diff --git a/scripts/nix-collect-garbage.in b/scripts/nix-collect-garbage.in
index 9b471d896e60..d0552fd2f6e0 100755
--- a/scripts/nix-collect-garbage.in
+++ b/scripts/nix-collect-garbage.in
@@ -17,9 +17,24 @@ foreach my $arg (@ARGV) {
     else { die "unknown argument `$arg'" };
 }
 
+opendir(DIR, $linkdir) or die "cannot open directory $linkdir: $!";
+my @links = readdir DIR or die "cannot read directory $linkdir: $!";
+closedir DIR;
+
+my @roots;
+foreach my $link (@links) {
+    $link = $linkdir . "/" . $link;
+    next if (!($link =~ /.id$/));
+    open ROOT, "<$link" or die "cannot open $link: $!";
+    my $root = <ROOT>;
+    chomp $root;
+    close ROOT;
+    push @roots, $root;
+}
+
 my $extraarg = "";
 if ($keepsuccessors) { $extraarg = "--include-successors"; };
-my $pid = open2(\*READ, \*WRITE, "nix --query --requisites $extraarg \$(cat $linkdir/*.id)") 
+my $pid = open2(\*READ, \*WRITE, "nix-store --query --requisites $extraarg @roots") 
     or die "determining live paths";
 close WRITE;
 while (<READ>) {
@@ -34,8 +49,8 @@ $? == 0 or die "determining live paths";
 
 exit 0 if ($invert);
 
-opendir(DIR, $storedir) or die "cannot opendir $storedir: $!";
-my @names = readdir(DIR);
+opendir(DIR, $storedir) or die "cannot open directory $storedir: $!";
+my @names = readdir DIR;
 closedir DIR;
 
 foreach my $name (@names) {