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