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

Proposed by Balint Reczey
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 Approve
Brian Murray Pending
Review via email: mp+356108@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Julian Andres Klode (juliank) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'UpdateManager/Core/UpdateList.py'
--- UpdateManager/Core/UpdateList.py 2018-03-21 17:41:10 +0000
+++ UpdateManager/Core/UpdateList.py 2018-10-03 23:24:21 +0000
@@ -499,7 +499,6 @@
499 if not is_security_update:499 if not is_security_update:
500 if self._is_ignored_phased_update(pkg):500 if self._is_ignored_phased_update(pkg):
501 self.ignored_phased_updates.append(pkg)501 self.ignored_phased_updates.append(pkg)
502 pkg.mark_keep()
503 continue502 continue
504503
505 if is_security_update:504 if is_security_update:
@@ -517,7 +516,13 @@
517 cache.versioned_kernel_pkgs_regexp.match(pkg.name) and516 cache.versioned_kernel_pkgs_regexp.match(pkg.name) and
518 not cache.running_kernel_pkgs_regexp.match(pkg.name))):517 not cache.running_kernel_pkgs_regexp.match(pkg.name))):
519 kernel_autoremove_pkgs.append(pkg)518 kernel_autoremove_pkgs.append(pkg)
520 pkg.mark_delete()519
520 # perform operations after the loop to not skip packages which
521 # changed state due to the resolver
522 for pkg in kernel_autoremove_pkgs:
523 pkg.mark_delete()
524 for pkg in self.ignored_phased_updates:
525 pkg.mark_keep()
521526
522 if security_pkgs or upgrade_pkgs:527 if security_pkgs or upgrade_pkgs:
523 # There's updates available. Initiate the desktop file cache.528 # There's updates available. Initiate the desktop file cache.
524529
=== modified file 'UpdateManager/backend/InstallBackendAptdaemon.py'
--- UpdateManager/backend/InstallBackendAptdaemon.py 2018-09-17 15:16:31 +0000
+++ UpdateManager/backend/InstallBackendAptdaemon.py 2018-10-03 23:24:21 +0000
@@ -49,8 +49,13 @@
49 self.trans_failed_msg = None49 self.trans_failed_msg = None
5050
51 def close(self):51 def close(self):
52 if self.button_cancel:52 if self.button_cancel and self.button_cancel.get_sensitive():
53 self.button_cancel.clicked()53 try:
54 self.button_cancel.clicked()
55 except Exception:
56 # there is not much left to do if the transaction can't be
57 # canceled
58 pass
54 return True59 return True
55 else:60 else:
56 return False61 return False
5762
=== modified file 'UpdateManager/backend/__init__.py'
--- UpdateManager/backend/__init__.py 2018-09-17 15:16:31 +0000
+++ UpdateManager/backend/__init__.py 2018-10-03 23:24:21 +0000
@@ -95,6 +95,25 @@
95 self.window_main.start_available(is_cancelled_update)95 self.window_main.start_available(is_cancelled_update)
9696
9797
98# try aptdaemon
99if os.path.exists("/usr/sbin/aptd") \
100 and "UPDATE_MANAGER_FORCE_BACKEND_SYNAPTIC" not in os.environ:
101 # check if the gtkwidgets are installed as well
102 try:
103 from .InstallBackendAptdaemon import InstallBackendAptdaemon
104 except ImportError:
105 import logging
106 logging.exception("importing aptdaemon")
107# try synaptic
108if os.path.exists("/usr/sbin/synaptic") \
109 and "UPDATE_MANAGER_FORCE_BACKEND_APTDAEMON" not in os.environ:
110 try:
111 from .InstallBackendSynaptic import InstallBackendSynaptic
112 except ImportError:
113 import logging
114 logging.exception("importing synaptic")
115
116
98def get_backend(*args, **kwargs):117def get_backend(*args, **kwargs):
99 """Select and return a package manager backend."""118 """Select and return a package manager backend."""
100 # try aptdaemon119 # try aptdaemon
@@ -102,16 +121,17 @@
102 "UPDATE_MANAGER_FORCE_BACKEND_SYNAPTIC" not in os.environ):121 "UPDATE_MANAGER_FORCE_BACKEND_SYNAPTIC" not in os.environ):
103 # check if the gtkwidgets are installed as well122 # check if the gtkwidgets are installed as well
104 try:123 try:
105 from .InstallBackendAptdaemon import InstallBackendAptdaemon
106 return InstallBackendAptdaemon(*args, **kwargs)124 return InstallBackendAptdaemon(*args, **kwargs)
107 except ImportError:125 except NameError:
108 import logging126 import logging
109 logging.exception("importing aptdaemon")127 logging.exception("using aptdaemon failed")
110 # try synaptic128 # try synaptic
111 if (os.path.exists("/usr/sbin/synaptic") and129 if (os.path.exists("/usr/sbin/synaptic")
112 "UPDATE_MANAGER_FORCE_BACKEND_APTDAEMON" not in os.environ):130 and "UPDATE_MANAGER_FORCE_BACKEND_APTDAEMON" not in os.environ):
113 from .InstallBackendSynaptic import InstallBackendSynaptic131 try:
114 return InstallBackendSynaptic(*args, **kwargs)132 return InstallBackendSynaptic(*args, **kwargs)
133 except NameError:
134 pass
115 # nothing found, raise135 # nothing found, raise
116 raise Exception("No working backend found, please try installing "136 raise Exception("No working backend found, please try installing "
117 "synaptic or aptdaemon")137 "aptdaemon or synaptic")
118138
=== modified file 'debian/changelog'
--- debian/changelog 2018-09-21 23:45:25 +0000
+++ debian/changelog 2018-10-03 23:24:21 +0000
@@ -1,3 +1,17 @@
1update-manager (1:18.04.11.6) bionic; urgency=medium
2
3 * Keep or delete packages after looping over all of them.
4 This prevents the resolver from changing the packages in the loop resulting
5 in not keeping some phased packages back from being upgraded. (LP: #1072136)
6 * Stop lazy import of InstallBackends.
7 Lazy imports made update-manager crash when an update-manager
8 update changed the backend API and an updated incompatible backend
9 was loaded to the not updated running update-manager process. (LP: #1795898)
10 * Cancel transaction on exit only when Cancel button is active.
11 Also ignore exception when cancellation fails. (LP: #1790670)
12
13 -- Balint Reczey <rbalint@ubuntu.com> Wed, 03 Oct 2018 23:06:18 +0200
14
1update-manager (1:18.04.11.5) bionic; urgency=medium15update-manager (1:18.04.11.5) bionic; urgency=medium
216
3 * Print transaction error and let the user try again applying updates17 * Print transaction error and let the user try again applying updates
418
=== added file 'tests/test_backend_error.py'
--- tests/test_backend_error.py 1970-01-01 00:00:00 +0000
+++ tests/test_backend_error.py 2018-10-03 23:24:21 +0000
@@ -0,0 +1,45 @@
1#!/usr/bin/python3
2# -*- Mode: Python; indent-tabs-mode: nil; tab-width: 4; coding: utf-8 -*-
3
4import logging
5import mock
6import sys
7import unittest
8from gettext import gettext as _
9from mock import patch
10
11from UpdateManager.Dialogs import NoUpdatesDialog
12from UpdateManager.UpdateManager import UpdateManager
13from UpdateManager.UpdatesAvailable import UpdatesAvailable
14
15import os
16CURDIR = os.path.dirname(os.path.abspath(__file__))
17
18
19class TestBackendError(unittest.TestCase):
20
21 def setUp(self):
22 os.environ['UPDATE_MANAGER_FORCE_BACKEND_APTDAEMON'] = '1'
23
24 def clear_environ():
25 del os.environ['UPDATE_MANAGER_FORCE_BACKEND_APTDAEMON']
26
27 self.addCleanup(clear_environ)
28
29 @patch('UpdateManager.backend.InstallBackendAptdaemon.update')
30 def test_backend_error(self, update):
31 main = mock.MagicMock()
32 main.datadir = os.path.join(CURDIR, '..', 'data')
33
34 from UpdateManager.backend import (InstallBackend, get_backend)
35 update_backend = get_backend(main, InstallBackend.ACTION_UPDATE)
36 update.side_effect = lambda: update_backend._action_done(
37 InstallBackend.ACTION_UPDATE, True, False, "string", "desc")
38 update_backend.start()
39 main.start_error.assert_called_once_with(True, "string", "desc")
40
41
42if __name__ == '__main__':
43 if len(sys.argv) > 1 and sys.argv[1] == "-v":
44 logging.basicConfig(level=logging.DEBUG)
45 unittest.main()
046
=== modified file 'tests/test_pep8.py'
--- tests/test_pep8.py 2017-08-07 20:54:58 +0000
+++ tests/test_pep8.py 2018-10-03 23:24:21 +0000
@@ -6,7 +6,7 @@
6import unittest6import unittest
77
8# pep8 is overdoing it a bit IMO8# pep8 is overdoing it a bit IMO
9IGNORE_PEP8 = "E265,E402"9IGNORE_PEP8 = "E265,E402,W503"
10IGNORE_FILES = (10IGNORE_FILES = (
11)11)
1212
1313
=== modified file 'tests/test_update_error.py'
--- tests/test_update_error.py 2017-08-07 19:42:06 +0000
+++ tests/test_update_error.py 2018-10-03 23:24:21 +0000
@@ -44,29 +44,6 @@
44 _("Some software couldn’t be checked for updates."))44 _("Some software couldn’t be checked for updates."))
4545
4646
47class TestBackendError(unittest.TestCase):
48
49 def setUp(self):
50 os.environ['UPDATE_MANAGER_FORCE_BACKEND_APTDAEMON'] = '1'
51
52 def clear_environ():
53 del os.environ['UPDATE_MANAGER_FORCE_BACKEND_APTDAEMON']
54
55 self.addCleanup(clear_environ)
56
57 @patch('UpdateManager.backend.InstallBackendAptdaemon.'
58 'InstallBackendAptdaemon.update')
59 def test_backend_error(self, update):
60 main = mock.MagicMock()
61 main.datadir = os.path.join(CURDIR, '..', 'data')
62
63 update_backend = get_backend(main, InstallBackend.ACTION_UPDATE)
64 update.side_effect = lambda: update_backend._action_done(
65 InstallBackend.ACTION_UPDATE, True, False, "string", "desc")
66 update_backend.start()
67 main.start_error.assert_called_once_with(True, "string", "desc")
68
69
70if __name__ == '__main__':47if __name__ == '__main__':
71 if len(sys.argv) > 1 and sys.argv[1] == "-v":48 if len(sys.argv) > 1 and sys.argv[1] == "-v":
72 logging.basicConfig(level=logging.DEBUG)49 logging.basicConfig(level=logging.DEBUG)

Subscribers

People subscribed via source and target branches