Merge ~nteodosio/update-manager:focal-ua into update-manager:ubuntu/focal

Proposed by Nathan Teodosio
Status: Merged
Approved by: Sebastien Bacher
Approved revision: 269e3093916f9dde333001e5173aee99cabc9580
Merged at revision: 269e3093916f9dde333001e5173aee99cabc9580
Proposed branch: ~nteodosio/update-manager:focal-ua
Merge into: update-manager:ubuntu/focal
Diff against target: 64 lines (+19/-2)
3 files modified
UpdateManager/Core/MyCache.py (+11/-2)
UpdateManager/UpdateManager.py (+1/-0)
debian/changelog (+7/-0)
Reviewer Review Type Date Requested Status
Sebastien Bacher Approve
Review via email: mp+455612@code.launchpad.net

Description of the change

Fix incorrect available version for Ubuntu Pro updates in unattached case.

Can't run autopkgtests right now: https://irclogs.ubuntu.com/2023/11/15/%23ubuntu-quality.txt. But lines are <80 characters.

Test case
---------

  ua detach --assume-yes && apt install hello
  # Make sure 'apt policy hello' gives non-esm version
  ./update-manager

Select hello package and verify that "Available version" is an esm one, and not the same as the "Installed version".

Also verify that non-pro packages' "Available version" show something sensible and didn't regress.

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

Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/UpdateManager/Core/MyCache.py b/UpdateManager/Core/MyCache.py
2index e86c9b3..7639429 100644
3--- a/UpdateManager/Core/MyCache.py
4+++ b/UpdateManager/Core/MyCache.py
5@@ -81,6 +81,7 @@ class MyCache(DistUpgrade.DistUpgradeCache.MyCache):
6 self._initDepCache()
7 self.all_changes = {}
8 self.all_news = {}
9+ self.pro_versions = {}
10 # on broken packages, try to fix via saveDistUpgrade()
11 if self._depcache.broken_count > 0:
12 self.saveDistUpgrade()
13@@ -424,14 +425,22 @@ class MyCache(DistUpgrade.DistUpgradeCache.MyCache):
14 "Please check your Internet connection.")
15 self.all_changes[name] += error_message
16
17+ # If the machine is not attached to Ubuntu Pro, Update Manager advertises
18+ # the upgrades that would be available if it were attached.
19+ # As that is unbeknownst to Apt, we need this map to show the correct
20+ # version of each upgradable-if-pro-subscribed package.
21+ def create_pro_cache(self, pro_pkgs):
22+ for (name, version, _, _) in pro_pkgs:
23+ self.pro_versions[name] = version
24+
25 def get_changelog(self, name):
26 " get the changelog file from the changelog location "
27 origins = self[name].candidate.origins
28+ version = self.pro_versions.get(name, self[name].candidate.version)
29 self.all_changes[name] = _("Changes for %s versions:\n"
30 "Installed version: %s\n"
31 "Available version: %s\n\n") % \
32- (name, getattr(self[name].installed, "version", None),
33- self[name].candidate.version)
34+ (name, getattr(self[name].installed, "version", None), version)
35 if self.CHANGELOG_ORIGIN not in [o.origin for o in origins]:
36 self._fetch_changelog_for_third_party_package(name, origins)
37 return
38diff --git a/UpdateManager/UpdateManager.py b/UpdateManager/UpdateManager.py
39index 16c3a4a..eef9fce 100644
40--- a/UpdateManager/UpdateManager.py
41+++ b/UpdateManager/UpdateManager.py
42@@ -298,6 +298,7 @@ class UpdateManager(Gtk.Window):
43 self.ua_security_packages.append(
44 (name, version, size, downloadable)
45 )
46+ self.cache.create_pro_cache(self.ua_security_packages)
47
48 def _make_available_pane(self, install_count, need_reboot=False,
49 cancelled_update=False, error_occurred=False):
50diff --git a/debian/changelog b/debian/changelog
51index b8afa70..7354a85 100644
52--- a/debian/changelog
53+++ b/debian/changelog
54@@ -1,3 +1,10 @@
55+update-manager (1:20.04.10.18) focal; urgency=medium
56+
57+ * Fix incorrect available version for Ubuntu Pro updates in unattached case
58+ (LP: #2043425).
59+
60+ -- Nathan Pratta Teodosio <nathan.teodosio@canonical.com> Wed, 15 Nov 2023 11:28:54 +0100
61+
62 update-manager (1:20.04.10.17) focal; urgency=medium
63
64 * Ubuntu Pro (LP: #1990450):

Subscribers

People subscribed via source and target branches