Merge ~renanrodrigo/update-notifier:esm-cache-update into update-notifier:master

Proposed by Renan Rodrigo
Status: Merged
Merge reported by: Christian Ehrhardt 
Merged at revision: 4f897152652a21e9040adfefee03e65dd1aab6ab
Proposed branch: ~renanrodrigo/update-notifier:esm-cache-update
Merge into: update-notifier:master
Diff against target: 109 lines (+29/-32)
1 file modified
data/apt_check.py (+29/-32)
Reviewer Review Type Date Requested Status
Julian Andres Klode Approve
Review via email: mp+435293@code.launchpad.net

Description of the change

Rely on the Pro Client apt esm cache to check for esm updates

The Pro Client is not pinnning esm repositores and adding them to the system apt anymore, but using a separate cache instead.

To post a comment you must log in.
Revision history for this message
Julian Andres Klode (juliank) wrote :

+1

review: Approve
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Thanks for the review and discussions.
As agreed, we will figure the rest out when there's no time pressure.
For now I'm landing this in git and sponsor the upload so that it can continue.

Latest in lunar still matches git
 update-notifier | 3.192.60 | lunar | source, amd64, arm64, armhf, ppc64el, riscv64, s390x

Tagged as the others tagged it before in this repo.

Double checked if the resulting debdiff has any stray content. Things appear twice in the debdiff, but that is ok as it is due to a symlink wich wasn't changed or added int his upload.

All ok, merged and uploaded

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 d4ba000..44bfd08 100755
--- a/data/apt_check.py
+++ b/data/apt_check.py
@@ -287,51 +287,42 @@ def write_human_readable_summary(outstream, upgrades, security_updates,
287 outstream.write("\n")287 outstream.write("\n")
288288
289289
290def has_disabled_esm_security_update(depcache, pkg, esm_origin):290def has_disabled_esm_security_update(esm_cache, pkg, esm_origin):
291 " check if we have a disabled ESM security update "291 " check if we have a disabled ESM security update "
292 inst_ver = pkg.current_ver292 inst_ver = pkg.current_ver
293 if not inst_ver:293 if not inst_ver:
294 return False294 return False
295295
296 for ver in pkg.version_list:296 if pkg.name not in esm_cache:
297 if ver == inst_ver:297 return False
298 break
299298
300 for (file, index) in ver.file_list:299 esm_update = esm_cache[pkg.name]
301 if (file.origin == esm_origin and file.archive.startswith(DISTRO)300 for version in esm_update.version_list:
302 and depcache.policy.get_priority(file) == -32768):301 for (file, index) in version.file_list:
302 if file.origin == esm_origin:
303 return True303 return True
304
304 return False305 return False
305306
306307
307def has_disabled_esm_apps_security_update(depcache, pkg):308def has_disabled_esm_apps_security_update(esm_cache, pkg):
308 " check if we have a disabled ESM Apps security update "309 " check if we have a disabled ESM Apps security update "
309 return has_disabled_esm_security_update(depcache, pkg, ESM_APPS_ORIGIN)310 return has_disabled_esm_security_update(esm_cache, pkg, ESM_APPS_ORIGIN)
310311
311312
312def has_disabled_esm_infra_security_update(depcache, pkg):313def has_disabled_esm_infra_security_update(esm_cache, pkg):
313 " check if we have a disabled ESM Infra security update "314 " check if we have a disabled ESM Infra security update "
314 return has_disabled_esm_security_update(depcache, pkg, ESM_INFRA_ORIGIN)315 return has_disabled_esm_security_update(esm_cache, pkg, ESM_INFRA_ORIGIN)
315316
316317
317def has_esm_service(cache, depcache, esm_origin):318def has_esm_service(cache, esm_origin):
318 " check if we have an enabled ESM service in the machine "319 " check if we have an enabled ESM service in the machine "
319 have_esm = None
320 for file in cache.file_list:320 for file in cache.file_list:
321 origin = file.origin321 origin = file.origin
322 if origin == esm_origin and file.archive.startswith(DISTRO):322 if origin == esm_origin and file.archive.startswith(DISTRO):
323 # In case of multiple ESM repos, one enabled is sufficient.323 return True
324 if depcache.policy.get_priority(file) == -32768:
325 # We found a disabled ESM repository, but we'll only count
326 # ESM as disabled here if we have not found any other ESM
327 # repo, so one ESM repo being enabled means ESM is enabled.
328 if have_esm is None:
329 have_esm = False
330 else:
331 have_esm = True
332 break
333324
334 return have_esm325 return False
335326
336327
337def init():328def init():
@@ -374,12 +365,17 @@ def run(options=None):
374 sys.stderr.write("E: " + _("Error: Marking the upgrade (%s)") % e)365 sys.stderr.write("E: " + _("Error: Marking the upgrade (%s)") % e)
375 sys.exit(-1)366 sys.exit(-1)
376367
368 try:
369 apt_pkg.config.set("Dir", "/var/lib/ubuntu-advantage/apt-esm/")
370 apt_pkg.init_system()
371 esm_cache = apt_pkg.Cache(progress=None)
372 except apt_pkg.Error:
373 esm_cache = None
374
377 # Check if we have ESM enabled or disabled; and if it exists in the375 # Check if we have ESM enabled or disabled; and if it exists in the
378 # first place.376 # first place.
379 have_esm_infra = has_esm_service(377 have_esm_infra = has_esm_service(cache, esm_origin=ESM_INFRA_ORIGIN)
380 cache, depcache, esm_origin=ESM_INFRA_ORIGIN)378 have_esm_apps = has_esm_service(cache, esm_origin=ESM_APPS_ORIGIN)
381 have_esm_apps = has_esm_service(
382 cache, depcache, esm_origin=ESM_APPS_ORIGIN)
383379
384 # analyze the ugprade380 # analyze the ugprade
385 upgrades = 0381 upgrades = 0
@@ -392,10 +388,11 @@ def run(options=None):
392 # we need another cache that has more pkg details388 # we need another cache that has more pkg details
393 with apt.Cache() as aptcache:389 with apt.Cache() as aptcache:
394 for pkg in cache.packages:390 for pkg in cache.packages:
395 if has_disabled_esm_apps_security_update(depcache, pkg):391 if esm_cache:
396 disabled_esm_apps_updates += 1392 if has_disabled_esm_apps_security_update(esm_cache, pkg):
397 if has_disabled_esm_infra_security_update(depcache, pkg):393 disabled_esm_apps_updates += 1
398 disabled_esm_infra_updates += 1394 if has_disabled_esm_infra_security_update(esm_cache, pkg):
395 disabled_esm_infra_updates += 1
399396
400 # skip packages that are not marked upgraded/installed397 # skip packages that are not marked upgraded/installed
401 if not (depcache.marked_install(pkg)398 if not (depcache.marked_install(pkg)

Subscribers

People subscribed via source and target branches