diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-17 16:37:30 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-17 16:37:30 +0000 |
commit | dbf14b11a1c911e6832e5518ae9c3e406245edaa (patch) | |
tree | f2b58ca7d37f97bf2c49862a31951aa103c06b12 /dh_installtmpfiles | |
parent | Releasing progress-linux version 13.15.3-0.0~progress7.99u1. (diff) | |
download | debhelper-dbf14b11a1c911e6832e5518ae9c3e406245edaa.tar.xz debhelper-dbf14b11a1c911e6832e5518ae9c3e406245edaa.zip |
Merging upstream version 13.16.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dh_installtmpfiles')
-rwxr-xr-x | dh_installtmpfiles | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/dh_installtmpfiles b/dh_installtmpfiles index aa5ab72..70dbc5a 100755 --- a/dh_installtmpfiles +++ b/dh_installtmpfiles @@ -28,6 +28,12 @@ and generates F<postinst> code blocks for activating the tmpfiles.d configuration when the package is installed. These snippets are added to the maintainer scripts by L<dh_installdeb(1)>. +In compat 14+, tmpfiles.d files are copied into the F<postrm> script, and +they are used with systemd-tmpfiles --remove after the package is removed +and --purge when the package is purged. This allows one to use the +tmpfiles.d mechanism to clean up files that are no longer needed after a +package has been removed/purged. + =head1 OPTIONS @@ -35,7 +41,7 @@ to the maintainer scripts by L<dh_installdeb(1)>. =item B<--name=>I<name> -This option controls both a prefix used for lookng up maintainer provided +This option controls both a prefix used for looking up maintainer provided tmpfiles.d configuration files (those mentioned in the L</FILES> section) and also the base name used for the installed version of the file. @@ -105,20 +111,54 @@ foreach my $package (@{$dh{DOPACKAGES}}) { foreach my $package (@{$dh{DOPACKAGES}}) { my $tmpdir = tmpdir($package); my @tmpfiles; + my @purge; + my @remove; my @dirs = grep { -d } map { "${tmpdir}/$_" } qw(usr/lib/tmpfiles.d etc/tmpfiles.d); find({ wanted => sub { + my $lines; my $name = $File::Find::name; return if not -f $name or not $name =~ m{[.]conf$}; - push(@tmpfiles, basename($name)); }, + push(@tmpfiles, basename($name)); + + # We copy the needed lines to the postrm, as the tmpfiles.d files + # will be gone by the time the remove/purge postscript is run. + if (! compat(13) && (! $dh{NO_PURGE} || ! $dh{NO_REMOVE})) { + open(my $fd, '<', $name) or error("open($name) failed: $!"); + { + local $/; + $lines = <$fd>; + } + close($fd); + + chomp $lines; + + if ($lines) { + push(@purge, $lines); + push(@remove, $lines); + } + } + }, no_chdir => 1, }, @dirs) if @dirs; if (@tmpfiles) { autoscript($package, 'postinst', 'postinst-init-tmpfiles', { 'TMPFILES' => join(' ', uniq(sort(@tmpfiles))) }); } + + if (@remove) { + autoscript($package, 'postrm', 'postrm-init-tmpfiles-remove', { + 'TMPFILES_REMOVE' => join("\n", @remove), + }); + } + + if (@purge) { + autoscript($package, 'postrm', 'postrm-init-tmpfiles-purge', { + 'TMPFILES_PURGE' => join("\n", @purge), + }); + } } =head1 SEE ALSO |