From 0c4c8f7a9d09c497d95771c894a5cc3d4276609b Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 8 May 2012 15:43:54 -0400 Subject: [PATCH] Remove obsolete files (moved to release tree) --- scripts/maintenance/gc-commands | 2 - scripts/maintenance/gc-releases.pl | 58 -------------------- scripts/maintenance/readcache.pm | 21 ------- scripts/maintenance/shrink-manifest.pl | 76 -------------------------- 4 files changed, 157 deletions(-) delete mode 100644 scripts/maintenance/gc-commands delete mode 100755 scripts/maintenance/gc-releases.pl delete mode 100644 scripts/maintenance/readcache.pm delete mode 100755 scripts/maintenance/shrink-manifest.pl diff --git a/scripts/maintenance/gc-commands b/scripts/maintenance/gc-commands deleted file mode 100644 index 3d548da19..000000000 --- a/scripts/maintenance/gc-commands +++ /dev/null @@ -1,2 +0,0 @@ -./gc-releases.pl /data/releases/patches/all-patches $(find /data/releases -name MANIFEST) | sort > dead -cat dead | xargs -d '\n' sh -c 'find "$@" -mtime +100 -print' | xargs -d '\n' mv -v --target-directory=/data/releases/trash/ diff --git a/scripts/maintenance/gc-releases.pl b/scripts/maintenance/gc-releases.pl deleted file mode 100755 index b1e41a97c..000000000 --- a/scripts/maintenance/gc-releases.pl +++ /dev/null @@ -1,58 +0,0 @@ -#! /var/run/current-system/sw/bin/perl -w -I. -I.. - -use strict; -use NixManifest; -use readcache; -use File::Basename; - - -# Read the manifests. -my %narFiles; -my %patches; - -foreach my $manifest (@ARGV) { - print STDERR "loading $manifest\n"; - if (readManifest($manifest, \%narFiles, \%patches, 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 $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'" - unless defined $readcache::archives{$basename}; - } -} - - -# Print out the dead archives. -foreach my $archive (keys %readcache::archives) { - next if $archive eq "." || $archive eq ".."; - if (!defined $usedFiles{$archive}) { - my $file = $readcache::archives{$archive}; - print "$file\n"; - my $hashFile = dirname($file) . "/.hash." . basename($file); - print "$hashFile\n" if -e $hashFile; - } -} diff --git a/scripts/maintenance/readcache.pm b/scripts/maintenance/readcache.pm deleted file mode 100644 index 9addf02aa..000000000 --- a/scripts/maintenance/readcache.pm +++ /dev/null @@ -1,21 +0,0 @@ -package readcache; -use strict; - -# Read the archive directories. -our %archives; - -sub readDir { - my $dir = shift; - opendir(DIR, "$dir") or die "cannot open `$dir': $!"; - my @as = readdir DIR; - foreach my $archive (@as) { - next unless $archive =~ /^sha256_/ || $archive =~ /\.nar-bsdiff$/ || $archive =~ /\.nar\.bz2$/; - $archives{$archive} = "$dir/$archive"; - } - closedir DIR; -} - -readDir "/data/releases/nars"; -readDir "/data/releases/patches"; - -print STDERR scalar (keys %archives), "\n"; diff --git a/scripts/maintenance/shrink-manifest.pl b/scripts/maintenance/shrink-manifest.pl deleted file mode 100755 index 60cf9c5b4..000000000 --- a/scripts/maintenance/shrink-manifest.pl +++ /dev/null @@ -1,76 +0,0 @@ -#! /usr/bin/perl -w -I. -I.. - -use strict; -use readmanifest; -use readcache; - - -my %allNarFiles; -my %allLocalPaths; -my %allPatches; - -foreach my $manifest (glob "/data/webserver/dist/*/*/MANIFEST") { - print STDERR "loading $manifest\n"; - readManifest($manifest, \%allNarFiles, \%allLocalPaths, \%allPatches, 1); -} - - - -foreach my $manifest (@ARGV) { - - print STDERR "shrinking manifest $manifest...\n"; - - my %narFiles; - my %patches; - - if (readManifest($manifest, \%narFiles, \%patches, 1) < 3) { - print STDERR "manifest `$manifest' is too old (i.e., for Nix <= 0.7)\n"; - next; - } - - my %done; - - sub traverse { - my $p = shift; - my $prefix = shift; - print "$prefix$p\n"; - - my $reachesNAR = 0; - - foreach my $patch (@{$patches{$p}}) { - next if defined $done{$patch->{url}}; - $done{$patch->{url}} = 1; - $reachesNAR = 1 if traverse ($patch->{basePath}, $prefix . " "); - } - - $reachesNAR = 1 if defined $allNarFiles{$p}; - - print " $prefix$reachesNAR\n"; - return $reachesNAR; - } - -# foreach my $p (keys %narFiles) { -# traverse ($p, ""); -# } - - my %newPatches; - - foreach my $p (keys %patches) { - my $patchList = $patches{$p}; - my @newList; - foreach my $patch (@{$patchList}) { - if (! defined $allNarFiles{$patch->{basePath}} || - ! defined $allNarFiles{$p} ) - { -# print "REMOVING PATCH ", $patch->{basePath}, " -> ", $p, "\n"; - } else { -# print "KEEPING PATCH ", $patch->{basePath}, " -> ", $p, "\n"; - push @newList, $patch; - } - } - $newPatches{$p} = \@newList; - } - - writeManifest ($manifest, \%narFiles, \%newPatches); -} -