diff --git a/scripts/maintenance/gc-commands b/scripts/maintenance/gc-commands index 26459c738..3d548da19 100644 --- a/scripts/maintenance/gc-commands +++ b/scripts/maintenance/gc-commands @@ -1,2 +1,2 @@ -./gc-releases.pl /data/webserver/dist/*/*/MANIFEST > dead -cat dead | xargs mv --target-directory=/data/webserver/trash/ +./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 index 80b2726c5..b1e41a97c 100755 --- a/scripts/maintenance/gc-releases.pl +++ b/scripts/maintenance/gc-releases.pl @@ -1,8 +1,9 @@ -#! /usr/bin/perl -w -I. -I.. +#! /var/run/current-system/sw/bin/perl -w -I. -I.. use strict; -use readmanifest; +use NixManifest; use readcache; +use File::Basename; # Read the manifests. @@ -49,6 +50,9 @@ foreach my $patch (keys %patches) { foreach my $archive (keys %readcache::archives) { next if $archive eq "." || $archive eq ".."; if (!defined $usedFiles{$archive}) { - print $readcache::archives{$archive}, "\n"; + 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 index f6beeeeb4..9addf02aa 100644 --- a/scripts/maintenance/readcache.pm +++ b/scripts/maintenance/readcache.pm @@ -9,13 +9,13 @@ sub readDir { 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/webserver/dist/nix-cache"; -readDir "/data/webserver/dist/test-cache"; -readDir "/data/webserver/dist/patches"; +readDir "/data/releases/nars"; +readDir "/data/releases/patches"; print STDERR scalar (keys %archives), "\n";