From a6e358119533289447a8462a2bd230c99f8ddc87 Mon Sep 17 00:00:00 2001 From: Niels Thykier Date: Wed, 23 Oct 2019 19:29:57 +0000 Subject: [PATCH] SuiteLoader: Support Release files only "Codename" fields The spec for Release files says that (at least) one of "Suite" and "Codename" will be defined. This implies that "Suite" is optional in some cases and SuiteLoader now correctly falls back to using "Codename" in that case. Closes: https://bugs.debian.org/942104 Signed-off-by: Niels Thykier --- britney2/inputs/suiteloader.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/britney2/inputs/suiteloader.py b/britney2/inputs/suiteloader.py index 665b66f..1c6825f 100644 --- a/britney2/inputs/suiteloader.py +++ b/britney2/inputs/suiteloader.py @@ -134,6 +134,17 @@ class DebMirrorLikeSuiteContentLoader(SuiteContentLoader): # building items/keys - by intern strings we reduce memory (considerably). self._architectures = [sys.intern(arch) for arch in allarches] + def _get_suite_name(self, suite, release_file): + for name in ('Suite', 'Codename'): + try: + return release_file[name] + except KeyError: + pass + self.logger.warning("Either of the fields \"Suite\" or \"Codename\" should be present in a release file.") + self.logger.error("Release file for suite %s is missing both the \"Suite\" and the \"Codename\" fields.", + suite.name) + raise KeyError('Suite') + def _update_suite_name(self, suite): try: release_file = read_release_file(suite.path) @@ -143,8 +154,8 @@ class DebMirrorLikeSuiteContentLoader(SuiteContentLoader): release_file = None if release_file is not None: - suite.name = release_file['Suite'] - self.logger.info("Using suite name from Release file: %s", release_file['Suite']) + suite.name = self._get_suite_name(suite, release_file) + self.logger.info("Using suite name from Release file: %s", suite.name) def _check_release_file(self, target_suite, missing_config_msg): try: