aboutsummaryrefslogtreecommitdiff
path: root/scripts/maintenance/shrink-manifest.pl
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-02-24 16:05:55 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-02-24 16:05:55 +0000
commite2f16b9cae0f9904daeb94ac0ecee1fd9ae2c9b1 (patch)
treeb3a58845c87fdfe5e332fa799136bab68a931394 /scripts/maintenance/shrink-manifest.pl
parent5168f9bb005aa0d25cb31fdd7aba1bac951b2251 (diff)
* A script to remove from a manifest those patches whose base or
target no longer applies to any available release. This is a partial fix for NIX-34 (when producing linear patch sequences between releases, the number of patches grows without bound).
Diffstat (limited to 'scripts/maintenance/shrink-manifest.pl')
-rwxr-xr-xscripts/maintenance/shrink-manifest.pl77
1 files changed, 77 insertions, 0 deletions
diff --git a/scripts/maintenance/shrink-manifest.pl b/scripts/maintenance/shrink-manifest.pl
new file mode 100755
index 000000000..9ceb4af90
--- /dev/null
+++ b/scripts/maintenance/shrink-manifest.pl
@@ -0,0 +1,77 @@
+#! /usr/bin/perl -w -I. -I..
+
+use strict;
+use readmanifest;
+use readcache;
+
+
+my %allNarFiles;
+my %allPatches;
+my %allSuccessors;
+
+foreach my $manifest (glob "/data/webserver/dist/*/*/MANIFEST") {
+ print STDERR "loading $manifest\n";
+ readManifest($manifest, \%allNarFiles, \%allPatches, \%allSuccessors, 1);
+}
+
+
+
+foreach my $manifest (@ARGV) {
+
+ print STDERR "shrinking manifest $manifest...\n";
+
+ my %narFiles;
+ my %patches;
+ my %successors;
+
+ if (readManifest($manifest, \%narFiles, \%patches, \%successors, 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);
+}
+