Merge ~litios/ubuntu-cve-tracker:ppas-tag-migration into ubuntu-cve-tracker:master

Proposed by David Fernandez Gonzalez
Status: Merged
Merge reported by: David Fernandez Gonzalez
Merged at revision: 8d5aa3898e261c0861d302c17b9d8220970388a8
Proposed branch: ~litios/ubuntu-cve-tracker:ppas-tag-migration
Merge into: ubuntu-cve-tracker:master
Diff against target: 435 lines (+114/-73)
3 files modified
scripts/cve_lib.py (+78/-45)
scripts/generate_pkg_cache.py (+35/-27)
scripts/test_source_map.py (+1/-1)
Reviewer Review Type Date Requested Status
Eduardo Barretto Approve
Emilia Torino Approve
Review via email: mp+453042@code.launchpad.net

Description of the change

Due to https://code.launchpad.net/~litios/ubuntu-security-customer-ppa-tracking/+git/ubuntu-security-customer-ppa-tracking/+merge/453041, we need to update the loading of the external subprojects accordingly to the new format.

To post a comment you must log in.
Revision history for this message
Emilia Torino (emitorino) wrote :

LGTM, thanks!

review: Approve
Revision history for this message
Eduardo Barretto (ebarretto) wrote :

As we've spoken, the current changes break generate_pkg_cache.py
It would also be great to handle the pockets correctly in that same script, otherwise everything will show up as "Release" pocket.
Thanks for making these changes

review: Needs Fixing
be2fc23... by David Fernandez Gonzalez

Add pockets to subprojects

Signed-off-by: David Fernandez Gonzalez <email address hidden>

8d5aa38... by David Fernandez Gonzalez

cve_lib: remove /ubuntu from subproject ppa names

Signed-off-by: David Fernandez Gonzalez <email address hidden>

Revision history for this message
Eduardo Barretto (ebarretto) wrote :

lgtm, thanks

CI failures are not related to this PR

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/scripts/cve_lib.py b/scripts/cve_lib.py
index fb9a744..7299ac0 100755
--- a/scripts/cve_lib.py
+++ b/scripts/cve_lib.py
@@ -106,7 +106,7 @@ subprojects = {
106 "name": "Ubuntu 12.04 ESM",106 "name": "Ubuntu 12.04 ESM",
107 "codename": "Precise Pangolin",107 "codename": "Precise Pangolin",
108 "alias": "precise/esm",108 "alias": "precise/esm",
109 "ppa": "ubuntu-esm/esm",109 "ppas": [{ "ppa": "ubuntu-esm/esm", "pocket": "security"}],
110 "parent": "ubuntu/precise",110 "parent": "ubuntu/precise",
111 "description": "Available with UA Infra or UA Desktop: https://ubuntu.com/advantage",111 "description": "Available with UA Infra or UA Desktop: https://ubuntu.com/advantage",
112 "stamp": 1493521200,112 "stamp": 1493521200,
@@ -118,7 +118,10 @@ subprojects = {
118 "name": "Ubuntu 14.04 ESM",118 "name": "Ubuntu 14.04 ESM",
119 "codename": "Trusty Tahr",119 "codename": "Trusty Tahr",
120 "alias": "trusty/esm",120 "alias": "trusty/esm",
121 "ppa": "ubuntu-esm/esm-infra-security",121 "ppas": [
122 {"ppa": "ubuntu-esm/esm-infra-security", "pocket": "security"},
123 {"ppa": "ubuntu-esm/esm-infra-updates", "pocket": "updates"}
124 ],
122 "parent": "ubuntu/trusty",125 "parent": "ubuntu/trusty",
123 "description": "Available with Ubuntu Pro (Infra-only): https://ubuntu.com/pro",126 "description": "Available with Ubuntu Pro (Infra-only): https://ubuntu.com/pro",
124 "stamp": 1556593200,127 "stamp": 1556593200,
@@ -130,7 +133,10 @@ subprojects = {
130 "packages": ["esm-infra-xenial-supported.txt"],133 "packages": ["esm-infra-xenial-supported.txt"],
131 "name": "Ubuntu 16.04 ESM",134 "name": "Ubuntu 16.04 ESM",
132 "codename": "Xenial Xerus",135 "codename": "Xenial Xerus",
133 "ppa": "ubuntu-esm/esm-infra-security",136 "ppas": [
137 {"ppa": "ubuntu-esm/esm-infra-security", "pocket": "security"},
138 {"ppa": "ubuntu-esm/esm-infra-updates", "pocket": "updates"}
139 ],
134 "parent": "ubuntu/xenial",140 "parent": "ubuntu/xenial",
135 "description": "Available with Ubuntu Pro (Infra-only): https://ubuntu.com/pro",141 "description": "Available with Ubuntu Pro (Infra-only): https://ubuntu.com/pro",
136 "stamp": 1618963200,142 "stamp": 1618963200,
@@ -142,7 +148,10 @@ subprojects = {
142 "packages": ["esm-infra-bionic-supported.txt"],148 "packages": ["esm-infra-bionic-supported.txt"],
143 "name": "Ubuntu 18.04 ESM",149 "name": "Ubuntu 18.04 ESM",
144 "codename": "Bionic Beaver",150 "codename": "Bionic Beaver",
145 "ppa": "ubuntu-esm/esm-infra-security",151 "ppas": [
152 {"ppa": "ubuntu-esm/esm-infra-security", "pocket": "security"},
153 {"ppa": "ubuntu-esm/esm-infra-updates", "pocket": "updates"}
154 ],
146 "parent": "ubuntu/bionic",155 "parent": "ubuntu/bionic",
147 "description": "Available with Ubuntu Pro (Infra-only): https://ubuntu.com/pro",156 "description": "Available with Ubuntu Pro (Infra-only): https://ubuntu.com/pro",
148 "stamp": 1685539024,157 "stamp": 1685539024,
@@ -154,7 +163,10 @@ subprojects = {
154 "packages": ["esm-apps-xenial-supported.txt"],163 "packages": ["esm-apps-xenial-supported.txt"],
155 "name": "Ubuntu 16.04 ESM",164 "name": "Ubuntu 16.04 ESM",
156 "codename": "Xenial Xerus",165 "codename": "Xenial Xerus",
157 "ppa": "ubuntu-esm/esm-apps-security",166 "ppas": [
167 {"ppa": "ubuntu-esm/esm-apps-security", "pocket": "security"},
168 {"ppa": "ubuntu-esm/esm-apps-updates", "pocket": "updates"}
169 ],
158 "parent": "esm-infra/xenial",170 "parent": "esm-infra/xenial",
159 "description": "Available with Ubuntu Pro: https://ubuntu.com/pro",171 "description": "Available with Ubuntu Pro: https://ubuntu.com/pro",
160 "stamp": 1618963200,172 "stamp": 1618963200,
@@ -166,7 +178,10 @@ subprojects = {
166 "packages": ["esm-apps-bionic-supported.txt"],178 "packages": ["esm-apps-bionic-supported.txt"],
167 "name": "Ubuntu 18.04 ESM",179 "name": "Ubuntu 18.04 ESM",
168 "codename": "Bionic Beaver",180 "codename": "Bionic Beaver",
169 "ppa": "ubuntu-esm/esm-apps-security",181 "ppas": [
182 {"ppa": "ubuntu-esm/esm-apps-security", "pocket": "security"},
183 {"ppa": "ubuntu-esm/esm-apps-updates", "pocket": "updates"}
184 ],
170 "parent": "esm-infra/bionic",185 "parent": "esm-infra/bionic",
171 "description": "Available with Ubuntu Pro: https://ubuntu.com/pro",186 "description": "Available with Ubuntu Pro: https://ubuntu.com/pro",
172 "stamp": 1524870000,187 "stamp": 1524870000,
@@ -178,7 +193,10 @@ subprojects = {
178 "packages": ["esm-apps-focal-supported.txt"],193 "packages": ["esm-apps-focal-supported.txt"],
179 "name": "Ubuntu 20.04 ESM",194 "name": "Ubuntu 20.04 ESM",
180 "codename": "Focal Fossa",195 "codename": "Focal Fossa",
181 "ppa": "ubuntu-esm/esm-apps-security",196 "ppas": [
197 {"ppa": "ubuntu-esm/esm-apps-security", "pocket": "security"},
198 {"ppa": "ubuntu-esm/esm-apps-updates", "pocket": "updates"}
199 ],
182 "parent": "ubuntu/focal",200 "parent": "ubuntu/focal",
183 "description": "Available with Ubuntu Pro: https://ubuntu.com/pro",201 "description": "Available with Ubuntu Pro: https://ubuntu.com/pro",
184 "stamp": 1587567600,202 "stamp": 1587567600,
@@ -190,7 +208,10 @@ subprojects = {
190 "packages": ["esm-apps-jammy-supported.txt"],208 "packages": ["esm-apps-jammy-supported.txt"],
191 "name": "Ubuntu 22.04 ESM",209 "name": "Ubuntu 22.04 ESM",
192 "codename": "Jammy Jellyfish",210 "codename": "Jammy Jellyfish",
193 "ppa": "ubuntu-esm/esm-apps-security",211 "ppas": [
212 {"ppa": "ubuntu-esm/esm-apps-security", "pocket": "security"},
213 {"ppa": "ubuntu-esm/esm-apps-updates", "pocket": "updates"}
214 ],
194 "parent": "ubuntu/jammy",215 "parent": "ubuntu/jammy",
195 "description": "Available with Ubuntu Pro: https://ubuntu.com/pro",216 "description": "Available with Ubuntu Pro: https://ubuntu.com/pro",
196 "stamp": 1650693600,217 "stamp": 1650693600,
@@ -201,7 +222,7 @@ subprojects = {
201 "packages": ["fips-xenial-supported.txt"],222 "packages": ["fips-xenial-supported.txt"],
202 "name": "Ubuntu 16.04 FIPS Certified",223 "name": "Ubuntu 16.04 FIPS Certified",
203 "codename": "Xenial Xerus",224 "codename": "Xenial Xerus",
204 "ppa": "ubuntu-advantage/fips",225 "ppas": [{"ppa" : "ubuntu-advantage/fips", "pocket": "security"}],
205 "parent": "ubuntu/xenial",226 "parent": "ubuntu/xenial",
206 "description": "Available with Ubuntu Pro: https://ubuntu.com/pro",227 "description": "Available with Ubuntu Pro: https://ubuntu.com/pro",
207 },228 },
@@ -211,7 +232,7 @@ subprojects = {
211 "packages": ["fips-bionic-supported.txt"],232 "packages": ["fips-bionic-supported.txt"],
212 "name": "Ubuntu 18.04 FIPS Certified",233 "name": "Ubuntu 18.04 FIPS Certified",
213 "codename": "Bionic Beaver",234 "codename": "Bionic Beaver",
214 "ppa": "ubuntu-advantage/fips",235 "ppas": [{"ppa" : "ubuntu-advantage/fips", "pocket": "security"}],
215 "parent": "ubuntu/bionic",236 "parent": "ubuntu/bionic",
216 "description": "Available with Ubuntu Pro: https://ubuntu.com/pro",237 "description": "Available with Ubuntu Pro: https://ubuntu.com/pro",
217 },238 },
@@ -221,7 +242,7 @@ subprojects = {
221 "packages": ["fips-focal-supported.txt"],242 "packages": ["fips-focal-supported.txt"],
222 "name": "Ubuntu 20.04 FIPS Certified",243 "name": "Ubuntu 20.04 FIPS Certified",
223 "codename": "Focal Fossa",244 "codename": "Focal Fossa",
224 "ppa": "ubuntu-advantage/fips",245 "ppas": [{"ppa" : "ubuntu-advantage/fips", "pocket": "security"}],
225 "parent": "ubuntu/bionic",246 "parent": "ubuntu/bionic",
226 "description": "Available with Ubuntu Pro: https://ubuntu.com/pro",247 "description": "Available with Ubuntu Pro: https://ubuntu.com/pro",
227 },248 },
@@ -231,7 +252,7 @@ subprojects = {
231 "packages": ["fips-updates-xenial-supported.txt"],252 "packages": ["fips-updates-xenial-supported.txt"],
232 "name": "Ubuntu 16.04 FIPS Compliant",253 "name": "Ubuntu 16.04 FIPS Compliant",
233 "codename": "Xenial Xerus",254 "codename": "Xenial Xerus",
234 "ppa": "ubuntu-advantage/fips-updates",255 "ppas": [{"ppa" : "ubuntu-advantage/fips-updates", "pocket": "updates"}],
235 "parent": "ubuntu/xenial",256 "parent": "ubuntu/xenial",
236 "description": "Available with Ubuntu Pro: https://ubuntu.com/pro",257 "description": "Available with Ubuntu Pro: https://ubuntu.com/pro",
237 },258 },
@@ -241,7 +262,7 @@ subprojects = {
241 "packages": ["fips-updates-bionic-supported.txt"],262 "packages": ["fips-updates-bionic-supported.txt"],
242 "name": "Ubuntu 18.04 FIPS Compliant",263 "name": "Ubuntu 18.04 FIPS Compliant",
243 "codename": "Bionic Beaver",264 "codename": "Bionic Beaver",
244 "ppa": "ubuntu-advantage/fips-updates",265 "ppas": [{"ppa" : "ubuntu-advantage/fips-updates", "pocket": "updates"}],
245 "parent": "ubuntu/bionic",266 "parent": "ubuntu/bionic",
246 "description": "Available with Ubuntu Pro: https://ubuntu.com/pro",267 "description": "Available with Ubuntu Pro: https://ubuntu.com/pro",
247 },268 },
@@ -251,7 +272,7 @@ subprojects = {
251 "packages": ["fips-updates-focal-supported.txt"],272 "packages": ["fips-updates-focal-supported.txt"],
252 "name": "Ubuntu 20.04 FIPS Compliant",273 "name": "Ubuntu 20.04 FIPS Compliant",
253 "codename": "Focal Fossa",274 "codename": "Focal Fossa",
254 "ppa": "ubuntu-advantage/fips-updates",275 "ppas": [{"ppa" : "ubuntu-advantage/fips-updates", "pocket": "updates"}],
255 "parent": "ubuntu/bionic",276 "parent": "ubuntu/bionic",
256 "description": "Available with Ubuntu Pro: https://ubuntu.com/pro",277 "description": "Available with Ubuntu Pro: https://ubuntu.com/pro",
257 },278 },
@@ -262,7 +283,7 @@ subprojects = {
262 "name": "Ubuntu 16.04 ROS ESM",283 "name": "Ubuntu 16.04 ROS ESM",
263 "codename": "Xenial Xerus",284 "codename": "Xenial Xerus",
264 "alias": "ros-esm/xenial",285 "alias": "ros-esm/xenial",
265 "ppa": "ubuntu-robotics-packagers/ros-security",286 "ppas": [{"ppa": "ubuntu-robotics-packagers/ros-security", "pocket": "security"}],
266 "parent": "ubuntu/xenial",287 "parent": "ubuntu/xenial",
267 "description": "Available with Ubuntu Advantage: https://ubuntu.com/advantage",288 "description": "Available with Ubuntu Advantage: https://ubuntu.com/advantage",
268 },289 },
@@ -273,7 +294,7 @@ subprojects = {
273 "name": "Ubuntu 18.04 ROS ESM",294 "name": "Ubuntu 18.04 ROS ESM",
274 "codename": "Bionic Beaver",295 "codename": "Bionic Beaver",
275 "alias": "ros-esm/bionic",296 "alias": "ros-esm/bionic",
276 "ppa": "ubuntu-robotics-packagers/ros-security",297 "ppas": [{"ppa": "ubuntu-robotics-packagers/ros-security", "pocket": "security"}],
277 "parent": "ubuntu/bionic",298 "parent": "ubuntu/bionic",
278 "description": "Available with Ubuntu Advantage: https://ubuntu.com/advantage",299 "description": "Available with Ubuntu Advantage: https://ubuntu.com/advantage",
279 },300 },
@@ -755,17 +776,30 @@ def get_subproject_details_by_ppa_url_and_series(url, series):
755 prod, ser = product_series(rel)776 prod, ser = product_series(rel)
756 if ser == series:777 if ser == series:
757 try:778 try:
758 if subprojects[rel]["ppa"] in url:779 for ppa_pocket in subprojects[rel]["ppas"]:
759 product = prod780 if ppa_pocket['ppa'] in url:
760 canon = product + "/" + series781 product = prod
761 details = subprojects[rel]782 canon = product + "/" + series
762 break783 details = subprojects[rel]
784 break
763 except KeyError:785 except KeyError:
764 pass786 pass
765 if details is not None:787 if details is not None:
766 break788 break
767 return canon, product, series, details789 return canon, product, series, details
768790
791def release_ppa_pocket(rel, ppa):
792 _, _, _, details = get_subproject_details(rel)
793 pocket = None
794 try:
795 for ppa_pocket in details["ppas"]:
796 if ppa_pocket["ppa"] == ppa:
797 pocket = ppa_pocket["pocket"]
798 break
799 except (KeyError, TypeError):
800 pass
801 return pocket
802
769def release_name(rel):803def release_name(rel):
770 name = None804 name = None
771 _, _, _, details = get_subproject_details(rel)805 _, _, _, details = get_subproject_details(rel)
@@ -832,16 +866,16 @@ def release_version(rel):
832 if details:866 if details:
833 version = details["version"]867 version = details["version"]
834 return version868 return version
835869
836def release_ppa(rel):870def release_ppas(rel):
837 """Return the ppa for a given subproject."""871 """Return the ppas for a given subproject."""
838 ppa = None872 ppas = None
839 _, _, _, details = get_subproject_details(rel)873 _, _, _, details = get_subproject_details(rel)
840 try:874 try:
841 ppa = details["ppa"]875 ppas = details["ppas"]
842 except (KeyError, TypeError):876 except (KeyError, TypeError):
843 pass877 pass
844 return ppa878 return ppas
845879
846def needs_oval(rel):880def needs_oval(rel):
847 """Return if OVAL should be generated for a given subproject"""881 """Return if OVAL should be generated for a given subproject"""
@@ -931,7 +965,7 @@ def find_external_subproject_cves(cve):
931# should follow the same as any other subproject965# should follow the same as any other subproject
932# except for the extra 'product' and 'release' keys.966# except for the extra 'product' and 'release' keys.
933MANDATORY_EXTERNAL_SUBPROJECT_KEYS = ['cve_triage', 'cve_patching', 'cve_notification', 'security_updates_notification', 'binary_copies_only', 'seg_support', 'owners']967MANDATORY_EXTERNAL_SUBPROJECT_KEYS = ['cve_triage', 'cve_patching', 'cve_notification', 'security_updates_notification', 'binary_copies_only', 'seg_support', 'owners']
934MANDATORY_EXTERNAL_SUBPROJECT_PPA_KEYS = ['ppa', 'oval', 'product', 'release', 'supported_packages']968MANDATORY_EXTERNAL_SUBPROJECT_PPA_KEYS = ['ppas', 'oval', 'product', 'release', 'supported_packages']
935OPTIONAL_EXTERNAL_SUBPROJECT_PPA_KEYS = ['parent', 'name', 'codename', 'description', 'aliases', 'archs']969OPTIONAL_EXTERNAL_SUBPROJECT_PPA_KEYS = ['parent', 'name', 'codename', 'description', 'aliases', 'archs']
936970
937def load_external_subprojects(strict=False):971def load_external_subprojects(strict=False):
@@ -976,8 +1010,8 @@ def load_external_subprojects(strict=False):
976 else:1010 else:
977 support_metadata[key] = main_config[key]1011 support_metadata[key] = main_config[key]
9781012
979 for ppa in main_config['ppas']:1013 for subproject in main_config['subprojects']:
980 config = main_config['ppas'][ppa]1014 config = main_config['subprojects'][subproject]
981 if 'product' not in config or 'release' not in config:1015 if 'product' not in config or 'release' not in config:
982 if strict:1016 if strict:
983 raise ValueError(error_msg)1017 raise ValueError(error_msg)
@@ -985,39 +1019,38 @@ def load_external_subprojects(strict=False):
985 print(error_msg, file=sys.stderr)1019 print(error_msg, file=sys.stderr)
986 error_msg = '%s: missing "product" or "release".' % (subproject_path)1020 error_msg = '%s: missing "product" or "release".' % (subproject_path)
9871021
988 subproject_name = ppa1022 external_releases.append(subproject)
989 external_releases.append(subproject_name)1023 subprojects.setdefault(subproject, {"packages": [],
990 subprojects.setdefault(subproject_name, {"packages": [],
991 "eol": False})1024 "eol": False})
992 # an external subproject can append to an internal one1025 # an external subproject can append to an internal one
993 subprojects[subproject_name]["packages"].append(\1026 subprojects[subproject]["packages"].append(\
994 os.path.join(subproject_path, config['supported_packages']))1027 os.path.join(subproject_path, config['supported_packages']))
9951028
996 # check if aliases for packages exist1029 # check if aliases for packages exist
997 if 'aliases' in config:1030 if 'aliases' in config:
998 subprojects[subproject_name].setdefault("aliases", \1031 subprojects[subproject].setdefault("aliases", \
999 os.path.join(subproject_path, config['aliases']))1032 os.path.join(subproject_path, config['aliases']))
10001033
1001 for key in MANDATORY_EXTERNAL_SUBPROJECT_PPA_KEYS + OPTIONAL_EXTERNAL_SUBPROJECT_PPA_KEYS:1034 for key in MANDATORY_EXTERNAL_SUBPROJECT_PPA_KEYS + OPTIONAL_EXTERNAL_SUBPROJECT_PPA_KEYS:
1002 if key in config:1035 if key in config:
1003 subprojects[subproject_name].setdefault(key, config[key])1036 subprojects[subproject].setdefault(key, config[key])
1004 elif key in OPTIONAL_EXTERNAL_SUBPROJECT_PPA_KEYS:1037 elif key in OPTIONAL_EXTERNAL_SUBPROJECT_PPA_KEYS:
1005 _, _, _, original_release_details = get_subproject_details(subprojects[subproject_name]['release'])1038 _, _, _, original_release_details = get_subproject_details(subprojects[subproject]['release'])
1006 if original_release_details and key in original_release_details:1039 if original_release_details and key in original_release_details:
1007 subprojects[subproject_name].setdefault(key, original_release_details[key])1040 subprojects[subproject].setdefault(key, original_release_details[key])
1008 else:1041 else:
1009 error_msg = '%s missing "%s" field.' % (subproject_path, key)1042 error_msg = '%s missing "%s" field.' % (subproject_path, key)
1010 del subprojects[subproject_name]1043 del subprojects[subproject]
1011 external_releases.remove(subproject_name)1044 external_releases.remove(subproject)
1012 if strict:1045 if strict:
1013 raise ValueError(error_msg)1046 raise ValueError(error_msg)
1014 else:1047 else:
1015 print(error_msg, file=sys.stderr)1048 print(error_msg, file=sys.stderr)
10161049
1017 subprojects[subproject_name].setdefault("support_metadata", support_metadata)1050 subprojects[subproject].setdefault("support_metadata", support_metadata)
1018 project = read_external_subproject_details(subproject_name)1051 project = read_external_subproject_details(subproject)
1019 if project:1052 if project:
1020 subprojects[subproject_name].setdefault("customer", project)1053 subprojects[subproject].setdefault("customer", project)
10211054
1022load_external_subprojects()1055load_external_subprojects()
10231056
@@ -1068,8 +1101,8 @@ def release_is_older_than(release_a, release_b):
1068flavor_releases = [1101flavor_releases = [
1069 'lucid', 'precise', 'trusty', 'utopic', 'vivid', 'wily', 'xenial',1102 'lucid', 'precise', 'trusty', 'utopic', 'vivid', 'wily', 'xenial',
1070 'yakkety', 'zesty', 'artful', 'bionic', 'cosmic', 'disco', 'eoan',1103 'yakkety', 'zesty', 'artful', 'bionic', 'cosmic', 'disco', 'eoan',
1071 'focal', 'groovy', 'hirsute', 'impish', 'jammy', 'kinetic', "lunar",1104 'focal', 'groovy', 'hirsute', 'impish', 'jammy', 'kinetic', 'lunar',
1072 'mantic', 'noble',1105 'mantic','noble',
1073]1106]
10741107
1075all_releases = release_sort(all_releases)1108all_releases = release_sort(all_releases)
diff --git a/scripts/generate_pkg_cache.py b/scripts/generate_pkg_cache.py
index 27404f7..672e614 100644
--- a/scripts/generate_pkg_cache.py
+++ b/scripts/generate_pkg_cache.py
@@ -11,7 +11,7 @@
11# for details.11# for details.
12#12#
1313
14from cve_lib import (all_releases, devel_release, eol_releases, needs_oval, product_series, release_parent, release_ppa)14from cve_lib import (all_releases, devel_release, eol_releases, needs_oval, product_series, release_parent, release_ppas, release_ppa_pocket)
1515
16import argparse16import argparse
17import datetime17import datetime
@@ -55,31 +55,11 @@ def write_to_cache(cache_dir, release, cache):
55 except Exception:55 except Exception:
56 error(f"Could not write to JSON file: {filename}")56 error(f"Could not write to JSON file: {filename}")
5757
5858def get_binaries_rel(release, archive, real_threshold, series, cache, latest_date_created, ppa=None):
59def update_cache(release, cache, ppa=None, latest_date_created=None):
60 lp = lpl_common.connect(version='devel')
61 ubuntu = lp.distributions['ubuntu']
62 series = ubuntu.getSeries(name_or_version=product_series(release)[1])
63
64 real_threshold = None
65 if latest_date_created:
66 # Allow a grace period to cope with publications arriving out of
67 # order during long transactions.
68 real_threshold = latest_date_created - datetime.timedelta(hours=1)
69
70 if ppa:
71 archive, group, ppa_full_name = lpl_common.get_archive(
72 ppa,
73 lp,
74 False,
75 distribution=ubuntu
76 )
77 else:
78 archive = ubuntu.main_archive
79
80 debug(f"Retrieving Launchpad publications since {real_threshold}")59 debug(f"Retrieving Launchpad publications since {real_threshold}")
81 sources = archive.getPublishedSources(order_by_date=True, created_since_date=real_threshold, distro_series=series)60 sources = archive.getPublishedSources(order_by_date=True, created_since_date=real_threshold, distro_series=series)
82 for s in sources:61 for s in sources:
62 override_pocket = None
83 if s.pocket not in pockets:63 if s.pocket not in pockets:
84 continue64 continue
8565
@@ -90,15 +70,16 @@ def update_cache(release, cache, ppa=None, latest_date_created=None):
90 src = s.source_package_name70 src = s.source_package_name
91 src_ver = s.source_package_version71 src_ver = s.source_package_version
92 src_component = None72 src_component = None
93 if not ppa:73 if ppa:
94 src_component = s.component_name74 src_component = s.component_name
75 override_pocket = release_ppa_pocket(release, ppa)
9576
96 binaries = s.getPublishedBinaries(active_binaries_only=False)77 binaries = s.getPublishedBinaries(active_binaries_only=False)
97 for b in binaries:78 for b in binaries:
98 bin_name = b.binary_package_name79 bin_name = b.binary_package_name
99 bin_version = b.binary_package_version80 bin_version = b.binary_package_version
100 bin_component = b.component_name81 bin_component = b.component_name
101 pocket = b.pocket82 pocket = b.pocket if not ppa else override_pocket
102 bin_arch = b.display_name.split(' ')[-1]83 bin_arch = b.display_name.split(' ')[-1]
10384
104 if src not in cache:85 if src not in cache:
@@ -120,6 +101,33 @@ def update_cache(release, cache, ppa=None, latest_date_created=None):
120101
121 return latest_date_created102 return latest_date_created
122103
104def update_cache(release, cache, ppas=None, latest_date_created=None):
105 lp = lpl_common.connect(version='devel')
106 ubuntu = lp.distributions['ubuntu']
107 series = ubuntu.getSeries(name_or_version=product_series(release)[1])
108
109 real_threshold = None
110 if latest_date_created:
111 # Allow a grace period to cope with publications arriving out of
112 # order during long transactions.
113 real_threshold = latest_date_created - datetime.timedelta(hours=1)
114
115 if ppas:
116 for ppa_pocket in ppas:
117 ppa = ppa_pocket['ppa']
118 archive, _, _ = lpl_common.get_archive(
119 ppa.split('/ubuntu')[0],
120 lp,
121 False,
122 distribution=ubuntu
123 )
124
125 latest_date_created = get_binaries_rel(release, archive, real_threshold, series, cache, latest_date_created, ppa)
126 else:
127 latest_date_created = get_binaries_rel(release, ubuntu.main_archive, real_threshold, series, cache, latest_date_created)
128
129 return latest_date_created
130
123131
124def warn(message):132def warn(message):
125 """ print a warning message """133 """ print a warning message """
@@ -186,8 +194,8 @@ def main():
186194
187 debug('UPDATING CACHE')195 debug('UPDATING CACHE')
188196
189 ppa = release_ppa(release)197 ppas = release_ppas(release)
190 latest_date_created = update_cache(release, cache, ppa, latest_date_created)198 latest_date_created = update_cache(release, cache, ppas, latest_date_created)
191199
192 if latest_date_created is not None:200 if latest_date_created is not None:
193 epoch = datetime.datetime.fromtimestamp(0, tz=datetime.timezone.utc)201 epoch = datetime.datetime.fromtimestamp(0, tz=datetime.timezone.utc)
diff --git a/scripts/test_source_map.py b/scripts/test_source_map.py
index 8e99825..e05117c 100755
--- a/scripts/test_source_map.py
+++ b/scripts/test_source_map.py
@@ -13,7 +13,7 @@ mock_subprojects = {
13 "packages": ["test/esm-fake-supported.txt"],13 "packages": ["test/esm-fake-supported.txt"],
14 "name": "Ubuntu 01.01 ESM",14 "name": "Ubuntu 01.01 ESM",
15 "codename": "Fabulous Fake",15 "codename": "Fabulous Fake",
16 "ppa": "ubuntu-esm/esm-bar-security/ubuntu",16 "ppas": [{"ppa": "ubuntu-esm/esm-bar-security/ubuntu", "pocket": "main"}],
17 "parent": "ubuntu/bar",17 "parent": "ubuntu/bar",
18 "description": "Available with Ubuntu Pro: https://ubuntu.com/pro",18 "description": "Available with Ubuntu Pro: https://ubuntu.com/pro",
19 "stamp": 1618963200,19 "stamp": 1618963200,

Subscribers

People subscribed via source and target branches