also delete everything in /run and add --skip=cleanup/run

This commit is contained in:
Johannes Schauer Marin Rodrigues 2022-09-02 23:29:52 +02:00
parent add9412a47
commit 0af22912f7
Signed by untrusted user: josch
GPG key ID: F2CBA5C78FBD83E1
3 changed files with 30 additions and 9 deletions

View file

@ -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} }) { if (any { $_ eq 'cleanup/tmp' } @{ $options->{skip} }) {
info "skipping cleanup/tmp as requested"; info "skipping cleanup/tmp as requested";
} else { } else {
# remove any possible leftovers in /tmp but warn about it # remove any possible leftovers in /tmp
if (-d "$options->{root}/tmp") { if (-d "$options->{root}/tmp") {
opendir(my $dh, "$options->{root}/tmp") opendir(my $dh, "$options->{root}/tmp")
or error "Can't opendir($options->{root}/tmp): $!"; or error "Can't opendir($options->{root}/tmp): $!";
@ -3044,7 +3065,7 @@ sub run_cleanup() {
# skip the "." and ".." entries # skip the "." and ".." entries
next if $entry eq "."; next if $entry eq ".";
next if $entry eq ".."; next if $entry eq "..";
warning "deleting files in /tmp: $entry"; debug "deleting files in /tmp: $entry";
0 == system( 0 == system(
'rm', '--interactive=never', 'rm', '--interactive=never',
'--recursive', '--preserve-root', '--recursive', '--preserve-root',
@ -6839,6 +6860,8 @@ Performs cleanup tasks, unless B<--skip=cleanup> is used:
=back =back
=item * Remove everything in F</run> inside the chroot. This can be disabled using B<--skip=cleanup/run>.
=item * Remove everything in F</tmp> inside the chroot. This can be disabled using B<--skip=cleanup/tmp>. =item * Remove everything in F</tmp> inside the chroot. This can be disabled using B<--skip=cleanup/tmp>.
=back =back

View file

@ -34,6 +34,9 @@ rm /tmp/debian-debootstrap/var/log/dpkg.log \
/tmp/debian-debootstrap/var/log/alternatives.log \ /tmp/debian-debootstrap/var/log/alternatives.log \
/tmp/debian-mm/var/log/bootstrap.log /tmp/debian-mm/var/log/bootstrap.log
# clear out /run
rm -r /tmp/debian-debootstrap/run/*
# debootstrap doesn't clean apt # debootstrap doesn't clean apt
rm /tmp/debian-debootstrap/var/lib/apt/lists/127.0.0.1_debian_dists_unstable_main_binary-{{ HOSTARCH }}_Packages \ 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 \ /tmp/debian-debootstrap/var/lib/apt/lists/127.0.0.1_debian_dists_unstable_Release \

View file

@ -95,13 +95,8 @@ fi
if [ -e /tmp/debian-{{ DIST }}-mm/etc/apt/apt.conf.d/01autoremove-kernels ]; then 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 rm /tmp/debian-{{ DIST }}-mm/etc/apt/apt.conf.d/01autoremove-kernels
fi fi
# who creates /run/mount? # clear out /run
if [ -e "/tmp/debian-{{ DIST }}-debootstrap/run/mount/utab" ]; then rm -r /tmp/debian-{{ DIST }}-debootstrap/run/*
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
# debootstrap doesn't clean apt # 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 \ 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 \ /tmp/debian-{{ DIST }}-debootstrap/var/lib/apt/lists/127.0.0.1_debian_dists_{{ DIST }}_Release \