Merge ~renanrodrigo/update-notifier:respect-phasing-jammy into update-notifier:jammy

Proposed by Renan Rodrigo
Status: Merged
Merged at revision: 4acee50a821c23ccb7529f98da63668881bf24c1
Proposed branch: ~renanrodrigo/update-notifier:respect-phasing-jammy
Merge into: update-notifier:jammy
Diff against target: 71 lines (+32/-6)
2 files modified
data/apt_check.py (+26/-6)
debian/changelog (+6/-0)
Reviewer Review Type Date Requested Status
Athos Ribeiro Approve
Review via email: mp+438010@code.launchpad.net

Description of the change

isolate creation of the esm apt cache in apt-check

create a separate function to configure apt_pkg, create the esm cache
and reinitialize the default configuration

To post a comment you must log in.
Revision history for this message
Athos Ribeiro (athos-ribeiro) wrote :

The code review was performed for the development branch at https://code.launchpad.net/~renanrodrigo/update-notifier/+git/update-notifier/+merge/438009.

The range diff is sane compared to the development changes. The only diff is the version/target series in the changelog.

The package builds fine and the DEP8 test suite is passing.

LGTM

review: Approve
Revision history for this message
Athos Ribeiro (athos-ribeiro) wrote :

Uploaded

Uploading to ubuntu (via ftp to upload.ubuntu.com):
  Uploading update-notifier_3.192.54.6.dsc: done.
  Uploading update-notifier_3.192.54.6.tar.xz: done.
  Uploading update-notifier_3.192.54.6_source.buildinfo: done.
  Uploading update-notifier_3.192.54.6_source.changes: done.
Successfully uploaded packages.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/data/apt_check.py b/data/apt_check.py
2index 44bfd08..f4cc471 100755
3--- a/data/apt_check.py
4+++ b/data/apt_check.py
5@@ -15,6 +15,7 @@ import distro_info
6
7 SYNAPTIC_PINFILE = "/var/lib/synaptic/preferences"
8 OS_RELEASE_PATH = "/etc/os-release"
9+PRO_ESM_CACHE_DIR = "/var/lib/ubuntu-advantage/apt-esm/"
10
11
12 def _get_info_from_os_release(key):
13@@ -325,6 +326,30 @@ def has_esm_service(cache, esm_origin):
14 return False
15
16
17+def get_apt_pkg_esm_cache():
18+ """Get an apt_pkg cache with the ubuntu-advantage-tools esm data.
19+
20+ Set the configuration to get the u-a-t cache, then set it back to an
21+ empty configuration state and init again so other calls to Cache work as
22+ expected.
23+ """
24+ for key in apt_pkg.config.keys():
25+ if re.match(r"^Acquire", key) is None:
26+ apt_pkg.config.clear(key)
27+ apt_pkg.config.set("Dir", PRO_ESM_CACHE_DIR)
28+ apt_pkg.init()
29+ try:
30+ esm_cache = apt_pkg.Cache(progress=None)
31+ except apt_pkg.Error:
32+ esm_cache = None
33+
34+ for key in apt_pkg.config.keys():
35+ apt_pkg.config.clear(key)
36+ apt_pkg.init()
37+
38+ return esm_cache
39+
40+
41 def init():
42 " init the system, be nice "
43 # FIXME: do a ionice here too?
44@@ -365,12 +390,7 @@ def run(options=None):
45 sys.stderr.write("E: " + _("Error: Marking the upgrade (%s)") % e)
46 sys.exit(-1)
47
48- try:
49- apt_pkg.config.set("Dir", "/var/lib/ubuntu-advantage/apt-esm/")
50- apt_pkg.init_system()
51- esm_cache = apt_pkg.Cache(progress=None)
52- except apt_pkg.Error:
53- esm_cache = None
54+ esm_cache = get_apt_pkg_esm_cache()
55
56 # Check if we have ESM enabled or disabled; and if it exists in the
57 # first place.
58diff --git a/debian/changelog b/debian/changelog
59index 090b924..ff84374 100644
60--- a/debian/changelog
61+++ b/debian/changelog
62@@ -1,3 +1,9 @@
63+update-notifier (3.192.54.6) jammy; urgency=medium
64+
65+ * Isolate creation of the esm apt cache in apt-check (LP: #2008212)
66+
67+ -- Renan Rodrigo Barbosa <renanrodrigo@canonical.com> Mon, 27 Feb 2023 23:15:02 -0300
68+
69 update-notifier (3.192.54.5) jammy; urgency=medium
70
71 * po/*.po: do not translate template variable needed for

Subscribers

People subscribed via source and target branches