--- Begin Message ---
Package: release.debian.org
Severity: normal
User: release.debian.org@packages.debian.org
Usertags: unblock
Please unblock package unattended-upgrades
The version 0.93.1+nmu1 fixes bug #809669. The debdiff is attached.
I used the fix proposed in the bug report in the NMU. It's based on the
work by Louis Bouchard plus actually includes the fix which was missing
in his debdiff. I also adjusted the version to be correct for an NMU.
I reproduced the bug and tested the fix using a VM with a separate /var.
Every thing worked as expected.
Gaudenz
unblock unattended-upgrades/0.93.1+nmu1
-- System Information:
Debian Release: 9.0
APT prefers testing-proposed-updates
APT policy: (500, 'testing-proposed-updates'), (500, 'testing'), (100, 'unstable'), (1, 'experimental')
Architecture: amd64
(x86_64)
Foreign Architectures: i386
Kernel: Linux 4.9.0-2-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=de_CH.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
diff -Nru unattended-upgrades-0.93.1/debian/changelog unattended-upgrades-0.93.1+nmu1/debian/changelog
--- unattended-upgrades-0.93.1/debian/changelog 2016-12-11 11:31:26.000000000 +0100
+++ unattended-upgrades-0.93.1+nmu1/debian/changelog 2017-05-06 19:42:14.000000000 +0200
@@ -1,3 +1,37 @@
+unattended-upgrades (0.93.1+nmu1) unstable; urgency=medium
+
+ * Non-maintainer upload.
+
+ [ Louis Bouchard ]
+ * Fix the unattended-upgrades.service unit not correctly working:
+ - d/rules : Remove the override_dh_installinit. The stop option is no longer
+ available so the command falls back to default. This is the normal
+ behavior so the override is not required
+ - d/unattended-upgrades.init : Add Default-Start runlevels, otherwise the
+ unattended-upgrades.service unit cannot be enabled on boot
+ - d/postinst : Cleanup the stop symlinks created by the wrong
+ override_dh_installinit. Without that, the systemd unit cannot be
+ enabled correctly.
+ Force disable the service before deb-systemd-helper runs so the old
+ symlink is not left dangling (workaround for Debian Bug #797108).
+ Force enable and start of the systemd unit to work around Debian Bug
+ #797108 which fails to enable systemd units correctly when WantedBy=
+ statement is changed which is the case here.
+ - d/unattended-upgrades.service : Fix the service so it runs correctly on
+ shutdown :
+ Remove DefaultDependencies=no : Breaks normal shutdown dependencies
+ Set After= to network.target and local-fs.target. Since our service is
+ now ExecStop, it will run before network and local-fs become
+ unavailable. Add RequiresMountsFor=/var/log /var/run /var/lib /boot :
+ Necessary if /var is a separate file system. Set WantedBy= to
+ multi-user.target
+ - Add DEP8 tests to verify the following :
+ Verify that the unattended-upgrades.service unit is enabled and started.
+ Verify that InstallOnShutdown works when configured.
+ (Closes: #809669)
+
+ -- Gaudenz Steinlin <gaudenz@debian.org> Sat, 06 May 2017 19:42:14 +0200
+
unattended-upgrades (0.93.1) unstable; urgency=medium
[ Brian Murray ]
diff -Nru unattended-upgrades-0.93.1/debian/postinst unattended-upgrades-0.93.1+nmu1/debian/postinst
--- unattended-upgrades-0.93.1/debian/postinst 2016-12-11 11:31:26.000000000 +0100
+++ unattended-upgrades-0.93.1+nmu1/debian/postinst 2017-05-06 19:41:53.000000000 +0200
@@ -61,6 +61,20 @@
&& [ -f /etc/rc6.d/S[0-9][0-9]unattended-upgrades ] ; then
update-rc.d -f unattended-upgrades remove
fi
+ # Recover from broken dh_installinit override in versions < 0.93.1+nmu1
+ if dpkg --compare-versions "$2" lt "0.93.1+nmu1"; then
+ if [ -f /etc/rc0.d/K[0-9][0-9]unattended-upgrades ] \
+ && [ -f /etc/rc6.d/K[0-9][0-9]unattended-upgrades ] ; then
+ update-rc.d -f unattended-upgrades remove
+ fi
+ # If running systemd, explicitely disable the service otherwise
+ # the shutdown.target symlink will remain (See Debian Bug #797108)
+ if [ -d /run/systemd/system ]; then
+ if deb-systemd-helper --quiet was-enabled unattended-upgrades.service; then
+ deb-systemd-helper disable unattended-upgrades.service >/dev/null || true
+ fi
+ fi
+ fi
;;
abort-upgrade|abort-remove|abort-deconfigure)
@@ -77,6 +91,21 @@
#DEBHELPER#
+# Explicitly enable and start the service. Debian Bug #797108 for
+# deb-systemd-helper fails to correctly enable the unit. It checks for
+# enablement using the content of the WantedBy= which has changed so it
+# sees the service as disable and will not enable it.
+case "$1" in
+ configure)
+ if dpkg --compare-versions "$2" lt "0.93.1+nmu1" \
+ && [ -d /run/systemd/system ]; then
+ # workaround systemd bug with enable --now which
+ # fails to start the unit
+ systemctl enable unattended-upgrades || true
+ systemctl start unattended-upgrades || true
+ fi
+ ;;
+esac
exit 0
diff -Nru unattended-upgrades-0.93.1/debian/rules unattended-upgrades-0.93.1+nmu1/debian/rules
--- unattended-upgrades-0.93.1/debian/rules 2016-12-11 11:31:26.000000000 +0100
+++ unattended-upgrades-0.93.1+nmu1/debian/rules 2017-05-06 12:57:12.000000000 +0200
@@ -28,8 +28,3 @@
rm -f $$f.py; \
done
$(PYTHON) setup.py clean -a
-
-override_dh_installinit:
- # we do not want to run the init script in the postinst/prerm, its
- # really only useful on shutdown, see Debian bug #645919
- dh_installinit $@ --no-start -- stop 10 0 6 .
diff -Nru unattended-upgrades-0.93.1/debian/tests/control unattended-upgrades-0.93.1+nmu1/debian/tests/control
--- unattended-upgrades-0.93.1/debian/tests/control 2016-12-11 11:31:26.000000000 +0100
+++ unattended-upgrades-0.93.1+nmu1/debian/tests/control 2017-05-06 12:57:12.000000000 +0200
@@ -1,2 +1,3 @@
-Tests: run-tests
+Tests: run-tests test-systemd.py
Depends: @, @builddeps@
+Restrictions: needs-root, isolation-container
diff -Nru unattended-upgrades-0.93.1/debian/tests/test-systemd.py unattended-upgrades-0.93.1+nmu1/debian/tests/test-systemd.py
--- unattended-upgrades-0.93.1/debian/tests/test-systemd.py 1970-01-01 01:00:00.000000000 +0100
+++ unattended-upgrades-0.93.1+nmu1/debian/tests/test-systemd.py 2017-05-06 12:57:12.000000000 +0200
@@ -0,0 +1,80 @@
+#!/usr/bin/python3
+
+import os
+import sys
+import subprocess
+
+
+def test_systemd_service():
+ '''
+ Verify that the unattended-upgrades.service unit is started
+ correctly. The unit must be started in order for the ExecStop=
+ to work correctly
+ '''
+ Service = 'unattended-upgrades.service'
+ try:
+ subprocess.check_output(['systemctl', '--quiet', 'is-active', Service])
+ except subprocess.CalledProcessError:
+ out = subprocess.getoutput(
+ 'systemctl status unattended-upgrades.service')
+ print('test_systemd_service() FAILED\n%s' % out)
+ return False
+ return True
+
+
+def enable_install_on_shutdown():
+ '''
+ Enable InstallOnShutdown to verify that the command runs correctly
+ upon reboot
+ '''
+ apt_conf_file = '/etc/apt/apt.conf.d/50unattended-upgrades'
+ param = 'Unattended-Upgrade::InstallOnShutdown'
+ sed_cmd = 's/\/\/%s/%s/' % (param, param)
+
+ try:
+ subprocess.check_output(['/bin/sed', '-i', sed_cmd, apt_conf_file])
+ except subprocess.CalledProcessError:
+ print("Unable to edit %s" % apt_conf_file)
+ return False
+ return True
+
+
+def check_log_files():
+ '''
+ Verify that the logfiles are correctly produced by the InstallOnShutdown
+ run upon reboot. This will confirm that it did run correctly when we
+ rebooted.
+ '''
+ logdir = '/var/log/unattended-upgrades/'
+ logfiles = ['unattended-upgrades.log', 'unattended-upgrades-shutdown.log']
+
+ for file in logfiles:
+ if not os.path.exists(logdir + file):
+ print("File missing : %s" % (logdir + file))
+ return False
+ return True
+
+
+if __name__ == '__main__':
+ autopkgtest_reboot_mark = os.getenv('AUTOPKGTEST_REBOOT_MARK')
+
+ if autopkgtest_reboot_mark is None:
+ if not test_systemd_service():
+ sys.exit(1)
+
+ if enable_install_on_shutdown():
+ print('Rebooting to test InstallOnShutdown...')
+ subprocess.check_call(['/tmp/autopkgtest-reboot',
+ 'InstallOnShutdown'])
+ else:
+ sys.exit(1)
+
+ if autopkgtest_reboot_mark == 'InstallOnShutdown':
+ if not check_log_files():
+ print("InstallOnShutdown did not run")
+ sys.exit(1)
+ else:
+ print('Invalid autopkgtest_reboot_mark value')
+ sys.exit(1)
+
+ sys.exit(0)
diff -Nru unattended-upgrades-0.93.1/debian/unattended-upgrades.init unattended-upgrades-0.93.1+nmu1/debian/unattended-upgrades.init
--- unattended-upgrades-0.93.1/debian/unattended-upgrades.init 2016-12-11 11:31:26.000000000 +0100
+++ unattended-upgrades-0.93.1+nmu1/debian/unattended-upgrades.init 2017-05-06 12:57:12.000000000 +0200
@@ -4,7 +4,7 @@
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Provides: unattended-upgrade-shutdown-check
-# Default-Start:
+# Default-Start: 2 3 4 5
# Default-Stop: 0 6
# Short-Description: Check if unattended upgrades are being applied
# Description: Check if unattended upgrades are being applied
diff -Nru unattended-upgrades-0.93.1/debian/unattended-upgrades.service unattended-upgrades-0.93.1+nmu1/debian/unattended-upgrades.service
--- unattended-upgrades-0.93.1/debian/unattended-upgrades.service 2016-12-11 11:31:26.000000000 +0100
+++ unattended-upgrades-0.93.1+nmu1/debian/unattended-upgrades.service 2017-05-06 18:54:41.000000000 +0200
@@ -1,13 +1,14 @@
[Unit]
Description=Unattended Upgrades Shutdown
-DefaultDependencies=no
-Before=shutdown.target reboot.target halt.target network.target local-fs.target
+After=network.target local-fs.target
+RequiresMountsFor=/var/log /var/run /var/lib /boot
Documentation=man:unattended-upgrade(8)
[Service]
Type=oneshot
-ExecStart=/usr/share/unattended-upgrades/unattended-upgrade-shutdown
-TimeoutStartSec=900
+RemainAfterExit=yes
+ExecStop=/usr/share/unattended-upgrades/unattended-upgrade-shutdown
+TimeoutStopSec=900
[Install]
-WantedBy=shutdown.target
+WantedBy=multi-user.target
--- End Message ---