From 0af22912f780b73b09aeb15810f2fe6f1bee4255 Mon Sep 17 00:00:00 2001 From: Johannes Schauer Marin Rodrigues Date: Fri, 2 Sep 2022 23:29:52 +0200 Subject: [PATCH] also delete everything in /run and add --skip=cleanup/run --- mmdebstrap | 27 +++++++++++++++++++++++++-- tests/as-debootstrap-unshare-wrapper | 3 +++ tests/check-against-debootstrap-dist | 9 ++------- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/mmdebstrap b/mmdebstrap index 182db7b..e4fb6ca 100755 --- a/mmdebstrap +++ b/mmdebstrap @@ -3033,10 +3033,31 @@ sub run_cleanup() { } } + if (any { $_ eq 'cleanup/run' } @{ $options->{skip} }) { + info "skipping cleanup/run as requested"; + } else { + # remove any possible leftovers in /run + if (-d "$options->{root}/run") { + opendir(my $dh, "$options->{root}/run") + or error "Can't opendir($options->{root}/run): $!"; + while (my $entry = readdir $dh) { + # skip the "." and ".." entries + next if $entry eq "."; + next if $entry eq ".."; + debug "deleting files in /run: $entry"; + 0 == system( + 'rm', '--interactive=never', + '--recursive', '--preserve-root', + '--one-file-system', "$options->{root}/run/$entry" + ) or error "rm failed: $?"; + } + closedir($dh); + } + } if (any { $_ eq 'cleanup/tmp' } @{ $options->{skip} }) { info "skipping cleanup/tmp as requested"; } else { - # remove any possible leftovers in /tmp but warn about it + # remove any possible leftovers in /tmp if (-d "$options->{root}/tmp") { opendir(my $dh, "$options->{root}/tmp") or error "Can't opendir($options->{root}/tmp): $!"; @@ -3044,7 +3065,7 @@ sub run_cleanup() { # skip the "." and ".." entries next if $entry eq "."; next if $entry eq ".."; - warning "deleting files in /tmp: $entry"; + debug "deleting files in /tmp: $entry"; 0 == system( 'rm', '--interactive=never', '--recursive', '--preserve-root', @@ -6839,6 +6860,8 @@ Performs cleanup tasks, unless B<--skip=cleanup> is used: =back +=item * Remove everything in F inside the chroot. This can be disabled using B<--skip=cleanup/run>. + =item * Remove everything in F inside the chroot. This can be disabled using B<--skip=cleanup/tmp>. =back diff --git a/tests/as-debootstrap-unshare-wrapper b/tests/as-debootstrap-unshare-wrapper index 62ea90a..e89c6dd 100644 --- a/tests/as-debootstrap-unshare-wrapper +++ b/tests/as-debootstrap-unshare-wrapper @@ -34,6 +34,9 @@ rm /tmp/debian-debootstrap/var/log/dpkg.log \ /tmp/debian-debootstrap/var/log/alternatives.log \ /tmp/debian-mm/var/log/bootstrap.log +# clear out /run +rm -r /tmp/debian-debootstrap/run/* + # debootstrap doesn't clean apt rm /tmp/debian-debootstrap/var/lib/apt/lists/127.0.0.1_debian_dists_unstable_main_binary-{{ HOSTARCH }}_Packages \ /tmp/debian-debootstrap/var/lib/apt/lists/127.0.0.1_debian_dists_unstable_Release \ diff --git a/tests/check-against-debootstrap-dist b/tests/check-against-debootstrap-dist index 9270aa3..a386a8a 100644 --- a/tests/check-against-debootstrap-dist +++ b/tests/check-against-debootstrap-dist @@ -95,13 +95,8 @@ fi if [ -e /tmp/debian-{{ DIST }}-mm/etc/apt/apt.conf.d/01autoremove-kernels ]; then rm /tmp/debian-{{ DIST }}-mm/etc/apt/apt.conf.d/01autoremove-kernels fi -# who creates /run/mount? -if [ -e "/tmp/debian-{{ DIST }}-debootstrap/run/mount/utab" ]; then - rm "/tmp/debian-{{ DIST }}-debootstrap/run/mount/utab" -fi -if [ -e "/tmp/debian-{{ DIST }}-debootstrap/run/mount" ]; then - rmdir "/tmp/debian-{{ DIST }}-debootstrap/run/mount" -fi +# clear out /run +rm -r /tmp/debian-{{ DIST }}-debootstrap/run/* # debootstrap doesn't clean apt rm /tmp/debian-{{ DIST }}-debootstrap/var/lib/apt/lists/127.0.0.1_debian_dists_{{ DIST }}_main_binary-{{ HOSTARCH }}_Packages \ /tmp/debian-{{ DIST }}-debootstrap/var/lib/apt/lists/127.0.0.1_debian_dists_{{ DIST }}_Release \