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

-- 
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to init-system-helpers in
Ubuntu.
https://bugs.launchpad.net/bugs/1579922

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

Status in init-system-helpers package in Ubuntu:
  Won't Fix

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: $!");

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/init-system-helpers/+bug/1579922/+subscriptions

-- 
Mailing list: https://launchpad.net/~touch-packages
Post to     : touch-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~touch-packages
More help   : https://help.launchpad.net/ListHelp

Reply via email to