From 88a031477a96258c1fd95badce217d244d631f45 Mon Sep 17 00:00:00 2001 From: Johannes Schauer Marin Rodrigues Date: Sun, 9 May 2021 20:44:02 +0200 Subject: [PATCH] add --skip=cleanup/apt/lists and --skip=cleanup/apt/cache --- mmdebstrap | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/mmdebstrap b/mmdebstrap index b513ad7..672d5df 100755 --- a/mmdebstrap +++ b/mmdebstrap @@ -3015,17 +3015,34 @@ sub run_cleanup() { if (any { $_ eq 'cleanup/apt' } @{ $options->{skip} }) { info "skipping cleanup/apt as requested"; } else { - info "cleaning package lists and apt cache..."; - run_apt_progress({ - ARGV => [ - 'apt-get', '--option', - 'Dir::Etc::SourceList=/dev/null', '--option', - 'Dir::Etc::SourceParts=/dev/null', 'update' - ], - CHDIR => $options->{root}, - }); - run_apt_progress( - { ARGV => ['apt-get', 'clean'], CHDIR => $options->{root} }); + if ( none { $_ eq 'cleanup/apt/lists' } @{ $options->{skip} } + and none { $_ eq 'cleanup/apt/cache' } @{ $options->{skip} }) { + info "cleaning package lists and apt cache..."; + } + if (any { $_ eq 'cleanup/apt/lists' } @{ $options->{skip} }) { + info "skipping cleanup/apt/lists as requested"; + } else { + if (any { $_ eq 'cleanup/apt/cache' } @{ $options->{skip} }) { + info "cleaning package lists..."; + } + run_apt_progress({ + ARGV => [ + 'apt-get', '--option', + 'Dir::Etc::SourceList=/dev/null', '--option', + 'Dir::Etc::SourceParts=/dev/null', 'update' + ], + CHDIR => $options->{root}, + }); + } + if (any { $_ eq 'cleanup/apt/cache' } @{ $options->{skip} }) { + info "skipping cleanup/apt/cache as requested"; + } else { + if (any { $_ eq 'cleanup/apt/lists' } @{ $options->{skip} }) { + info "cleaning apt cache..."; + } + run_apt_progress( + { ARGV => ['apt-get', 'clean'], CHDIR => $options->{root} }); + } # apt since 1.6 creates the auxfiles directory. If apt inside the # chroot is older than that, then it will not know how to clean it. @@ -6727,7 +6744,7 @@ Performs cleanup tasks like: =over 4 -=item * Removes the package lists and apt cache. This can be disabled using B<--skip=cleanup/apt>. +=item * Removes the package lists (unless B<--skip=cleanup/apt/lists>) and apt cache (unless B<--skip=cleanup/apt/cache>). Both removals can be disabled by using B<--skip=cleanup/apt>. =item * Remove all files that were put into the chroot for setup purposes, like F, the temporary apt config and the qemu-user-static binary. This can be disabled using B<--skip=cleanup/mmdebstrap>.