Merge lp:~azzar1/ubuntu-release-upgrader/fix-1799310 into lp:ubuntu-release-upgrader

Proposed by Andrea Azzarone
Status: Merged
Merged at revision: 3212
Proposed branch: lp:~azzar1/ubuntu-release-upgrader/fix-1799310
Merge into: lp:ubuntu-release-upgrader
Diff against target: 199 lines (+93/-1)
8 files modified
DistUpgrade/DistUpgradeController.py (+21/-0)
DistUpgrade/DistUpgradeView.py (+3/-0)
DistUpgrade/DistUpgradeViewGtk3.py (+24/-0)
DistUpgrade/DistUpgradeViewKDE.py (+20/-0)
DistUpgrade/DistUpgradeViewNonInteractive.py (+2/-0)
DistUpgrade/DistUpgradeViewText.py (+6/-1)
debian/changelog (+16/-0)
debian/control (+1/-0)
To merge this branch: bzr merge lp:~azzar1/ubuntu-release-upgrader/fix-1799310
Reviewer Review Type Date Requested Status
Sebastien Bacher Needs Information
Review via email: mp+361896@code.launchpad.net

Commit message

Ask for confirmation if Livepatch is turned on, and you are upgrading to a version where Livepatch is not available.

To post a comment you must log in.
Revision history for this message
Sebastien Bacher (seb128) wrote :

Thanks for your work, one question. The design image on https://wiki.ubuntu.com/ReleaseUpgrades has a settings button on the bottom left corner, is that omitted on purpose in the implementation? (if so maybe add a comment stating why?)

review: Needs Information
Revision history for this message
Andrea Azzarone (azzar1) wrote :

> Thanks for your work, one question. The design image on
> https://wiki.ubuntu.com/ReleaseUpgrades has a settings button on the bottom
> left corner, is that omitted on purpose in the implementation? (if so maybe
> add a comment stating why?)

The main reasons are:
- atm there is no way to ask software-properties-gtk to open the livepatch tab. We can open tab by numbers and not by name. Considering that we're moving around tabs, using the number is not a good solution.
- I want to keep the diff as small as possible. In particualar I had to add a mechanism to show that button only under Gtk3. Considering the controller/view model of ubuntu-release-upgrader it's not naive as it seems.

Considering these mpt agreed to not show the button for the moment.

Revision history for this message
Sebastien Bacher (seb128) wrote :

(thanks for the reply, also I was just having a look but would prefer if someone from foundations could review/upload so don't bail out just because I commented ;-)

Revision history for this message
Brian Murray (brian-murray) wrote :

I'll test this out today.

Revision history for this message
Brian Murray (brian-murray) wrote :

It's not a blocker for me per se but I thought it worth mentioning that some things don't match what is in the design. The dialog does not morph and the "turn off" dialog does not have the title bar label indicated in the design. Let me know if you want to get this changed or not. If you don't I'll merge it and upload it to the devel release.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'DistUpgrade/DistUpgradeController.py'
2--- DistUpgrade/DistUpgradeController.py 2018-12-11 00:28:15 +0000
3+++ DistUpgrade/DistUpgradeController.py 2019-01-17 14:54:46 +0000
4@@ -22,6 +22,7 @@
5
6 import apt
7 import apt_pkg
8+import distro_info
9 import sys
10 import os
11 import subprocess
12@@ -1151,6 +1152,23 @@
13 self.cache.required_download)
14 return res
15
16+ def _isLivepatchEnabled(self):
17+ return os.path.isfile('/var/snap/canonical-livepatch/common/machine-token')
18+
19+ def askLivepatch(self):
20+ di = distro_info.UbuntuDistroInfo()
21+
22+ if not self._isLivepatchEnabled() or di.is_lts(self.toDist):
23+ return True
24+
25+ version = next((r.version for r in di.get_all("object") if r.series == self.toDist), self.toDist)
26+
27+ res = self._view.askCancelContinueQuestion(None,
28+ _("Livepatch security updates are not available for Ubuntu %s. "
29+ "If you upgrade, Livepatch will turn off.") % version)
30+ return res
31+
32+
33 def _disableAptCronJob(self):
34 if os.path.exists("/etc/cron.daily/apt"):
35 #self._aptCronJobPerms = os.stat("/etc/cron.daily/apt")[ST_MODE]
36@@ -1874,6 +1892,9 @@
37 "autocreated")
38 self.abort()
39
40+ if not self.askLivepatch():
41+ self.abort()
42+
43 # run a "apt-get update" now, its ok to ignore errors,
44 # because
45 # a) we disable any third party sources later
46
47=== modified file 'DistUpgrade/DistUpgradeView.py'
48--- DistUpgrade/DistUpgradeView.py 2018-05-04 13:52:53 +0000
49+++ DistUpgrade/DistUpgradeView.py 2019-01-17 14:54:46 +0000
50@@ -417,6 +417,9 @@
51 def askYesNoQuestion(self, summary, msg, default='No'):
52 " ask a Yes/No question and return True on 'Yes' "
53 pass
54+ def askCancelContinueQuestion(self, summary, msg, default='Cancel'):
55+ " ask a Cancel/Continue question and return True on 'Continue'"
56+ pass
57 def confirmRestart(self):
58 " generic ask about the restart, can be overridden "
59 summary = _("Reboot required")
60
61=== modified file 'DistUpgrade/DistUpgradeViewGtk3.py'
62--- DistUpgrade/DistUpgradeViewGtk3.py 2018-08-01 22:04:28 +0000
63+++ DistUpgrade/DistUpgradeViewGtk3.py 2019-01-17 14:54:46 +0000
64@@ -756,6 +756,30 @@
65 return True
66 return False
67
68+ def askCancelContinueQuestion(self, summary, msg, default='Cancel'):
69+ if summary:
70+ msg = "<big><b>%s</b></big>\n\n%s" % (summary,msg)
71+
72+ dialog = Gtk.MessageDialog(parent=self.window_main,
73+ flags=Gtk.DialogFlags.MODAL,
74+ type=Gtk.MessageType.WARNING,
75+ buttons=Gtk.ButtonsType.NONE)
76+ dialog.set_title("")
77+ dialog.set_markup(msg)
78+ dialog.add_buttons(_('Cancel'), Gtk.ResponseType.CANCEL,
79+ _('Continue'), Gtk.ResponseType.ACCEPT)
80+
81+ if default == 'Cancel':
82+ dialog.set_default_response(Gtk.ResponseType.CANCEL)
83+ else:
84+ dialog.set_default_response(Gtk.ResponseType.ACCEPT)
85+
86+ res = dialog.run()
87+ dialog.destroy()
88+ if res == Gtk.ResponseType.ACCEPT:
89+ return True
90+ return False
91+
92 def confirmRestart(self):
93 self.dialog_restart.set_transient_for(self.window_main)
94 self.dialog_restart.set_title("")
95
96=== modified file 'DistUpgrade/DistUpgradeViewKDE.py'
97--- DistUpgrade/DistUpgradeViewKDE.py 2018-08-29 12:03:28 +0000
98+++ DistUpgrade/DistUpgradeViewKDE.py 2019-01-17 14:54:46 +0000
99@@ -929,6 +929,26 @@
100 return True
101 return False
102
103+ def askCancelContinueQuestion(self, summary, msg, default='Cancel'):
104+ messageBox = QMessageBox(QMessageBox.Warning, summary, msg, QMessageBox.NoButton, self.window_main)
105+ continueButton = messageBox.addButton(QMessageBox.Apply)
106+ cancelButton = messageBox.addButton(QMessageBox.Cancel)
107+ continueButton.setText(_("Continue"))
108+
109+ if default == 'Cancel':
110+ messageBox.setDefaultButton(cancelButton)
111+ else:
112+ messageBox.setDefaultButton(continueButton)
113+
114+ if summary is None:
115+ flags = messageBox.windowFlags()
116+ messageBox.setWindowFlags(flags | Qt.FramelessWindowHint)
117+
118+ answer = messageBox.exec_()
119+ if answer == QMessageBox.Apply:
120+ return True
121+ return False
122+
123 def confirmRestart(self):
124 messageBox = QMessageBox(QMessageBox.Question, _("Restart required"), _("<b><big>Restart the system to complete the upgrade</big></b>"), QMessageBox.NoButton, self.window_main)
125 yesButton = messageBox.addButton(QMessageBox.Yes)
126
127=== modified file 'DistUpgrade/DistUpgradeViewNonInteractive.py'
128--- DistUpgrade/DistUpgradeViewNonInteractive.py 2018-05-04 13:52:53 +0000
129+++ DistUpgrade/DistUpgradeViewNonInteractive.py 2019-01-17 14:54:46 +0000
130@@ -305,6 +305,8 @@
131 #if default.lower() == "no":
132 # return False
133 return True
134+ def askCancelContinueQuestion(self, summary, msg, default='Cancel'):
135+ return True
136 def confirmRestart(self):
137 " generic ask about the restart, can be overridden "
138 logging.debug("confirmRestart() called")
139
140=== modified file 'DistUpgrade/DistUpgradeViewText.py'
141--- DistUpgrade/DistUpgradeViewText.py 2018-05-04 13:52:53 +0000
142+++ DistUpgrade/DistUpgradeViewText.py 2019-01-17 14:54:46 +0000
143@@ -254,7 +254,8 @@
144
145 def askYesNoQuestion(self, summary, msg, default='No'):
146 print()
147- print(twrap(summary))
148+ if summary:
149+ print(twrap(summary))
150 print(twrap(msg))
151 if default == 'No':
152 print(_("Continue [yN] "), end="")
153@@ -271,6 +272,10 @@
154 return False
155 return True
156
157+ def askCancelContinueQuestion(self, summary, msg, default='Cancel'):
158+ return self.askYesNoQuestion(summary, msg,
159+ default='No' if default == 'Cancel' else 'Yes')
160+
161 # FIXME: when we need this most the resolver is writing debug logs
162 # and we redirect stdout/stderr
163 # def processEvents(self):
164
165=== modified file 'debian/changelog'
166--- debian/changelog 2018-12-21 18:21:10 +0000
167+++ debian/changelog 2019-01-17 14:54:46 +0000
168@@ -1,3 +1,19 @@
169+ubuntu-release-upgrader (1:19.04.9) UNRELEASED; urgency=medium
170+
171+ * DistUpgrade/DistUpgradeView.py,
172+ DistUpgrade/DistUpgradeViewGtk3.py,
173+ DistUpgrade/DistUpgradeViewKDE.py,
174+ DistUpgrade/DistUpgradeViewNonInteractive.py,
175+ DistUpgrade/DistUpgradeViewText.py:
176+ - add askCancelContinueQuestion for all the supported views.
177+ * DistUpgrade/DistUpgradeController.py: Ask for confirmation if Livepatch
178+ is turned on, and you are upgrading to a version where Livepatch is not
179+ available. (LP: #1799310)
180+ * debian/control: add an explicit python3-distro-info dependency to
181+ python3-distupgrade as it is now required by DistUpgradeController.
182+
183+ -- Andrea Azzarone <andrea.azzarone@canonical.com> Thu, 17 Jan 2019 04:16:29 -0800
184+
185 ubuntu-release-upgrader (1:19.04.9) disco; urgency=medium
186
187 * DistUpgrade/xorg_fix_proprietary.py: shebang needs to use python3 not
188
189=== modified file 'debian/control'
190--- debian/control 2018-11-28 18:02:37 +0000
191+++ debian/control 2019-01-17 14:54:46 +0000
192@@ -40,6 +40,7 @@
193 ${misc:Depends},
194 python3-update-manager (>= 1:19.04.2~),
195 python3-apt (>= 0.8.5~),
196+ python3-distro-info,
197 gpgv,
198 lsb-release,
199 sensible-utils

Subscribers

People subscribed via source and target branches