Merge lp:~rbalint/update-manager/lp-1795898-lp-1790670-lp-1072136-bionic into lp:~ubuntu-core-dev/update-manager/bionic

Proposed by Balint Reczey on 2018-10-03
Status: Merged
Merged at revision: 2830
Proposed branch: lp:~rbalint/update-manager/lp-1795898-lp-1790670-lp-1072136-bionic
Merge into: lp:~ubuntu-core-dev/update-manager/bionic
Diff against target: 221 lines (+102/-36)
7 files modified
UpdateManager/Core/UpdateList.py (+7/-2)
UpdateManager/backend/InstallBackendAptdaemon.py (+7/-2)
UpdateManager/backend/__init__.py (+28/-8)
debian/changelog (+14/-0)
tests/test_backend_error.py (+45/-0)
tests/test_pep8.py (+1/-1)
tests/test_update_error.py (+0/-23)
To merge this branch: bzr merge lp:~rbalint/update-manager/lp-1795898-lp-1790670-lp-1072136-bionic
Reviewer Review Type Date Requested Status
Julian Andres Klode 2018-10-04 Approve on 2018-10-04
Brian Murray 2018-10-03 Pending
Review via email: mp+356108@code.launchpad.net
To post a comment you must log in.
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'UpdateManager/Core/UpdateList.py'
2--- UpdateManager/Core/UpdateList.py 2018-03-21 17:41:10 +0000
3+++ UpdateManager/Core/UpdateList.py 2018-10-03 23:24:21 +0000
4@@ -499,7 +499,6 @@
5 if not is_security_update:
6 if self._is_ignored_phased_update(pkg):
7 self.ignored_phased_updates.append(pkg)
8- pkg.mark_keep()
9 continue
10
11 if is_security_update:
12@@ -517,7 +516,13 @@
13 cache.versioned_kernel_pkgs_regexp.match(pkg.name) and
14 not cache.running_kernel_pkgs_regexp.match(pkg.name))):
15 kernel_autoremove_pkgs.append(pkg)
16- pkg.mark_delete()
17+
18+ # perform operations after the loop to not skip packages which
19+ # changed state due to the resolver
20+ for pkg in kernel_autoremove_pkgs:
21+ pkg.mark_delete()
22+ for pkg in self.ignored_phased_updates:
23+ pkg.mark_keep()
24
25 if security_pkgs or upgrade_pkgs:
26 # There's updates available. Initiate the desktop file cache.
27
28=== modified file 'UpdateManager/backend/InstallBackendAptdaemon.py'
29--- UpdateManager/backend/InstallBackendAptdaemon.py 2018-09-17 15:16:31 +0000
30+++ UpdateManager/backend/InstallBackendAptdaemon.py 2018-10-03 23:24:21 +0000
31@@ -49,8 +49,13 @@
32 self.trans_failed_msg = None
33
34 def close(self):
35- if self.button_cancel:
36- self.button_cancel.clicked()
37+ if self.button_cancel and self.button_cancel.get_sensitive():
38+ try:
39+ self.button_cancel.clicked()
40+ except Exception:
41+ # there is not much left to do if the transaction can't be
42+ # canceled
43+ pass
44 return True
45 else:
46 return False
47
48=== modified file 'UpdateManager/backend/__init__.py'
49--- UpdateManager/backend/__init__.py 2018-09-17 15:16:31 +0000
50+++ UpdateManager/backend/__init__.py 2018-10-03 23:24:21 +0000
51@@ -95,6 +95,25 @@
52 self.window_main.start_available(is_cancelled_update)
53
54
55+# try aptdaemon
56+if os.path.exists("/usr/sbin/aptd") \
57+ and "UPDATE_MANAGER_FORCE_BACKEND_SYNAPTIC" not in os.environ:
58+ # check if the gtkwidgets are installed as well
59+ try:
60+ from .InstallBackendAptdaemon import InstallBackendAptdaemon
61+ except ImportError:
62+ import logging
63+ logging.exception("importing aptdaemon")
64+# try synaptic
65+if os.path.exists("/usr/sbin/synaptic") \
66+ and "UPDATE_MANAGER_FORCE_BACKEND_APTDAEMON" not in os.environ:
67+ try:
68+ from .InstallBackendSynaptic import InstallBackendSynaptic
69+ except ImportError:
70+ import logging
71+ logging.exception("importing synaptic")
72+
73+
74 def get_backend(*args, **kwargs):
75 """Select and return a package manager backend."""
76 # try aptdaemon
77@@ -102,16 +121,17 @@
78 "UPDATE_MANAGER_FORCE_BACKEND_SYNAPTIC" not in os.environ):
79 # check if the gtkwidgets are installed as well
80 try:
81- from .InstallBackendAptdaemon import InstallBackendAptdaemon
82 return InstallBackendAptdaemon(*args, **kwargs)
83- except ImportError:
84+ except NameError:
85 import logging
86- logging.exception("importing aptdaemon")
87+ logging.exception("using aptdaemon failed")
88 # try synaptic
89- if (os.path.exists("/usr/sbin/synaptic") and
90- "UPDATE_MANAGER_FORCE_BACKEND_APTDAEMON" not in os.environ):
91- from .InstallBackendSynaptic import InstallBackendSynaptic
92- return InstallBackendSynaptic(*args, **kwargs)
93+ if (os.path.exists("/usr/sbin/synaptic")
94+ and "UPDATE_MANAGER_FORCE_BACKEND_APTDAEMON" not in os.environ):
95+ try:
96+ return InstallBackendSynaptic(*args, **kwargs)
97+ except NameError:
98+ pass
99 # nothing found, raise
100 raise Exception("No working backend found, please try installing "
101- "synaptic or aptdaemon")
102+ "aptdaemon or synaptic")
103
104=== modified file 'debian/changelog'
105--- debian/changelog 2018-09-21 23:45:25 +0000
106+++ debian/changelog 2018-10-03 23:24:21 +0000
107@@ -1,3 +1,17 @@
108+update-manager (1:18.04.11.6) bionic; urgency=medium
109+
110+ * Keep or delete packages after looping over all of them.
111+ This prevents the resolver from changing the packages in the loop resulting
112+ in not keeping some phased packages back from being upgraded. (LP: #1072136)
113+ * Stop lazy import of InstallBackends.
114+ Lazy imports made update-manager crash when an update-manager
115+ update changed the backend API and an updated incompatible backend
116+ was loaded to the not updated running update-manager process. (LP: #1795898)
117+ * Cancel transaction on exit only when Cancel button is active.
118+ Also ignore exception when cancellation fails. (LP: #1790670)
119+
120+ -- Balint Reczey <rbalint@ubuntu.com> Wed, 03 Oct 2018 23:06:18 +0200
121+
122 update-manager (1:18.04.11.5) bionic; urgency=medium
123
124 * Print transaction error and let the user try again applying updates
125
126=== added file 'tests/test_backend_error.py'
127--- tests/test_backend_error.py 1970-01-01 00:00:00 +0000
128+++ tests/test_backend_error.py 2018-10-03 23:24:21 +0000
129@@ -0,0 +1,45 @@
130+#!/usr/bin/python3
131+# -*- Mode: Python; indent-tabs-mode: nil; tab-width: 4; coding: utf-8 -*-
132+
133+import logging
134+import mock
135+import sys
136+import unittest
137+from gettext import gettext as _
138+from mock import patch
139+
140+from UpdateManager.Dialogs import NoUpdatesDialog
141+from UpdateManager.UpdateManager import UpdateManager
142+from UpdateManager.UpdatesAvailable import UpdatesAvailable
143+
144+import os
145+CURDIR = os.path.dirname(os.path.abspath(__file__))
146+
147+
148+class TestBackendError(unittest.TestCase):
149+
150+ def setUp(self):
151+ os.environ['UPDATE_MANAGER_FORCE_BACKEND_APTDAEMON'] = '1'
152+
153+ def clear_environ():
154+ del os.environ['UPDATE_MANAGER_FORCE_BACKEND_APTDAEMON']
155+
156+ self.addCleanup(clear_environ)
157+
158+ @patch('UpdateManager.backend.InstallBackendAptdaemon.update')
159+ def test_backend_error(self, update):
160+ main = mock.MagicMock()
161+ main.datadir = os.path.join(CURDIR, '..', 'data')
162+
163+ from UpdateManager.backend import (InstallBackend, get_backend)
164+ update_backend = get_backend(main, InstallBackend.ACTION_UPDATE)
165+ update.side_effect = lambda: update_backend._action_done(
166+ InstallBackend.ACTION_UPDATE, True, False, "string", "desc")
167+ update_backend.start()
168+ main.start_error.assert_called_once_with(True, "string", "desc")
169+
170+
171+if __name__ == '__main__':
172+ if len(sys.argv) > 1 and sys.argv[1] == "-v":
173+ logging.basicConfig(level=logging.DEBUG)
174+ unittest.main()
175
176=== modified file 'tests/test_pep8.py'
177--- tests/test_pep8.py 2017-08-07 20:54:58 +0000
178+++ tests/test_pep8.py 2018-10-03 23:24:21 +0000
179@@ -6,7 +6,7 @@
180 import unittest
181
182 # pep8 is overdoing it a bit IMO
183-IGNORE_PEP8 = "E265,E402"
184+IGNORE_PEP8 = "E265,E402,W503"
185 IGNORE_FILES = (
186 )
187
188
189=== modified file 'tests/test_update_error.py'
190--- tests/test_update_error.py 2017-08-07 19:42:06 +0000
191+++ tests/test_update_error.py 2018-10-03 23:24:21 +0000
192@@ -44,29 +44,6 @@
193 _("Some software couldn’t be checked for updates."))
194
195
196-class TestBackendError(unittest.TestCase):
197-
198- def setUp(self):
199- os.environ['UPDATE_MANAGER_FORCE_BACKEND_APTDAEMON'] = '1'
200-
201- def clear_environ():
202- del os.environ['UPDATE_MANAGER_FORCE_BACKEND_APTDAEMON']
203-
204- self.addCleanup(clear_environ)
205-
206- @patch('UpdateManager.backend.InstallBackendAptdaemon.'
207- 'InstallBackendAptdaemon.update')
208- def test_backend_error(self, update):
209- main = mock.MagicMock()
210- main.datadir = os.path.join(CURDIR, '..', 'data')
211-
212- update_backend = get_backend(main, InstallBackend.ACTION_UPDATE)
213- update.side_effect = lambda: update_backend._action_done(
214- InstallBackend.ACTION_UPDATE, True, False, "string", "desc")
215- update_backend.start()
216- main.start_error.assert_called_once_with(True, "string", "desc")
217-
218-
219 if __name__ == '__main__':
220 if len(sys.argv) > 1 and sys.argv[1] == "-v":
221 logging.basicConfig(level=logging.DEBUG)

Subscribers

People subscribed via source and target branches