From 928cce592279615fbe7b29fc0f47bb2506297116 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 22 Feb 2006 14:13:02 +0000 Subject: * Directory for nix.cs.uu.nl manifest / cache maintenance scripts. --- scripts/gc-releases.pl | 76 -------------------------------------- scripts/maintenance/gc-commands | 2 + scripts/maintenance/gc-releases.pl | 76 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 76 deletions(-) delete mode 100755 scripts/gc-releases.pl create mode 100644 scripts/maintenance/gc-commands create mode 100755 scripts/maintenance/gc-releases.pl (limited to 'scripts') diff --git a/scripts/gc-releases.pl b/scripts/gc-releases.pl deleted file mode 100755 index 9c81a68e835b..000000000000 --- a/scripts/gc-releases.pl +++ /dev/null @@ -1,76 +0,0 @@ -#! /usr/bin/perl -w -I. - -use strict; -use readmanifest; - - -# 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"; - - -# 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" - unless defined $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'" - unless defined $archives{$basename}; - } -} - - -# Print out the dead archives. -foreach my $archive (@archives) { - next if $archive eq "." || $archive eq ".."; - if (!defined $usedFiles{$archive}) { - print $archives{$archive}, "\n"; - } -} diff --git a/scripts/maintenance/gc-commands b/scripts/maintenance/gc-commands new file mode 100644 index 000000000000..26459c738e8c --- /dev/null +++ b/scripts/maintenance/gc-commands @@ -0,0 +1,2 @@ +./gc-releases.pl /data/webserver/dist/*/*/MANIFEST > dead +cat dead | xargs mv --target-directory=/data/webserver/trash/ diff --git a/scripts/maintenance/gc-releases.pl b/scripts/maintenance/gc-releases.pl new file mode 100755 index 000000000000..9c81a68e835b --- /dev/null +++ b/scripts/maintenance/gc-releases.pl @@ -0,0 +1,76 @@ +#! /usr/bin/perl -w -I. + +use strict; +use readmanifest; + + +# 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"; + + +# 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" + unless defined $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'" + unless defined $archives{$basename}; + } +} + + +# Print out the dead archives. +foreach my $archive (@archives) { + next if $archive eq "." || $archive eq ".."; + if (!defined $usedFiles{$archive}) { + print $archives{$archive}, "\n"; + } +} -- cgit 1.4.1