[Debconf-devel] Bug#1028128: debconf: Please support /var/cache/debconf/tmp.ci being a tmpfs

Colin Watson cjwatson at debian.org
Sat Jan 7 22:29:59 GMT 2023


On Sat, Jan 07, 2023 at 04:04:20PM +0100, Niels Thykier wrote:
> Thanks for change to make dpkg-preconfigure no longer assume /tmp is mounted
> with `exec` (or without `noexec`).
> 
> When trying it out, I decided to make `/var/cache/debconf/tmp.ci` a tmpfs
> (with `exec` mounted) as a means to avoid unnecessary writes to the disk.
> This results in the following warnings from dpkg-preconfigure:
> 
> ```
> [... apt output here ...]
> Need to get 0 B/357 kB of archives.
> After this operation, 11,3 kB disk space will be freed.
> Do you want to continue? [Y/n]
> cannot remove directory for /var/cache/debconf/tmp.ci: Device or resource
> busy at /usr/sbin/dpkg-preconfigure line 73.
> cannot remove directory for /var/cache/debconf/tmp.ci: Device or resource
> busy at /usr/sbin/dpkg-preconfigure line 159.
> (Reading database ... 126341 files and directories currently installed.)
> [... dpkg log from here ...]
> ```
> 
> It does not seem to cause errors or problems, but I would prefer not having
> "warnings". Therefore, I was hoping dpkg-preconfigure would adopt/support
> this particular configuration as a supported (warning-free) method.

What do you think about this patch?  It would mean that
/var/cache/debconf/tmp.ci ends up existing more or less permanently on
most systems, but I guess that also helps with reducing unnecessary
writes very slightly (in the form of modifications to the
/var/cache/debconf directory).

The alternative would be to skip removal if the directory is a
mountpoint, but I think I marginally prefer this approach, especially as
I think the only sensible way to check for a mountpoint without extra
Perl modules is to call the external mountpoint(1) command.

diff --git a/dpkg-preconfigure b/dpkg-preconfigure
index e0db5b19..c1f24441 100755
--- a/dpkg-preconfigure
+++ b/dpkg-preconfigure
@@ -141,7 +141,7 @@ if (! $have_tty && $frontend->need_tty) {
 }
 
 my $tempdir='/var/cache/debconf/tmp.ci';
-remove_tree($tempdir, { safe => 1 });
+remove_tree($tempdir, { safe => 1, keep_root => 1 });
 make_path($tempdir);
 
 # Use the external package scanner for speed. It takes a list of debs
@@ -248,7 +248,7 @@ $frontend->shutdown;
 # Save state.
 Debconf::Db->save;
 
-remove_tree($tempdir, { safe => 1 });
+remove_tree($tempdir, { safe => 1, keep_root => 1 });
 
 =head1 AUTHOR
 
-- 
Colin Watson (he/him)                              [cjwatson at debian.org]



More information about the Debconf-devel mailing list