lix/scripts/maintenance/gc-releases.pl

56 lines
1.4 KiB
Perl
Raw Normal View History

2006-02-22 14:35:19 +00:00
#! /usr/bin/perl -w -I. -I..
use strict;
use readmanifest;
2006-02-22 14:35:19 +00:00
use readcache;
# Read the manifests.
my %narFiles;
my %patches;
my %successors;
foreach my $manifest (@ARGV) {
print STDERR "loading $manifest\n";
if (readManifest($manifest, \%narFiles, \%patches, \%successors, 1) < 3) {
# die "manifest `$manifest' is too old (i.e., for Nix <= 0.7)\n";
}
}
# Find the live archives.
my %usedFiles;
foreach my $narFile (keys %narFiles) {
foreach my $file (@{$narFiles{$narFile}}) {
$file->{url} =~ /\/([^\/]+)$/;
my $basename = $1;
die unless defined $basename;
# print $basename, "\n";
$usedFiles{$basename} = 1;
print STDERR "missing archive `$basename'\n"
2006-02-22 14:35:19 +00:00
unless defined $readcache::archives{$basename};
}
}
foreach my $patch (keys %patches) {
foreach my $file (@{$patches{$patch}}) {
$file->{url} =~ /\/([^\/]+)$/;
my $basename = $1;
die unless defined $basename;
# print $basename, "\n";
$usedFiles{$basename} = 1;
die "missing archive `$basename'"
2006-02-22 14:35:19 +00:00
unless defined $readcache::archives{$basename};
}
}
# Print out the dead archives.
2006-02-22 14:35:19 +00:00
foreach my $archive (keys %readcache::archives) {
next if $archive eq "." || $archive eq "..";
if (!defined $usedFiles{$archive}) {
2006-02-22 14:35:19 +00:00
print $readcache::archives{$archive}, "\n";
}
}