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
1diff --git a/data/apt_check.py b/data/apt_check.py
2index 9915d1d..304ac66 100755
3--- a/data/apt_check.py
4+++ b/data/apt_check.py
5@@ -307,51 +307,42 @@ def write_human_readable_summary(outstream, upgrades, security_updates,
6 outstream.write("\n")
7
8
9-def has_disabled_esm_security_update(depcache, pkg, esm_origin):
10+def has_disabled_esm_security_update(esm_cache, pkg, esm_origin):
11 " check if we have a disabled ESM security update "
12 inst_ver = pkg.current_ver
13 if not inst_ver:
14 return False
15
16- for ver in pkg.version_list:
17- if ver == inst_ver:
18- break
19+ if pkg.name not in esm_cache:
20+ return False
21
22- for (file, index) in ver.file_list:
23- if (file.origin == esm_origin and file.archive.startswith(DISTRO)
24- and depcache.policy.get_priority(file) == -32768):
25+ esm_update = esm_cache[pkg.name]
26+ for version in esm_update.version_list:
27+ for (file, index) in version.file_list:
28+ if file.origin == esm_origin:
29 return True
30+
31 return False
32
33
34-def has_disabled_esm_apps_security_update(depcache, pkg):
35+def has_disabled_esm_apps_security_update(esm_cache, pkg):
36 " check if we have a disabled ESM Apps security update "
37- return has_disabled_esm_security_update(depcache, pkg, ESM_APPS_ORIGIN)
38+ return has_disabled_esm_security_update(esm_cache, pkg, ESM_APPS_ORIGIN)
39
40
41-def has_disabled_esm_infra_security_update(depcache, pkg):
42+def has_disabled_esm_infra_security_update(esm_cache, pkg):
43 " check if we have a disabled ESM Infra security update "
44- return has_disabled_esm_security_update(depcache, pkg, ESM_INFRA_ORIGIN)
45+ return has_disabled_esm_security_update(esm_cache, pkg, ESM_INFRA_ORIGIN)
46
47
48-def has_esm_service(cache, depcache, esm_origin):
49+def has_esm_service(cache, esm_origin):
50 " check if we have an enabled ESM service in the machine "
51- have_esm = None
52 for file in cache.file_list:
53 origin = file.origin
54 if origin == esm_origin and file.archive.startswith(DISTRO):
55- # In case of multiple ESM repos, one enabled is sufficient.
56- if depcache.policy.get_priority(file) == -32768:
57- # We found a disabled ESM repository, but we'll only count
58- # ESM as disabled here if we have not found any other ESM
59- # repo, so one ESM repo being enabled means ESM is enabled.
60- if have_esm is None:
61- have_esm = False
62- else:
63- have_esm = True
64- break
65+ return True
66
67- return have_esm
68+ return False
69
70
71 def init():
72@@ -394,12 +385,17 @@ def run(options=None):
73 sys.stderr.write("E: " + _("Error: Marking the upgrade (%s)") % e)
74 sys.exit(-1)
75
76+ try:
77+ apt_pkg.config.set("Dir", "/var/lib/ubuntu-advantage/apt-esm/")
78+ apt_pkg.init_system()
79+ esm_cache = apt_pkg.Cache(progress=None)
80+ except apt_pkg.Error:
81+ esm_cache = None
82+
83 # Check if we have ESM enabled or disabled; and if it exists in the
84 # first place.
85- have_esm_infra = has_esm_service(
86- cache, depcache, esm_origin=ESM_INFRA_ORIGIN)
87- have_esm_apps = has_esm_service(
88- cache, depcache, esm_origin=ESM_APPS_ORIGIN)
89+ have_esm_infra = has_esm_service(cache, esm_origin=ESM_INFRA_ORIGIN)
90+ have_esm_apps = has_esm_service(cache, esm_origin=ESM_APPS_ORIGIN)
91
92 # analyze the ugprade
93 upgrades = 0
94@@ -412,10 +408,11 @@ def run(options=None):
95 # we need another cache that has more pkg details
96 with apt.Cache() as aptcache:
97 for pkg in cache.packages:
98- if has_disabled_esm_apps_security_update(depcache, pkg):
99- disabled_esm_apps_updates += 1
100- if has_disabled_esm_infra_security_update(depcache, pkg):
101- disabled_esm_infra_updates += 1
102+ if esm_cache:
103+ if has_disabled_esm_apps_security_update(esm_cache, pkg):
104+ disabled_esm_apps_updates += 1
105+ if has_disabled_esm_infra_security_update(esm_cache, pkg):
106+ disabled_esm_infra_updates += 1
107
108 # skip packages that are not marked upgraded/installed
109 if not (depcache.marked_install(pkg)

Subscribers

People subscribed via source and target branches