Package: setserial
Version: 2.17-48
Severity: minor
Tags: patch
User: [email protected]
Usertags: origin-ubuntu ubuntu-patch wily

Hello,

In Ubuntu (https://launchpad.net/bugs/1452644) it was reported that
installing setserial, network-manager, and nfs-kernel-server leads to
a dependency cycle:

|  Found ordering cycle on nfs-server.service/start
|  Found dependency on network.target/start
|  Found dependency on NetworkManager.service/start
|  Found dependency on basic.target/start
|  Found dependency on sockets.target/start
|  Found dependency on cups.socket/start
|  Found dependency on sysinit.target/start
|  Found dependency on setserial.service/start
|  Found dependency on remote-fs.target/start
|  Found dependency on remote-fs-pre.target/start
|  Found dependency on nfs-server.service/start
|  Breaking ordering cycle by deleting job network.target/start
|  Job network.target/start deleted to break ordering cycle starting with 
nfs-server.service/start

This does not yet affect Debian with this precise configuration as
Debian's nfs-utils package did not yet get systemd units (but I figure
it will at some point, as we really need to get rid of rcS init.d
scripts). (To clarify: such problems happen under sysvinit as well,
but they are a lot harder to see)

setserial's init.d script is very demanding as it both wants to start
in run level "S" (sysinit.target in systemd's mapping) *and* requires
$remote_fs. But we can't start remote file systems that early if we
need NetworkManager for them, this only works with very simple
networking like ifupdown.

I suppose /etc/init.d/setserial wants $remote_fs as it reads stuff
from /var/lib/setserial/ which might potentially be on NFS.

As far as I can see, the most appropriate course here is to provide a
systemd unit for setserial with more fine-grained ordering to relax
the overly harsh "Default-Start: S" (as this really just needs to run
before any getty)

The attached debdiff does that now, by providing a systemd unit with
proper dependencies; it also cleans up some other bits from the
auto-generated LSB service so that it behaves in a cleaner way.

I did not completely replace the init.d script as it has lots of code,
so that unit just calls it. Such an amount of code doesn't really
belong into a conffile, so eventually this should be factored out into
/usr/ somewhere and be called from the SysV, systemd, upstart etc.
scripts. But this will do fine for now -- we reuse the init.d logic
but stop using the very coarse-grained LSB header dependencies which
are too inflexible for more complicated use cases like the above.

Thanks for considering,

Martin

-- 
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)
diff -Nru setserial-2.17/debian/changelog setserial-2.17/debian/changelog
--- setserial-2.17/debian/changelog     2012-07-02 10:22:13.000000000 +0200
+++ setserial-2.17/debian/changelog     2015-05-27 12:08:01.000000000 +0200
@@ -1,3 +1,15 @@
+setserial (2.17-49) UNRELEASED; urgency=medium
+
+  * Add debian/setserial.service systemd unit, mostly to relax the very
+    demanding Before=sysinit.target plus After=remote-fs.target combination
+    resulting from the init.d script's $remote_fs dependency. This causes an
+    insatisfiable dependency loop when using NFS and NetworkManager.
+    (LP: #1452644)
+  * Add dh-systemd build dependency and call dh_systemd_enable in
+    debian/rules.
+
+ -- Martin Pitt <[email protected]>  Wed, 27 May 2015 11:57:47 +0200
+
 setserial (2.17-48) unstable; urgency=low
 
   * new maintainer (Closes: #636122)
diff -Nru setserial-2.17/debian/control setserial-2.17/debian/control
--- setserial-2.17/debian/control       2012-06-22 10:14:10.000000000 +0200
+++ setserial-2.17/debian/control       2015-05-27 12:07:53.000000000 +0200
@@ -2,7 +2,7 @@
 Section: comm
 Priority: extra
 Maintainer: Thorsten Alteholz <[email protected]>
-Build-Depends: debhelper (>= 9), autotools-dev, po-debconf
+Build-Depends: debhelper (>= 9), dh-systemd, autotools-dev, po-debconf
 Standards-Version: 3.9.3.1
 Homepage: http://ftp.mcc.ac.uk/pub/linux/
 
diff -Nru setserial-2.17/debian/rules setserial-2.17/debian/rules
--- setserial-2.17/debian/rules 2012-06-22 10:14:10.000000000 +0200
+++ setserial-2.17/debian/rules 2015-05-27 11:57:46.000000000 +0200
@@ -75,6 +75,7 @@
        dh_installdocs README pcmcia.repair
        dh_installchangelogs
        dh_installdebconf
+       dh_systemd_enable
        dh_strip
        dh_compress
        dh_fixperms
diff -Nru setserial-2.17/debian/setserial.service 
setserial-2.17/debian/setserial.service
--- setserial-2.17/debian/setserial.service     1970-01-01 01:00:00.000000000 
+0100
+++ setserial-2.17/debian/setserial.service     2015-05-27 11:56:12.000000000 
+0200
@@ -0,0 +1,16 @@
+[Unit]
+Documentation=man:setserial(8)
+Description=controls configuration of serial ports
+DefaultDependencies=no
+Before=system-getty.slice shutdown.target
+After=remote-fs.target
+Conflicts=shutdown.target
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/etc/init.d/setserial start
+ExecStop=/etc/init.d/setserial stop
+
+[Install]
+WantedBy=multi-user.target

Attachment: signature.asc
Description: Digital signature

Reply via email to