dh_installsystemd - why deactivate services in postrm instead of prerm?

Michael Biebl biebl at debian.org
Wed Jun 27 19:33:33 BST 2018

Am 27.06.2018 um 20:20 schrieb Daniele Nicolodi:
> 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.

I remember that invoke-rc.d did not handle masked services properly
I.e. if a service was masked in prerm and the invoke-rc.d stop foo was
called, this failed.
I think this was the original reason why we moved the mask-on-remove to
postrm. It's been a long time ago though, so I could misremember.
This part could move to prerm I guess.

The cleanup-on-purge is definitely something you should run in postrm
and not prerm, as restoring the state on an aborted removal will become
impossible or at least really tricky afair.


Why is it that all of the instruments seeking intelligent life in the
universe are pointed away from Earth?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://alioth-lists.debian.net/pipermail/pkg-systemd-maintainers/attachments/20180627/827dd617/attachment-0002.sig>

More information about the Pkg-systemd-maintainers mailing list