dh_installsystemd - why deactivate services in postrm instead of prerm?

Daniele Nicolodi daniele at grinta.net
Wed Jun 27 19:20:55 BST 2018


On 6/27/18 11:48 AM, Michael Biebl wrote:
> Hi Daniele
> 
> Am 27.06.2018 um 19:39 schrieb Daniele Nicolodi:
>> Hello,
>>
>> I'm working on dh_installsystemduser, the equivalent of
>> dh_installsystemd for user instance systemd units. In the process I'm
>> trying to understand why dh_installsystemd works the way it does.
>>
>> dh_installsystemd generates maintainer scripts code blocks that
>> deactivates installed unit. Why is it that done at postrm stage and not
>> at prerm stage? It seems that the later is the most common place where
>> to clean up on package removal, but I'm probably missing something.
>>
> 
> Which part exactly do you mean? The bits that mask a service?

All of the postrm code block:

if [ "$1" = "remove" ]; then
	if [ -x "/usr/bin/deb-systemd-helper" ]; then
		deb-systemd-helper mask #UNITFILES# >/dev/null || true
	fi
fi

if [ "$1" = "purge" ]; then
	if [ -x "/usr/bin/deb-systemd-helper" ]; then
		deb-systemd-helper purge #UNITFILES# >/dev/null || true
		deb-systemd-helper unmask #UNITFILES# >/dev/null || true
	fi
fi

I think it could be safely moved to prerm.

The issue came up (see my message and Simon answer on debian-devel)
because it is safe to rely on dependencies still being available at
prerm time but not at postrm time, and dh_installsystemduser will need
to have a versioned dependency on init-system-helpers.

Cheers,
Dan




More information about the Pkg-systemd-maintainers mailing list