Merge ~renanrodrigo/ubuntu/+source/update-notifier:esm-cache-update-xenial into ubuntu/+source/update-notifier:ubuntu/xenial-devel

Proposed by Renan Rodrigo
Status: Merged
Merged at revision: 2391d6471e9a80747127158e2bd20adf962348b0
Proposed branch: ~renanrodrigo/ubuntu/+source/update-notifier:esm-cache-update-xenial
Merge into: ubuntu/+source/update-notifier:ubuntu/xenial-devel
Diff against target: 109 lines (+29/-32)
1 file modified
data/apt_check.py (+29/-32)
Reviewer Review Type Date Requested Status
Ubuntu Core Development Team Pending
Review via email: mp+436035@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
Christian Ehrhardt  (paelzer) wrote :

I checked how other recent xenial uploads landed (as it is in ESM mode), but it seems they were handled just "normal" which is fine. I'm following the same path.

Since there are no git branches for xenial in the recent team owned git I've followed Renan's proposed git-ubuntu approach.

This made me do another few checks to see if that change of internal structure affects it.
I was wondering about the symlink that we've seen in later versions, but that doesn't exist at all in the xenial version - so the change of repositories can't break it either \o/.

It is now uploaded it including proper VCS info in .changes - should switch to merged once accepted.

Needed some extra steps to convince dput-ng to let it through.

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

This is uploaded and was combined with https://code.launchpad.net/~lamoura/ubuntu/+source/update-notifier/+git/update-notifier/+merge/436159

Consider it merged (even though it needs to land in -proposed for git-ubuntu to mark it that way).

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 9915d1d..304ac66 100755
--- a/data/apt_check.py
+++ b/data/apt_check.py
@@ -307,51 +307,42 @@ def write_human_readable_summary(outstream, upgrades, security_updates,
307 outstream.write("\n")307 outstream.write("\n")
308308
309309
310def has_disabled_esm_security_update(depcache, pkg, esm_origin):310def has_disabled_esm_security_update(esm_cache, pkg, esm_origin):
311 " check if we have a disabled ESM security update "311 " check if we have a disabled ESM security update "
312 inst_ver = pkg.current_ver312 inst_ver = pkg.current_ver
313 if not inst_ver:313 if not inst_ver:
314 return False314 return False
315315
316 for ver in pkg.version_list:316 if pkg.name not in esm_cache:
317 if ver == inst_ver:317 return False
318 break
319318
320 for (file, index) in ver.file_list:319 esm_update = esm_cache[pkg.name]
321 if (file.origin == esm_origin and file.archive.startswith(DISTRO)320 for version in esm_update.version_list:
322 and depcache.policy.get_priority(file) == -32768):321 for (file, index) in version.file_list:
322 if file.origin == esm_origin:
323 return True323 return True
324
324 return False325 return False
325326
326327
327def has_disabled_esm_apps_security_update(depcache, pkg):328def has_disabled_esm_apps_security_update(esm_cache, pkg):
328 " check if we have a disabled ESM Apps security update "329 " check if we have a disabled ESM Apps security update "
329 return has_disabled_esm_security_update(depcache, pkg, ESM_APPS_ORIGIN)330 return has_disabled_esm_security_update(esm_cache, pkg, ESM_APPS_ORIGIN)
330331
331332
332def has_disabled_esm_infra_security_update(depcache, pkg):333def has_disabled_esm_infra_security_update(esm_cache, pkg):
333 " check if we have a disabled ESM Infra security update "334 " check if we have a disabled ESM Infra security update "
334 return has_disabled_esm_security_update(depcache, pkg, ESM_INFRA_ORIGIN)335 return has_disabled_esm_security_update(esm_cache, pkg, ESM_INFRA_ORIGIN)
335336
336337
337def has_esm_service(cache, depcache, esm_origin):338def has_esm_service(cache, esm_origin):
338 " check if we have an enabled ESM service in the machine "339 " check if we have an enabled ESM service in the machine "
339 have_esm = None
340 for file in cache.file_list:340 for file in cache.file_list:
341 origin = file.origin341 origin = file.origin
342 if origin == esm_origin and file.archive.startswith(DISTRO):342 if origin == esm_origin and file.archive.startswith(DISTRO):
343 # In case of multiple ESM repos, one enabled is sufficient.343 return True
344 if depcache.policy.get_priority(file) == -32768:
345 # We found a disabled ESM repository, but we'll only count
346 # ESM as disabled here if we have not found any other ESM
347 # repo, so one ESM repo being enabled means ESM is enabled.
348 if have_esm is None:
349 have_esm = False
350 else:
351 have_esm = True
352 break
353344
354 return have_esm345 return False
355346
356347
357def init():348def init():
@@ -394,12 +385,17 @@ def run(options=None):
394 sys.stderr.write("E: " + _("Error: Marking the upgrade (%s)") % e)385 sys.stderr.write("E: " + _("Error: Marking the upgrade (%s)") % e)
395 sys.exit(-1)386 sys.exit(-1)
396387
388 try:
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
394
397 # Check if we have ESM enabled or disabled; and if it exists in the395 # Check if we have ESM enabled or disabled; and if it exists in the
398 # first place.396 # first place.
399 have_esm_infra = has_esm_service(397 have_esm_infra = has_esm_service(cache, esm_origin=ESM_INFRA_ORIGIN)
400 cache, depcache, esm_origin=ESM_INFRA_ORIGIN)398 have_esm_apps = has_esm_service(cache, esm_origin=ESM_APPS_ORIGIN)
401 have_esm_apps = has_esm_service(
402 cache, depcache, esm_origin=ESM_APPS_ORIGIN)
403399
404 # analyze the ugprade400 # analyze the ugprade
405 upgrades = 0401 upgrades = 0
@@ -412,10 +408,11 @@ def run(options=None):
412 # we need another cache that has more pkg details408 # we need another cache that has more pkg details
413 with apt.Cache() as aptcache:409 with apt.Cache() as aptcache:
414 for pkg in cache.packages:410 for pkg in cache.packages:
415 if has_disabled_esm_apps_security_update(depcache, pkg):411 if esm_cache:
416 disabled_esm_apps_updates += 1412 if has_disabled_esm_apps_security_update(esm_cache, pkg):
417 if has_disabled_esm_infra_security_update(depcache, pkg):413 disabled_esm_apps_updates += 1
418 disabled_esm_infra_updates += 1414 if has_disabled_esm_infra_security_update(esm_cache, pkg):
415 disabled_esm_infra_updates += 1
419416
420 # skip packages that are not marked upgraded/installed417 # skip packages that are not marked upgraded/installed
421 if not (depcache.marked_install(pkg)418 if not (depcache.marked_install(pkg)

Subscribers

People subscribed via source and target branches