Merge ~renanrodrigo/ubuntu/+source/update-notifier:respect-phasing-xenial into ubuntu/+source/update-notifier:ubuntu/xenial-devel

Proposed by Renan Rodrigo
Status: Merged
Merge reported by: Renan Rodrigo
Merged at revision: 01a2b1ed0706cb9098df92c04328663bdb5c933e
Proposed branch: ~renanrodrigo/ubuntu/+source/update-notifier:respect-phasing-xenial
Merge into: ubuntu/+source/update-notifier:ubuntu/xenial-devel
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 (community) Approve
git-ubuntu import Pending
Review via email: mp+438015@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

I did split the logical changes from the changelog ones here though.

Thanks!

Uploaded:

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

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/data/apt_check.py b/data/apt_check.py
index 304ac66..164b2f9 100755
--- a/data/apt_check.py
+++ b/data/apt_check.py
@@ -16,6 +16,7 @@ import subprocess
1616
17SYNAPTIC_PINFILE = "/var/lib/synaptic/preferences"17SYNAPTIC_PINFILE = "/var/lib/synaptic/preferences"
18OS_RELEASE_PATH = "/etc/os-release"18OS_RELEASE_PATH = "/etc/os-release"
19PRO_ESM_CACHE_DIR = "/var/lib/ubuntu-advantage/apt-esm/"
1920
2021
21def _get_info_from_os_release(key):22def _get_info_from_os_release(key):
@@ -345,6 +346,30 @@ def has_esm_service(cache, esm_origin):
345 return False346 return False
346347
347348
349def get_apt_pkg_esm_cache():
350 """Get an apt_pkg cache with the ubuntu-advantage-tools esm data.
351
352 Set the configuration to get the u-a-t cache, then set it back to an
353 empty configuration state and init again so other calls to Cache work as
354 expected.
355 """
356 for key in apt_pkg.config.keys():
357 if re.match(r"^Acquire", key) is None:
358 apt_pkg.config.clear(key)
359 apt_pkg.config.set("Dir", PRO_ESM_CACHE_DIR)
360 apt_pkg.init()
361 try:
362 esm_cache = apt_pkg.Cache(progress=None)
363 except apt_pkg.Error:
364 esm_cache = None
365
366 for key in apt_pkg.config.keys():
367 apt_pkg.config.clear(key)
368 apt_pkg.init()
369
370 return esm_cache
371
372
348def init():373def init():
349 " init the system, be nice "374 " init the system, be nice "
350 # FIXME: do a ionice here too?375 # FIXME: do a ionice here too?
@@ -385,12 +410,7 @@ def run(options=None):
385 sys.stderr.write("E: " + _("Error: Marking the upgrade (%s)") % e)410 sys.stderr.write("E: " + _("Error: Marking the upgrade (%s)") % e)
386 sys.exit(-1)411 sys.exit(-1)
387412
388 try:413 esm_cache = get_apt_pkg_esm_cache()
389 apt_pkg.config.set("Dir", "/var/lib/ubuntu-advantage/apt-esm/")
390 apt_pkg.init_system()
391 esm_cache = apt_pkg.Cache(progress=None)
392 except apt_pkg.Error:
393 esm_cache = None
394414
395 # Check if we have ESM enabled or disabled; and if it exists in the415 # Check if we have ESM enabled or disabled; and if it exists in the
396 # first place.416 # first place.
diff --git a/debian/changelog b/debian/changelog
index 16fd87f..4db475b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
1update-notifier (3.168.20) xenial; urgency=medium
2
3 * Isolate creation of the esm apt cache in apt-check (LP: #2008212)
4
5 -- Renan Rodrigo Barbosa <renanrodrigo@canonical.com> Mon, 27 Feb 2023 23:15:02 -0300
6
1update-notifier (3.168.19) xenial; urgency=medium7update-notifier (3.168.19) xenial; urgency=medium
28
3 [ Renan Rodrigo Barbosa]9 [ Renan Rodrigo Barbosa]

Subscribers

People subscribed via source and target branches