diff options
author | intrigeri <intrigeri@boum.org> | 2016-05-06 16:38:18 +0000 |
---|---|---|
committer | intrigeri <intrigeri@boum.org> | 2016-05-06 16:41:00 +0000 |
commit | b9d38b62759d6a74d0bda4d84571eee92fe14610 (patch) | |
tree | dce9444864243fc050ed84c7aaeaefd18e6e71e1 /files/reprepro/snapshots | |
parent | e5ca904670cab3fe97433c73d9200cd536383173 (diff) |
Don't load the entire output of dumpreferences into memory.
It can get seriously big, so instead handle its output in stream mode.
Diffstat (limited to 'files/reprepro/snapshots')
-rwxr-xr-x | files/reprepro/snapshots/time_based/tails-delete-expired-apt-snapshots | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/files/reprepro/snapshots/time_based/tails-delete-expired-apt-snapshots b/files/reprepro/snapshots/time_based/tails-delete-expired-apt-snapshots index 99be045..4d88a70 100755 --- a/files/reprepro/snapshots/time_based/tails-delete-expired-apt-snapshots +++ b/files/reprepro/snapshots/time_based/tails-delete-expired-apt-snapshots @@ -14,12 +14,13 @@ use warnings; use DateTime; use DateTime::Format::Mail; +use English qw{-no_match_vars}; use File::Basename; use File::Find::Rule; use File::Path qw(remove_tree); use File::Slurp; use Getopt::Long; -use IPC::System::Simple qw(capturex runx); +use IPC::System::Simple qw(runx); use List::MoreUtils qw(uniq); @@ -68,12 +69,15 @@ my @snapshots_dirs = File::Find::Rule->directory() verbose_print("found snapshots directories: @snapshots_dirs\n"); # Let's load once and for all references known by reprepro to see -# which suites/snapshots are present there to see what needs removing: +# which suites/snapshots are present there to see what needs removing +# (use a shell pipeline to avoid loading the entire output of +# dumpreferences into memory; we've seen it take no less than 7.5 GiB): my @reprepro_references = - uniq - map { (split / /, $_)[0] } - grep { $_ =~ /^s=/ } - capturex('reprepro', '-b', $archive_dir, 'dumpreferences'); + `reprepro -b '$archive_dir' dumpreferences \\ + | awk '/^s=/ {print \$1}' \\ + | sort -u`; +${^CHILD_ERROR_NATIVE} == 0 + or die "E: Failed to load references: ${^CHILD_ERROR_NATIVE}"; verbose_print("reprepro-known snapshot references:", (join "\n - ", '', @reprepro_references), "\n"); my $now = DateTime->now(); |