dh-systemd seems not to support multiple service units
Dererk
dererk at debian.org
Mon Feb 13 13:21:30 GMT 2017
On 13/02/17 09:52, Felipe Sateler wrote:
> Hi Dererk,
>
> On 10 February 2017 at 14:06, Dererk <dererk at debian.org> wrote:
>> Dear pkg-systemd Maintainers,
>>
>> I've been trying to deliver a package that has a mix of enabled/disable
>> and started/not started service units.
>>
>> The situation I encounter seems to be reflected at the manpage, when
>> calling dh_systemd_enable, quoting:
>>
>> "Note that this command is not idempotent. dh_prep(1) should be called
>> between invocations of this command (with the same arguments).
>> Otherwise, it may cause multiple instances of the same text to be added
>> to maintainer scripts"
>>
>> Which is exactly what I end up with, a really long postinst file
>> repeating the postinst instructions generated in the previous
>> dh_systemd_enable call
>>
>> On the other hand, I may not be properly understanding the reference in
>> the manpage that states to trigger dh_prep between dh_system. If I
>> understand correctly, dh_prep will actually remove everything writing up
>> to that point into the respective debian/ directory's package entry,
>> which I double checked it does:
>>
>> dh_prep --name=service_on_by_default
>> rm -f debian/python3-mypackage.substvars
>> rm -f debian/python3-mypackage.*.debhelper
>> rm -rf debian/python3-mypackage/
>> rm -f debian/binaries-pkg.substvars
>> rm -f debian/binaries-pkg.*.debhelper
>> rm -rf debian/binaries-pkg/
>> rm -rf debian/tmp
>>
>> What am I doing wrong? This is what the debian/rules looks like:
>>
>> override_dh_systemd_enable:
>> dh_systemd_enable --name=service_on_by_default
>> dh_prep --name=service_on_by_default
>>
>> dh_systemd_enable --no-enable --name=non_tipical_service
> Do not invoke dh_prep here. The manpage warning refers to invocations
> using the same arguments. In your case they are not the same
> arguments, so you should not call dh_prep.
>
> The warning just implies that running the
> override_dh_systemd_enable[1] target multiple times will result in
> maintainer scripts that repeat themselves.
>
>
> [1] or equivalent for other sequencers.
Hey Felipe!
Thanks for replying back! :)
Ok, what I don't get is what I should do to avoid getting maintainer
scripts called several times.
In the case I mentioned, what I get after calling different
/dh_systemd_enable/ on *a single /override_dh_systemd_enable/* is
exactly what the warning talks about: I'm getting duplicated
dh_systemd_enable maintainer scripts entries, just like I'm attaching
above, here's what the debian/rules target looks like:
override_dh_systemd_enable:
dh_systemd_enable --name=service_on_by_default
dh_systemd_enable --name=another_service_on_by_default
dh_systemd_enable --no-enable --name=non_tipical_service
Please see that the very same block is repeated, and, If a attempt to
add another /dh_systemd_enable/ line, it would and this entries, plus
triplicate them all the same. I see this is because the
dh_systemd_enable parses a state file that has included all runs that
happen before its call.
What should I do?
#!/bin/sh
set -e
# End automatically added section
# Automatically added by dh_systemd_enable
# This will only remove masks created by d-s-h on package removal.
deb-systemd-helper unmask service_on_by_default.service >/dev/null || true
# was-enabled defaults to true, so new installations run enable.
if deb-systemd-helper --quiet was-enabled service_on_by_default.service;
then
# Enables the unit on first installation, creates new
# symlinks on upgrades if the unit file has changed.
deb-systemd-helper enable service_on_by_default.service >/dev/null
|| true
else
# Update the statefile to add new symlinks (if any), which need to be
# cleaned up on purge. Also remove old symlinks.
deb-systemd-helper update-state service_on_by_default.service
>/dev/null || true
fi
# End automatically added section
# Automatically added by dh_systemd_enable
# This will only remove masks created by d-s-h on package removal.
deb-systemd-helper unmask service_on_by_default.service >/dev/null || true
# was-enabled defaults to true, so new installations run enable.
if deb-systemd-helper --quiet was-enabled service_on_by_default.service;
then
# Enables the unit on first installation, creates new
# symlinks on upgrades if the unit file has changed.
deb-systemd-helper enable service_on_by_default.service >/dev/null
|| true
else
# Update the statefile to add new symlinks (if any), which need to be
# cleaned up on purge. Also remove old symlinks.
deb-systemd-helper update-state service_on_by_default.service
>/dev/null || true
fi
# End automatically added section
# Automatically added by dh_systemd_enable
# This will only remove masks created by d-s-h on package removal.
deb-systemd-helper unmask another_service_on_by_default.service
>/dev/null || true
# was-enabled defaults to true, so new installations run enable.
if deb-systemd-helper --quiet was-enabled
another_service_on_by_default.service; then
# Enables the unit on first installation, creates new
# symlinks on upgrades if the unit file has changed.
deb-systemd-helper enable another_service_on_by_default.service
>/dev/null || true
else
# Update the statefile to add new symlinks (if any), which need to be
# cleaned up on purge. Also remove old symlinks.
deb-systemd-helper update-state
another_service_on_by_default.service >/dev/null || true
fi
# End automatically added section
# Automatically added by dh_systemd_enable
if deb-systemd-helper debian-installed service_on_by_default.service; then
# This will only remove masks created by d-s-h on package removal.
deb-systemd-helper unmask service_on_by_default.service >/dev/null
|| true
if deb-systemd-helper --quiet was-enabled
service_on_by_default.service; then
# Create new symlinks, if any.
deb-systemd-helper enable service_on_by_default.service
>/dev/null || true
fi
fi
# Update the statefile to add new symlinks (if any), which need to be
cleaned
# up on purge. Also remove old symlinks.
deb-systemd-helper update-state service_on_by_default.service >/dev/null
|| true
# End automatically added section
# Automatically added by dh_systemd_enable
if deb-systemd-helper debian-installed
another_service_on_by_default.service; then
# This will only remove masks created by d-s-h on package removal.
deb-systemd-helper unmask another_service_on_by_default.service
>/dev/null || true
if deb-systemd-helper --quiet was-enabled
another_service_on_by_default.service; then
# Create new symlinks, if any.
deb-systemd-helper enable another_service_on_by_default.service
>/dev/null || true
fi
fi
# Update the statefile to add new symlinks (if any), which need to be
cleaned
# up on purge. Also remove old symlinks.
deb-systemd-helper update-state another_service_on_by_default.service
>/dev/null || true
# End automatically added section
--
"Oh what wouldn't I give to be spat at in the face..."
-- a prisoner in "Life of Brian"
More information about the Pkg-systemd-maintainers
mailing list