#1010020 systemctl-replacement doesn't work with deb-systemd-helper

#1010020#5
Date:
2022-04-22 12:26:31 UTC
From:
To:
Dear Maintainer,

systemctl-replacement fails to support the preset parameter, which is used by
the deb-systemd-helper script when installing packages with systemd service
files. If the systemctl package is installed before a package, which wants to
install a systemd service file, enabling this service fails. If the systemctl
package is not installed, deb-systemd-helper itself takes care of enabling the
service file, if no systemd is installed on the system.

With installed systemctl package:

================================================================
# DEBIAN_FRONTEND=noninteractive apt-get install -y ntp

...

Setting up ntp (1:4.2.8p15+dfsg-1) ...
/usr/bin/deb-systemd-helper: error: systemctl preset failed on ntp.service: No such file or directory
invoke-rc.d: could not determine current runlevel
invoke-rc.d: policy-rc.d denied execution of start.
Setting up libgdbm-compat4:amd64 (1.19-2) ...
Setting up libperl5.32:amd64 (5.32.1-4+deb11u2) ...
Setting up perl (5.32.1-4+deb11u2) ...
Processing triggers for libc-bin (2.31-13+deb11u3) ...

# ls -l /etc/systemd/system/
default.target.wants/ timers.target.wants/

# ls -l /etc/systemd/system/*.wants

/etc/systemd/system/default.target.wants:
total 0
lrwxrwxrwx 1 root root 40 Jan  1  1970 e2scrub_reap.service -> /lib/systemd/system/e2scrub_reap.service

/etc/systemd/system/timers.target.wants:
total 0
lrwxrwxrwx 1 root root 43 Jan  1  1970 apt-daily-upgrade.timer -> /lib/systemd/system/apt-daily-upgrade.timer
lrwxrwxrwx 1 root root 35 Jan  1  1970 apt-daily.timer -> /lib/systemd/system/apt-daily.timer
lrwxrwxrwx 1 root root 37 Jan  1  1970 e2scrub_all.timer -> /lib/systemd/system/e2scrub_all.timer
lrwxrwxrwx 1 root root 32 Jan  1  1970 fstrim.timer -> /lib/systemd/system/fstrim.timer

# ls -l /lib/systemd/system/ntp.service
-rw-r--r-- 1 root root 354 Sep 23  2020 /lib/systemd/system/ntp.service
================================================================

Notice, that the error message "No such file or directory" is misleading and
wrong, see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1009963.

Calling systemctl manually with the parameter set by deb-systemd-helper fails
too, 1 is returned as result and no links to the service files are setup.

================================================================
# systemctl --system --preset-mode=enable-only preset ntp.service
# echo $?
1
================================================================

Thanks,
Sascha