about summary refs log tree commit diff
path: root/scripts/maintenance/gc-releases.pl
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-02-22T14·35+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-02-22T14·35+0000
commit43fa1c20e7e98819925b16d60d6b7c9e87c93fca (patch)
tree7c98a6b3fe73b02b10531adff0dc38acec505fe7 /scripts/maintenance/gc-releases.pl
parent928cce592279615fbe7b29fc0f47bb2506297116 (diff)
* Separate the cache reading code.
Diffstat (limited to 'scripts/maintenance/gc-releases.pl')
-rwxr-xr-xscripts/maintenance/gc-releases.pl32
1 files changed, 7 insertions, 25 deletions
diff --git a/scripts/maintenance/gc-releases.pl b/scripts/maintenance/gc-releases.pl
index 9c81a68e835b..67654835afc1 100755
--- a/scripts/maintenance/gc-releases.pl
+++ b/scripts/maintenance/gc-releases.pl
@@ -1,29 +1,11 @@
-#! /usr/bin/perl -w -I.
+#! /usr/bin/perl -w -I. -I..
 
 use strict;
 use readmanifest;
+use readcache;
 
 
-# Read the archive directories.
-my @archives = ();
-my %archives;
-
-sub readDir {
-    my $dir = shift;
-    opendir(DIR, "$dir") or die "cannot open `$dir': $!";
-    my @as = readdir DIR;
-    foreach my $archive (@as) {
-        push @archives, $archive;
-        $archives{$archive} = "$dir/$archive";
-    }
-    closedir DIR;
-}
-
-readDir "/data/webserver/dist/nix-cache";
-readDir "/data/webserver/dist/test";
-readDir "/data/webserver/dist/patches";
-
-print STDERR scalar @archives, "\n";
+print STDERR scalar (keys %readcache::archives), "\n";
 
 
 # Read the manifests.
@@ -50,7 +32,7 @@ foreach my $narFile (keys %narFiles) {
 #        print $basename, "\n";
         $usedFiles{$basename} = 1;
         print STDERR "missing archive `$basename'\n"
-            unless defined $archives{$basename};
+            unless defined $readcache::archives{$basename};
     }
 }
 
@@ -62,15 +44,15 @@ foreach my $patch (keys %patches) {
 #        print $basename, "\n";
         $usedFiles{$basename} = 1;
         die "missing archive `$basename'"
-            unless defined $archives{$basename};
+            unless defined $readcache::archives{$basename};
     }
 }
 
 
 # Print out the dead archives.
-foreach my $archive (@archives) {
+foreach my $archive (keys %readcache::archives) {
     next if $archive eq "." || $archive eq "..";
     if (!defined $usedFiles{$archive}) {
-        print $archives{$archive}, "\n";
+        print $readcache::archives{$archive}, "\n";
     }
 }