Merge ~lamoura/update-notifier:treat-security-updates-as-separate-bucket into update-notifier:master
- Git
- lp:~lamoura/update-notifier
- treat-security-updates-as-separate-bucket
- Merge into master
Status: | Merged |
---|---|
Merged at revision: | 75c314cd65ab516f47625cb051666c12985fd796 |
Proposed branch: | ~lamoura/update-notifier:treat-security-updates-as-separate-bucket |
Merge into: | update-notifier:master |
Diff against target: |
416 lines (+72/-68) 3 files modified
data/apt_check.py (+35/-23) debian/changelog (+4/-0) tests/test_motd.py (+33/-45) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Chad Smith (community) | Approve | ||
Ubuntu Core Development Team | Pending | ||
Review via email:
|
Commit message
Description of the change
Currently, we display packaging count for both ESM and security updates. However, if the package upgrade comes from ESM, we still count it as a security update. This can provide confusing messages to users, since we don't say in that message that security updates contain both source of packages. To better handle that, we are now only treating as security updates only security upgrades
that are not related to ESM packages.
For example, this will turn this message:
5 updates can be installed immediately.
5 of these updates are UA Apps: ESM security updates.
5 of these updates are security updates
Into:
5 updates can be installed immediately.
5 of these updates are UA Apps: ESM security updates.
Another example, we turn this message from:
8 updates can be installed immediately.
5 of these updates are UA Apps: ESM security updates.
8 of these updates are security updates
to:
8 updates can be installed immediately.
5 of these updates are UA Apps: ESM security updates.
3 of these updates are standard security updates

Chad Smith (chad.smith) wrote : | # |
Thanks for the commit message update here. +1. I'll let you sort debian/changelog requirements separately
Preview Diff
1 | diff --git a/data/apt_check.py b/data/apt_check.py |
2 | index f984e45..2f2bb3d 100755 |
3 | --- a/data/apt_check.py |
4 | +++ b/data/apt_check.py |
5 | @@ -70,10 +70,12 @@ def _isESMUpgrade(ver, esm_origin): |
6 | |
7 | |
8 | def isESMAppsUpgrade(ver): |
9 | + " check if the given version is a ESM Apps upgrade " |
10 | return _isESMUpgrade(ver, esm_origin=ESM_APPS_ORIGIN) |
11 | |
12 | |
13 | def isESMInfraUpgrade(ver): |
14 | + " check if the given version is a ESM Infra upgrade " |
15 | return _isESMUpgrade(ver, esm_origin=ESM_INFRA_ORIGIN) |
16 | |
17 | |
18 | @@ -85,6 +87,7 @@ def write_package_names(outstream, cache, depcache): |
19 | |
20 | |
21 | def is_esm_distro(): |
22 | + " check if the current distro is ESM or not " |
23 | ubuntu_distro = distro_info.UbuntuDistroInfo() |
24 | |
25 | is_esm_supported = bool( |
26 | @@ -99,16 +102,18 @@ def is_esm_distro(): |
27 | |
28 | |
29 | def is_lts_distro(): |
30 | + " check if the current distro is LTS or not" |
31 | return distro_info.UbuntuDistroInfo().is_lts(DISTRO) |
32 | |
33 | |
34 | def _output_esm_package_count(outstream, service_type, esm_pkg_count): |
35 | + " output the number of packages upgrades related to esm service " |
36 | if esm_pkg_count > 0: |
37 | outstream.write("\n") |
38 | outstream.write(gettext.dngettext("update-notifier", |
39 | "%d of these updates " |
40 | - "are UA %s: ESM " |
41 | - "security updates.", |
42 | + "is an UA %s: ESM " |
43 | + "security update.", |
44 | "%d of these updates " |
45 | "are UA %s: ESM " |
46 | "security updates.", |
47 | @@ -119,12 +124,13 @@ def _output_esm_package_count(outstream, service_type, esm_pkg_count): |
48 | def _output_esm_package_alert( |
49 | outstream, service_type, disabled_pkg_count |
50 | ): |
51 | + " output the number of upgradable packages if esm service was enabled " |
52 | outstream.write("\n") |
53 | if disabled_pkg_count > 0: |
54 | outstream.write("\n") |
55 | outstream.write(gettext.dngettext("update-notifier", |
56 | "%i additional security " |
57 | - "updates can be applied " |
58 | + "update can be applied " |
59 | "with UA %s: ESM\nLearn " |
60 | "more about enabling UA " |
61 | "%s: ESM service at " |
62 | @@ -159,9 +165,9 @@ def write_human_readable_summary(outstream, upgrades, security_updates, |
63 | disabled_esm_infra_updates, |
64 | disabled_esm_apps_updates): |
65 | |
66 | + " write out human summary summary to outstream " |
67 | esm_distro = is_esm_distro() |
68 | lts_distro = is_lts_distro() |
69 | - " write out human summary summary to outstream " |
70 | if have_esm_infra is not None and esm_distro: |
71 | if have_esm_infra: |
72 | outstream.write(gettext.dgettext("update-notifier", |
73 | @@ -173,28 +179,30 @@ def write_human_readable_summary(outstream, upgrades, security_updates, |
74 | "UA Infra: Extended " |
75 | "Security Maintenance (ESM) is " |
76 | "not enabled.")) |
77 | - outstream.write("\n\n") |
78 | - |
79 | - outstream.write( |
80 | - gettext.dngettext("update-notifier", |
81 | - "%i updates can be installed immediately.", |
82 | - "%i updates can be installed immediately.", |
83 | - upgrades) % upgrades |
84 | - ) |
85 | + if upgrades > 0: |
86 | + outstream.write("\n\n") |
87 | + if upgrades > 0: |
88 | + outstream.write( |
89 | + gettext.dngettext("update-notifier", |
90 | + "%i update can be applied immediately.", |
91 | + "%i updates can be applied immediately.", |
92 | + upgrades) % upgrades |
93 | + ) |
94 | |
95 | _output_esm_package_count( |
96 | outstream, service_type="Infra", esm_pkg_count=esm_infra_updates) |
97 | _output_esm_package_count( |
98 | outstream, service_type="Apps", esm_pkg_count=esm_apps_updates) |
99 | |
100 | - outstream.write("\n") |
101 | - outstream.write(gettext.dngettext("update-notifier", |
102 | - "%i of these updates is a " |
103 | - "security update.", |
104 | - "%i of these updates are " |
105 | - "security updates.", |
106 | - security_updates) % |
107 | - security_updates) |
108 | + if security_updates > 0: |
109 | + outstream.write("\n") |
110 | + outstream.write(gettext.dngettext("update-notifier", |
111 | + "%i of these updates is a " |
112 | + "standard security update.", |
113 | + "%i of these updates are " |
114 | + "standard security updates.", |
115 | + security_updates) % |
116 | + security_updates) |
117 | |
118 | if any([upgrades, security_updates, esm_infra_updates, esm_apps_updates]): |
119 | outstream.write("\n") |
120 | @@ -233,14 +241,17 @@ def has_disabled_esm_security_update(depcache, pkg, esm_origin): |
121 | |
122 | |
123 | def has_disabled_esm_apps_security_update(depcache, pkg): |
124 | + " check if we have a disabled ESM Apps security update " |
125 | return has_disabled_esm_security_update(depcache, pkg, ESM_APPS_ORIGIN) |
126 | |
127 | |
128 | def has_disabled_esm_infra_security_update(depcache, pkg): |
129 | + " check if we have a disabled ESM Infra security update " |
130 | return has_disabled_esm_security_update(depcache, pkg, ESM_INFRA_ORIGIN) |
131 | |
132 | |
133 | def has_esm_service(cache, depcache, esm_origin): |
134 | + " check if we have an enabled ESM service in the machine " |
135 | have_esm = None |
136 | for file in cache.file_list: |
137 | origin = file.origin |
138 | @@ -338,8 +349,10 @@ def run(options=None): |
139 | esm_apps_updates += 1 |
140 | elif have_esm_infra and isESMInfraUpgrade(cand_ver): |
141 | esm_infra_updates += 1 |
142 | + else: |
143 | + security_updates += 1 |
144 | + |
145 | upgrades += 1 |
146 | - security_updates += 1 |
147 | continue |
148 | |
149 | # check to see if the update is a phased one |
150 | @@ -367,8 +380,7 @@ def run(options=None): |
151 | esm_apps_updates += 1 |
152 | elif have_esm_infra and isESMInfraUpgrade(cand_ver): |
153 | esm_infra_updates += 1 |
154 | - |
155 | - if isSecurityUpgrade(ver): |
156 | + elif isSecurityUpgrade(ver): |
157 | security_updates += 1 |
158 | break |
159 | |
160 | diff --git a/debian/changelog b/debian/changelog |
161 | index 5d860ba..0383f94 100644 |
162 | --- a/debian/changelog |
163 | +++ b/debian/changelog |
164 | @@ -5,6 +5,10 @@ update-notifier (3.192.41) hirsute; urgency=medium |
165 | and only display alerts if the distro is ESM. (LP: #1924766) |
166 | - Do not display a count of ESM packages if the system does not have ESM |
167 | enabled. (LP: #1883315) |
168 | + - Make distinction between standard security updates and ESM updates |
169 | + when performing package counts. (LP: #1926208) |
170 | + - use 'applied' instead of 'installed', redact 0 of these updates are |
171 | + security updates, and correct singular messages |
172 | * debian/control: Add a dependency on python3-distro-info. |
173 | |
174 | -- Brian Murray <brian@ubuntu.com> Mon, 19 Apr 2021 13:47:41 -0700 |
175 | diff --git a/tests/test_motd.py b/tests/test_motd.py |
176 | index f3b982c..335adce 100755 |
177 | --- a/tests/test_motd.py |
178 | +++ b/tests/test_motd.py |
179 | @@ -27,19 +27,16 @@ class TestMotd(unittest.TestCase): |
180 | get_message(upgrades=0, security_updates=0, |
181 | esm_infra_updates=0, esm_apps_updates=0, |
182 | have_esm_infra=False, have_esm_apps=False, |
183 | - disabled_esm_infra_updates=23, |
184 | + disabled_esm_infra_updates=1, |
185 | disabled_esm_apps_updates=0), |
186 | textwrap.dedent( |
187 | """\ |
188 | UA Infra: Extended Security Maintenance (ESM) is not enabled. |
189 | |
190 | - 0 updates can be installed immediately. |
191 | - 0 of these updates are security updates. |
192 | - |
193 | Enable UA Apps: ESM to receive additional future security updates. |
194 | See https://ubuntu.com/esm or run: sudo ua status |
195 | |
196 | - 23 additional security updates can be applied with UA Infra: ESM |
197 | + 1 additional security update can be applied with UA Infra: ESM |
198 | Learn more about enabling UA Infra: ESM service at https://ubuntu.com/esm |
199 | """)) |
200 | |
201 | @@ -49,7 +46,7 @@ class TestMotd(unittest.TestCase): |
202 | self, _m_esm_distro, _m_is_lts |
203 | ): |
204 | self.assertEqual( |
205 | - get_message(upgrades=15, security_updates=7, |
206 | + get_message(upgrades=15, security_updates=1, |
207 | esm_infra_updates=0, esm_apps_updates=0, |
208 | have_esm_infra=False, have_esm_apps=False, |
209 | disabled_esm_infra_updates=23, |
210 | @@ -58,8 +55,8 @@ class TestMotd(unittest.TestCase): |
211 | """\ |
212 | UA Infra: Extended Security Maintenance (ESM) is not enabled. |
213 | |
214 | - 15 updates can be installed immediately. |
215 | - 7 of these updates are security updates. |
216 | + 15 updates can be applied immediately. |
217 | + 1 of these updates is a standard security update. |
218 | To see these additional updates run: apt list --upgradable |
219 | |
220 | Enable UA Apps: ESM to receive additional future security updates. |
221 | @@ -84,8 +81,8 @@ class TestMotd(unittest.TestCase): |
222 | """\ |
223 | UA Infra: Extended Security Maintenance (ESM) is not enabled. |
224 | |
225 | - 15 updates can be installed immediately. |
226 | - 7 of these updates are security updates. |
227 | + 15 updates can be applied immediately. |
228 | + 7 of these updates are standard security updates. |
229 | To see these additional updates run: apt list --upgradable |
230 | |
231 | Enable UA Apps: ESM to receive additional future security updates. |
232 | @@ -110,8 +107,7 @@ class TestMotd(unittest.TestCase): |
233 | """\ |
234 | UA Infra: Extended Security Maintenance (ESM) is not enabled. |
235 | |
236 | - 15 updates can be installed immediately. |
237 | - 0 of these updates are security updates. |
238 | + 15 updates can be applied immediately. |
239 | To see these additional updates run: apt list --upgradable |
240 | |
241 | Enable UA Apps: ESM to receive additional future security updates. |
242 | @@ -136,9 +132,6 @@ class TestMotd(unittest.TestCase): |
243 | """\ |
244 | UA Infra: Extended Security Maintenance (ESM) is not enabled. |
245 | |
246 | - 0 updates can be installed immediately. |
247 | - 0 of these updates are security updates. |
248 | - |
249 | Enable UA Apps: ESM to receive additional future security updates. |
250 | See https://ubuntu.com/esm or run: sudo ua status |
251 | |
252 | @@ -161,9 +154,8 @@ class TestMotd(unittest.TestCase): |
253 | """\ |
254 | UA Infra: Extended Security Maintenance (ESM) is enabled. |
255 | |
256 | - 35 updates can be installed immediately. |
257 | + 35 updates can be applied immediately. |
258 | 13 of these updates are UA Infra: ESM security updates. |
259 | - 0 of these updates are security updates. |
260 | To see these additional updates run: apt list --upgradable |
261 | |
262 | Enable UA Apps: ESM to receive additional future security updates. |
263 | @@ -185,9 +177,9 @@ class TestMotd(unittest.TestCase): |
264 | """\ |
265 | UA Infra: Extended Security Maintenance (ESM) is enabled. |
266 | |
267 | - 47 updates can be installed immediately. |
268 | + 47 updates can be applied immediately. |
269 | 13 of these updates are UA Infra: ESM security updates. |
270 | - 7 of these updates are security updates. |
271 | + 7 of these updates are standard security updates. |
272 | To see these additional updates run: apt list --upgradable |
273 | |
274 | Enable UA Apps: ESM to receive additional future security updates. |
275 | @@ -209,9 +201,6 @@ class TestMotd(unittest.TestCase): |
276 | """\ |
277 | UA Infra: Extended Security Maintenance (ESM) is enabled. |
278 | |
279 | - 0 updates can be installed immediately. |
280 | - 0 of these updates are security updates. |
281 | - |
282 | 10 additional security updates can be applied with UA Apps: ESM |
283 | Learn more about enabling UA Apps: ESM service at https://ubuntu.com/esm |
284 | """)) |
285 | @@ -222,7 +211,7 @@ class TestMotd(unittest.TestCase): |
286 | self, _m_esm_distro, _m_is_lts |
287 | ): |
288 | self.assertEqual( |
289 | - get_message(upgrades=30, security_updates=18, |
290 | + get_message(upgrades=30, security_updates=0, |
291 | esm_infra_updates=15, esm_apps_updates=15, |
292 | have_esm_infra=True, have_esm_apps=True, |
293 | disabled_esm_infra_updates=0, |
294 | @@ -231,10 +220,9 @@ class TestMotd(unittest.TestCase): |
295 | """ |
296 | UA Infra: Extended Security Maintenance (ESM) is enabled. |
297 | |
298 | - 30 updates can be installed immediately. |
299 | + 30 updates can be applied immediately. |
300 | 15 of these updates are UA Infra: ESM security updates. |
301 | 15 of these updates are UA Apps: ESM security updates. |
302 | - 18 of these updates are security updates. |
303 | To see these additional updates run: apt list --upgradable |
304 | """).lstrip()) |
305 | |
306 | @@ -244,7 +232,7 @@ class TestMotd(unittest.TestCase): |
307 | self, _m_esm_distro, _m_is_lts |
308 | ): |
309 | self.assertEqual( |
310 | - get_message(upgrades=30, security_updates=18, |
311 | + get_message(upgrades=30, security_updates=12, |
312 | esm_infra_updates=0, esm_apps_updates=15, |
313 | have_esm_infra=False, have_esm_apps=True, |
314 | disabled_esm_infra_updates=0, |
315 | @@ -253,9 +241,9 @@ class TestMotd(unittest.TestCase): |
316 | """ |
317 | UA Infra: Extended Security Maintenance (ESM) is not enabled. |
318 | |
319 | - 30 updates can be installed immediately. |
320 | + 30 updates can be applied immediately. |
321 | 15 of these updates are UA Apps: ESM security updates. |
322 | - 18 of these updates are security updates. |
323 | + 12 of these updates are standard security updates. |
324 | To see these additional updates run: apt list --upgradable |
325 | |
326 | Enable UA Infra: ESM to receive additional future security updates. |
327 | @@ -268,8 +256,8 @@ class TestMotd(unittest.TestCase): |
328 | self, _m_esm_distro, _m_is_lts |
329 | ): |
330 | self.assertEqual( |
331 | - get_message(upgrades=30, security_updates=18, |
332 | - esm_infra_updates=0, esm_apps_updates=15, |
333 | + get_message(upgrades=30, security_updates=15, |
334 | + esm_infra_updates=0, esm_apps_updates=1, |
335 | have_esm_infra=False, have_esm_apps=True, |
336 | disabled_esm_infra_updates=40, |
337 | disabled_esm_apps_updates=0), |
338 | @@ -277,9 +265,9 @@ class TestMotd(unittest.TestCase): |
339 | """ |
340 | UA Infra: Extended Security Maintenance (ESM) is not enabled. |
341 | |
342 | - 30 updates can be installed immediately. |
343 | - 15 of these updates are UA Apps: ESM security updates. |
344 | - 18 of these updates are security updates. |
345 | + 30 updates can be applied immediately. |
346 | + 1 of these updates is an UA Apps: ESM security update. |
347 | + 15 of these updates are standard security updates. |
348 | To see these additional updates run: apt list --upgradable |
349 | |
350 | 40 additional security updates can be applied with UA Infra: ESM |
351 | @@ -301,8 +289,8 @@ class TestMotd(unittest.TestCase): |
352 | """\ |
353 | UA Infra: Extended Security Maintenance (ESM) is not enabled. |
354 | |
355 | - 30 updates can be installed immediately. |
356 | - 18 of these updates are security updates. |
357 | + 30 updates can be applied immediately. |
358 | + 18 of these updates are standard security updates. |
359 | To see these additional updates run: apt list --upgradable |
360 | |
361 | 40 additional security updates can be applied with UA Apps: ESM |
362 | @@ -325,8 +313,8 @@ class TestMotd(unittest.TestCase): |
363 | disabled_esm_apps_updates=0), |
364 | textwrap.dedent( |
365 | """\ |
366 | - 30 updates can be installed immediately. |
367 | - 18 of these updates are security updates. |
368 | + 30 updates can be applied immediately. |
369 | + 18 of these updates are standard security updates. |
370 | To see these additional updates run: apt list --upgradable |
371 | """)) |
372 | |
373 | @@ -343,8 +331,8 @@ class TestMotd(unittest.TestCase): |
374 | disabled_esm_apps_updates=0), |
375 | textwrap.dedent( |
376 | """\ |
377 | - 30 updates can be installed immediately. |
378 | - 18 of these updates are security updates. |
379 | + 30 updates can be applied immediately. |
380 | + 18 of these updates are standard security updates. |
381 | To see these additional updates run: apt list --upgradable |
382 | """)) |
383 | |
384 | @@ -361,8 +349,8 @@ class TestMotd(unittest.TestCase): |
385 | disabled_esm_apps_updates=40), |
386 | textwrap.dedent( |
387 | """\ |
388 | - 30 updates can be installed immediately. |
389 | - 18 of these updates are security updates. |
390 | + 30 updates can be applied immediately. |
391 | + 18 of these updates are standard security updates. |
392 | To see these additional updates run: apt list --upgradable |
393 | """)) |
394 | |
395 | @@ -384,8 +372,8 @@ class TestMotd(unittest.TestCase): |
396 | disabled_esm_apps_updates=40), |
397 | textwrap.dedent( |
398 | """\ |
399 | - 30 updates can be installed immediately. |
400 | - 18 of these updates are security updates. |
401 | + 30 updates can be applied immediately. |
402 | + 18 of these updates are standard security updates. |
403 | To see these additional updates run: apt list --upgradable |
404 | """)) |
405 | |
406 | @@ -402,8 +390,8 @@ class TestMotd(unittest.TestCase): |
407 | disabled_esm_apps_updates=40), |
408 | textwrap.dedent( |
409 | """\ |
410 | - 30 updates can be installed immediately. |
411 | - 18 of these updates are security updates. |
412 | + 30 updates can be applied immediately. |
413 | + 18 of these updates are standard security updates. |
414 | To see these additional updates run: apt list --upgradable |
415 | |
416 | 40 additional security updates can be applied with UA Apps: ESM |
Looks really good. Just a nit about the commit message and don't we also need a second commit with a new debian/changelog entry explaining this change? via dch -i