Package: release.debian.org
Severity: normal
User: release.debian....@packages.debian.org
Usertags: unblock

Ohai,

I would like to upload thinkfan/0.9.3-2 for Stretch, fixing two bugs:
 #758579 (grave) Post Installation, Start Script fails to Initialize
 #850514 (important) daemon args (/etc/default/thinkfan) not in use with systemd

The fix for #758579 is a bit of a workaround for #709384 (debhelper)
and #857452 (init-system-helpers) and triggers an additional
`update-rc.d thinkfan disable` on fresh installations.

To make upgrades identical, I also added code to migrate old START=no entries
in /etc/default/thinkfan to propery disabled sysv services and droped the
whole START=(yes|no) handling from the init script. This part could be safely
be droped at the cost of a slightly degraded user expirience as they would
have to enable the serivice via update-rc.d AND edit /e/d/thinkfan.

The fix for #850514 is quite easy (and also can be dropped), it's just a
EnvironmentFile=-/etc/default/thinkfan to load DAEMON_ARGS.

What do you think?

diffstat:
 NEWS                                              |   11 +++++
 README.Debian                                     |    9 ++--
 changelog                                         |   10 +++++
 patches/rcscripts-drop-start-check.patch          |   35 +++++++++++++++++
 patches/rcscripts-load-defaults-for-systemd.patch |   14 +++++++
 patches/series                                    |    2 +
 thinkfan.lintian-overrides                        |    7 +++
 thinkfan.postinst                                 |   44 ++++++++++++++++++++++
 thinkfan.preinst                                  |   43 +++++++++++++++++++++
 9 files changed, 171 insertions(+), 4 deletions(-)

Thanks in advance
Evgeni

-- System Information:
Debian Release: 9.0
  APT prefers unstable-debug
  APT policy: (500, 'unstable-debug'), (500, 'unstable'), (500, 'testing'), (1, 
'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.9.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
diff --git a/debian/NEWS b/debian/NEWS
new file mode 100644
index 0000000..6dbc4ab
--- /dev/null
+++ b/debian/NEWS
@@ -0,0 +1,11 @@
+thinkfan (0.9.3-2) unstable; urgency=medium
+
+    On systems using SysV init, thinkfan is now enabled and disabled
+    using     update-rc.d and not via the obsolete START=(yes|no) flag
+    in /etc/default/thinkfan. During the upgrade the state from the
+    file is migrated automatically.
+
+    Please refer to README.Debian how to manually manage the service.
+
+ -- Evgeni Golov <evg...@debian.org>  Sun, 12 Mar 2017 09:01:50 +0100
+
diff --git a/debian/README.Debian b/debian/README.Debian
index 2450d4d..47ee31b 100644
--- a/debian/README.Debian
+++ b/debian/README.Debian
@@ -5,10 +5,11 @@ WARNING!
  thinkfan CAN kill your system and is thus disabled by default
 
 If you really want to enable thinkfan, adjust /etc/thinkfan.conf to your
-needs and set START=yes in /etc/default/thinkfan.
+needs and then enable thinkfan in your init system.
 
-If you are using systemd, use “systemctl enable thinkfan.service” — as is
-customary with systemd, thinkfan.service ignores /etc/default/thinkfan.
+If you are using SysV init, use “update-rc.d thinkfan enable”.
+
+If you are using systemd, use “systemctl enable thinkfan.service”.
 
 Additionally, on ThinkPads, you need to load the thinkpad_acpi module with
 fan_control=1, or it will refuse to accept control from thinkfan.
@@ -16,4 +17,4 @@ That's most easily done with a file 
/etc/modprobe.d/thinkfan.conf and the
 following entry in it:
 options thinkpad_acpi fan_control=1
 
- -- Evgeni Golov <evg...@debian.org>  Mon, 09 Nov 2009 11:53:11 +0100
+ -- Evgeni Golov <evg...@debian.org>  Sun, 12 Mar 2017 09:01:50 +0100
diff --git a/debian/changelog b/debian/changelog
index 9c08b1e..e97fac8 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,13 @@
+thinkfan (0.9.3-2) unstable; urgency=medium
+
+  * call update-rc.d thinkfan disable on fresh installs (Closes: #758579)
+  * migrate old installations to a properly disabled sysv service too
+  * drop the old START param from the init script and defaults file
+  * update docs on enabling the service under sysvinit
+  * load daemon args from /e/d/thinkfan when using systemd too (Closes: 
#850514)
+
+ -- Evgeni Golov <evg...@debian.org>  Sun, 12 Mar 2017 18:44:20 +0100
+
 thinkfan (0.9.3-1) unstable; urgency=medium
 
   * Imported Upstream version 0.9.3
diff --git a/debian/patches/rcscripts-drop-start-check.patch 
b/debian/patches/rcscripts-drop-start-check.patch
new file mode 100644
index 0000000..84d8864
--- /dev/null
+++ b/debian/patches/rcscripts-drop-start-check.patch
@@ -0,0 +1,35 @@
+diff --git a/rcscripts/thinkfan.default b/rcscripts/thinkfan.default
+index e8f43ad..dd43d31 100644
+--- a/rcscripts/thinkfan.default
++++ b/rcscripts/thinkfan.default
+@@ -1,8 +1,2 @@
+-# Should thinkfan be started automatically on boot?
+-# Only say "yes" when you know what you are doing, have configured
+-# thinkfan correctly for *YOUR* machine and loaded thinkpad_acpi
+-# with fan_control=1 (if you have a ThinkPad).
+-START=no
+-
+ # Additional startup parameters
+ DAEMON_ARGS="-q"
+diff --git a/rcscripts/thinkfan.init b/rcscripts/thinkfan.init
+index 01f74b4..6361421 100644
+--- a/rcscripts/thinkfan.init
++++ b/rcscripts/thinkfan.init
+@@ -22,7 +22,6 @@ DAEMON_ARGS="-q"
+ # This one is compiled-in, you can't change it here!
+ PIDFILE=/var/run/$NAME.pid
+ SCRIPTNAME=/etc/init.d/$NAME
+-START=no
+ 
+ # Exit if the package is not installed
+ [ -x "$DAEMON" ] || exit 0
+@@ -30,9 +29,6 @@ START=no
+ # Read configuration variable file if it is present
+ [ -r /etc/default/$NAME ] && . /etc/default/$NAME
+ 
+-# Check if daemon is to be started
+-[ "$START" = "yes" ] || exit 0
+-
+ # Load the VERBOSE setting and other rcS variables
+ . /lib/init/vars.sh
+ 
diff --git a/debian/patches/rcscripts-load-defaults-for-systemd.patch 
b/debian/patches/rcscripts-load-defaults-for-systemd.patch
new file mode 100644
index 0000000..79b1534
--- /dev/null
+++ b/debian/patches/rcscripts-load-defaults-for-systemd.patch
@@ -0,0 +1,14 @@
+diff --git a/rcscripts/thinkfan.service b/rcscripts/thinkfan.service
+index 049b88b..e296abc 100644
+--- a/rcscripts/thinkfan.service
++++ b/rcscripts/thinkfan.service
+@@ -4,7 +4,8 @@ After=syslog.target
+ 
+ [Service]
+ Type=forking
+-ExecStart=/usr/sbin/thinkfan
++EnvironmentFile=-/etc/default/thinkfan
++ExecStart=/usr/sbin/thinkfan $DAEMON_ARGS
+ PIDFile=/var/run/thinkfan.pid
+ ExecReload=/bin/kill -HUP $MAINPID
+ 
diff --git a/debian/patches/series b/debian/patches/series
index 055d67b..bde09ec 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,3 @@
 cmake-man.patch
+rcscripts-drop-start-check.patch
+rcscripts-load-defaults-for-systemd.patch
diff --git a/debian/thinkfan.lintian-overrides 
b/debian/thinkfan.lintian-overrides
new file mode 100644
index 0000000..292b9cd
--- /dev/null
+++ b/debian/thinkfan.lintian-overrides
@@ -0,0 +1,7 @@
+# pre-deployment of a disabled service as dh_installinit is
+# not capable to do so for us.
+thinkfan: duplicate-updaterc.d-calls-in-postinst thinkfan
+
+# only called for upgrades from older versions to migrate
+# enabled/disabled state
+thinkfan: preinst-calls-updaterc.d thinkfan
diff --git a/debian/thinkfan.postinst b/debian/thinkfan.postinst
new file mode 100644
index 0000000..5572342
--- /dev/null
+++ b/debian/thinkfan.postinst
@@ -0,0 +1,44 @@
+#!/bin/sh
+# postinst script for thinkfan
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <postinst> `configure' <most-recently-configured-version>
+#        * <old-postinst> `abort-upgrade' <new version>
+#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
+#          <new-version>
+#        * <postinst> `abort-remove'
+#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
+#          <failed-install-package> <version> `removing'
+#          <conflicting-package> <version>
+# for details, see https://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+    configure)
+        if [ -x "/etc/init.d/thinkfan" ] && [ -z "$2" ]; then
+            # Disable the service by default on new installations
+            update-rc.d thinkfan defaults >/dev/null || true
+            update-rc.d thinkfan disable >/dev/null || true
+        fi
+    ;;
+
+    abort-upgrade|abort-remove|abort-deconfigure)
+    ;;
+
+    *)
+        echo "postinst called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/thinkfan.preinst b/debian/thinkfan.preinst
new file mode 100644
index 0000000..e356be7
--- /dev/null
+++ b/debian/thinkfan.preinst
@@ -0,0 +1,43 @@
+#!/bin/sh
+# preinst script for thinkfan
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <new-preinst> `install'
+#        * <new-preinst> `install' <old-version>
+#        * <new-preinst> `upgrade' <old-version>
+#        * <old-preinst> `abort-upgrade' <new-version>
+# for details, see https://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+    install|upgrade)
+        if [ -n "$2" ] && dpkg --compare-versions "$2" lt "0.9.3-2~" && [ -r 
/etc/default/thinkfan ]; then
+            . /etc/default/thinkfan
+            if [ "${START}" != "yes" ]; then
+                # Disable the service if it was disabled via /e/d/thinkfan
+                update-rc.d thinkfan defaults >/dev/null || true
+                update-rc.d thinkfan disable >/dev/null || true
+            fi
+        fi
+    ;;
+
+    abort-upgrade)
+    ;;
+
+    *)
+        echo "preinst called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0

Reply via email to