Installing mrpd on a bridge that had mrpd-minimal left the stack half
stopped. With only mrpd-minimal declaring Conflicts/Replaces, apt
removed it first: its prerm (remove) ran
"systemctl disable --now mrpd.service avb.target
mv88e6341-atu-hash.service", and stopping avb.target also stopped
ptp4l.service through its PartOf=. mrpd's postinst (configure) then
only enabled the units, so mrpd, avb.target and ptp4l stayed down
until someone started them. An mrpd upgrade had a related gap: the
postinst never restarted mrpd, so the old binary kept running.
The scriptlets common.sh writes now follow dh_installsystemd's
snippets (deb-systemd-helper, deb-systemd-invoke) instead of calling
systemctl directly. The package now depends on init-system-helpers:
- postinst (configure, abort-*): enables each unit unless the admin
disabled it (deb-systemd-helper was-enabled), then starts
DEB_START_UNITS and restarts DEB_RESTART_UNITS, each only if
enabled. mrpd sets these to ptp4l.service avb.target and
mrpd.service. The ATU hash unit is enabled but not run, because
changing the hash on a live switch would misplace learned entries.
Other packages leave both empty, so they still only enable their
units.
- prerm: stops the units on "remove", but not on "remove in-favour
<pkg> <ver>". It no longer disables them; enablement is cleared on
purge (postrm purge: deb-systemd-helper purge), as with debhelper.
- mrpd now also Conflicts/Replaces mrpd-minimal, so either direction
of replacement is a dpkg conflict replacement.
The sequences:
- Fresh install: postinst configure enables the units, starts ptp4l
(if enabled by linuxptp) and avb.target, and starts mrpd.
- Upgrade: prerm upgrade does nothing, and postinst configure <old>
restarts mrpd onto the new binary. ptp4l and avb.target stay as
they are, because starting an active unit does nothing.
- Replacement through dpkg (unpack mrpd, prerm remove in-favour on
mrpd-minimal, postrm remove, postinst configure): nothing is
stopped, and the postinst restarts mrpd onto the full binary.
- Replacement through an explicit apt removal (prerm remove, postrm
remove, then install), including the already installed mrpd-minimal
whose old prerm still runs: the stack stops, and the new postinst
starts ptp4l and avb.target and restarts mrpd. Old installs enabled
the units with systemctl and have no deb-systemd-helper state, so
was-enabled is true and the units are re-enabled.
- Removal: prerm remove stops the units (and so ptp4l, through
avb.target), and postrm reloads systemd.
Verified by building dummy mrpd and linuxptp .debs with build_deb.
dpkg-deb -I shows the control fields, dash -n passes on every script,
and running the scripts with stubbed helpers for configure (fresh and
upgrade), remove, remove in-favour, upgrade and purge gave the calls
listed above. Nothing was installed on a target.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SGwDLWKAC1NJDijG6Ss6YH