dh_systemd_enable fails due to 'preset' when service file is renamed

Bug #1579922 reported by Serge Hallyn
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
init-system-helpers (Ubuntu)
Won't Fix
Undecided
Unassigned

Bug Description

This is a bit of a special case and may be being done wrong by the package... libvirt is moving the libvirt-bin.service from libvirt-bin package to libvirtd.service in libvirt-daemon-system package. The packaging source can be seen at https://git.launchpad.net/~libvirt-maintainers/ubuntu/+source/libvirt/tree/?h=2016-05-07/yakkety, and it is packaged at ppa:serge-hallyn/virt.

When using the init-system-helpers package from xenial, this all works. However with the init-system-helpers package in yakkety, and when upgrading the current libvirt-bin package to this proposed package, it fails during deb-systemd-helper with a message from:

            system("/bin/systemctl", "--preset-mode=enable-only",
                "preset", $scriptname) == 0 or
                error("systemctl preset failed on $scriptname: $!");

Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

Hm, at this point this doesn't seem to be reproducing any more. Without any changes to either init-system-helpers or libvirt. Only upgraded packages are:

libpython3.5-minimal/yakkety 3.5.1-12 amd64 [upgradable from: 3.5.1-11]
libpython3.5-stdlib/yakkety 3.5.1-12 amd64 [upgradable from: 3.5.1-11]
pollinate/yakkety 4.18-0ubuntu1 all [upgradable from: 4.17-0ubuntu1]
python3-cffi-backend/yakkety 1.6.0-1 amd64 [upgradable from: 1.5.2-1ubuntu1]
python3-jwt/yakkety 1.4.0-1 all [upgradable from: 1.3.0-1]
python3-update-manager/yakkety 1:16.10.1 all [upgradable from: 1:16.04.3]
python3-urllib3/yakkety 1.13.1-2ubuntu1 all [upgradable from: 1.13.1-2]
python3.5/yakkety 3.5.1-12 amd64 [upgradable from: 3.5.1-11]
python3.5-minimal/yakkety 3.5.1-12 amd64 [upgradable from: 3.5.1-11]
update-manager-core/yakkety 1:16.10.1 all [upgradable from: 1:16.04.3]

Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

(so this probably should be marked invalid as cannot-be-reproduced, but i'll leave it to a maintainer to do that in case this bug points to something which still ought to be fixed)

Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

No, now I have reproduced it:

Adding user `libvirt-qemu' to group `libvirt-qemu' ...
Adding user libvirt-qemu to group libvirt-qemu
Done.
Failed to execute operation: No such file or directory
/usr/bin/deb-systemd-helper: error: systemctl preset failed on libvirtd.service: No such file or directory
virtlockd.service is a disabled or a static unit, not starting it.

Steps:

create a xenial vm
sed -i 's/xenial/yakkety/g' /etc/apt/sources.list
apt update && apt -y upgrade
apt -y install qemu-kvm libvirt-bin
add-apt-repository ppa:serge-hallyn/virt
apt update && apt -y upgrade

Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

I can reproduce it with the package excerpts at

https://code.launchpad.net/~serge-hallyn/+git/pkg1
and
https://code.launchpad.net/~serge-hallyn/+git/pkg2

First

 dpkg -i pkg1_1-1_amd64.deb

then

 dpkg -i pkg1_1-2_amd64.deb pkg2_1-2_amd64.deb

On yakkety, this gives me:

(Reading database ... 27385 files and directories currently installed.)
Preparing to unpack /pkg1_1-2_amd64.deb ...
enabled
Unpacking pkg1 (1-2) over (1-1) ...
Selecting previously unselected package pkg2.
Preparing to unpack /pkg2_1-2_amd64.deb ...
Unpacking pkg2 (1-2) ...
Setting up pkg2 (1-2) ...
Failed to execute operation: No such file or directory
/usr/bin/deb-systemd-helper: error: systemctl preset failed on pkg2.service: No such file or directory
Failed to get unit file state for pkg2.service: No such file or directory
pkg2.service is a disabled or a static unit, not starting it.

I trust I'm doing something wrong in pkg1.preinst (in version 1-2).

Revision history for this message
Martin Pitt (pitti) wrote :

The .service files are a bit confusing -- pkg1.service has Alias=pkg2.service and pkg2.service has Alias=pkg1.service. Thus you have a unit with an alias which is actually a different unit, and then a criss-cross aliasing. Normally Alias= should not point to an existing different unit, these will become a symlink to the unit that declares them.

Indeed in this situation the unit enablement gets confused:

# systemctl preset pkg2.service
Failed to execute operation: No such file or directory
# systemctl enable pkg2.service
Failed to execute operation: Too many levels of symbolic links

This is because there is an already existing dangling link:

  lrwxrwxrwx 1 root root 32 May 19 11:50 /etc/systemd/system/pkg2.service -> /lib/systemd/system/pkg1.service

I. e. the maintainer scripts of the old pkg1 don't disable the service before the upgrade (or remove the dangling symlink). As you already found out on IRC, this currently needs to be done manually, there is no debhelper automatism for this.

It works fine with:

--- a/debian/pkg1.preinst
+++ b/debian/pkg1.preinst
@@ -16,15 +16,9 @@ set -e
 case "$1" in
     install|upgrade)
        if dpkg --compare-versions "$2" lt-nl "1-2"; then
- if [ -d /run/systemd/system ]; then
- if [ "$(deb-systemd-helper was-enabled pkg1.service)" = "disabled" ]; then
- touch /var/run/TMP_pkg1-enabled
- else
- touch /var/run/TMP_pkg1-disabled
- fi
- fi
-
             invoke-rc.d pkg1 stop
+ deb-systemd-helper disable pkg1.service
+ deb-systemd-helper purge pkg1.service
        fi
     ;;

Then pkg2.service is enabled, running, and aliased to pkg1 as desired.

Changed in init-system-helpers (Ubuntu):
status: New → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.