Merge ~nteodosio/update-manager:main into update-manager:main

Proposed by Nathan Teodosio
Status: Merged
Approved by: Sebastien Bacher
Approved revision: 4b2f30b066c8387eaf8914929691b8723805961f
Merged at revision: 4b2f30b066c8387eaf8914929691b8723805961f
Proposed branch: ~nteodosio/update-manager:main
Merge into: update-manager:main
Diff against target: 67 lines (+19/-1)
3 files modified
UpdateManager/Core/MyCache.py (+11/-1)
UpdateManager/UpdateManager.py (+1/-0)
debian/changelog (+7/-0)
Reviewer Review Type Date Requested Status
Sebastien Bacher Approve
Review via email: mp+455614@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 :

Great, 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 66f33f9..e29333c 100644
3--- a/UpdateManager/Core/MyCache.py
4+++ b/UpdateManager/Core/MyCache.py
5@@ -76,6 +76,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@@ -468,9 +469,18 @@ class MyCache(DistUpgrade.DistUpgradeCache.MyCache):
14 )
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] = _(
30 "Changes for %s versions:\n"
31 "Installed version: %s\n"
32@@ -478,7 +488,7 @@ class MyCache(DistUpgrade.DistUpgradeCache.MyCache):
33 ) % (
34 name,
35 getattr(self[name].installed, "version", None),
36- self[name].candidate.version,
37+ version,
38 )
39 if self.CHANGELOG_ORIGIN not in [o.origin for o in origins]:
40 self._fetch_changelog_for_third_party_package(name, origins)
41diff --git a/UpdateManager/UpdateManager.py b/UpdateManager/UpdateManager.py
42index 16cc18e..2e6aed4 100644
43--- a/UpdateManager/UpdateManager.py
44+++ b/UpdateManager/UpdateManager.py
45@@ -305,6 +305,7 @@ class UpdateManager(Gtk.Window):
46 self.ua_security_packages.append(
47 (name, version, size, downloadable)
48 )
49+ self.cache.create_pro_cache(self.ua_security_packages)
50
51 def _make_available_pane(
52 self,
53diff --git a/debian/changelog b/debian/changelog
54index a0a7672..b8ee063 100644
55--- a/debian/changelog
56+++ b/debian/changelog
57@@ -1,3 +1,10 @@
58+update-manager (1:24.04.1) noble; urgency=medium
59+
60+ * Fix incorrect available version for Ubuntu Pro updates in unattached case
61+ (LP: #2043425).
62+
63+ -- Nathan Pratta Teodosio <nathan.teodosio@canonical.com> Wed, 15 Nov 2023 11:45:02 +0100
64+
65 update-manager (1:23.10.2) mantic; urgency=medium
66
67 * Ubuntu Pro (LP: #1990450):

Subscribers

People subscribed via source and target branches