From eda1e44fb1df3b25c72a99ffa6613a747e1a965c Mon Sep 17 00:00:00 2001 From: Luke Nowakowski-Krijger Date: Tue, 11 Jul 2023 11:07:11 -0700 Subject: [PATCH] UBUNTU: [Packaging] update annotations scripts BugLink: https://bugs.launchpad.net/bugs/1786013 Signed-off-by: Luke Nowakowski-Krijger --- debian/scripts/misc/annotations | 2 +- debian/scripts/misc/kconfig/annotations.py | 23 +++++++++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/debian/scripts/misc/annotations b/debian/scripts/misc/annotations index ea6bc9b5157d6..86d858611780d 100755 --- a/debian/scripts/misc/annotations +++ b/debian/scripts/misc/annotations @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- mode: python -*- # Manage Ubuntu kernel .config and annotations # Copyright © 2022 Canonical Ltd. diff --git a/debian/scripts/misc/kconfig/annotations.py b/debian/scripts/misc/kconfig/annotations.py index b521bd0c71359..1d5e40cb67de3 100644 --- a/debian/scripts/misc/kconfig/annotations.py +++ b/debian/scripts/misc/kconfig/annotations.py @@ -117,14 +117,14 @@ def _parse_body(self, data: str, parent=True): entry['note'] = "'" + m.group(1).replace("'", '') + "'" if not match: - raise Exception('syntax error') + raise SyntaxError('syntax error') self.config[conf] = entry except Exception as e: - raise Exception(str(e) + f', line = {line}') from e + raise SyntaxError(str(e) + f', line = {line}') from e continue # Invalid line - raise Exception(f'invalid line: {line}') + raise SyntaxError(f'invalid line: {line}') def _parse(self, data: str): """ @@ -162,9 +162,9 @@ def _parse(self, data: str): # Sanity check: Verify that all FLAVOUR_DEP flavors are valid for src, tgt in self.flavour_dep.items(): if src not in self.flavour: - raise Exception(f'Invalid source flavour in FLAVOUR_DEP: {src}') + raise SyntaxError(f'Invalid source flavour in FLAVOUR_DEP: {src}') if tgt not in self.include_flavour: - raise Exception(f'Invalid target flavour in FLAVOUR_DEP: {tgt}') + raise SyntaxError(f'Invalid target flavour in FLAVOUR_DEP: {tgt}') def _remove_entry(self, config: str): if self.config[config]: @@ -338,15 +338,20 @@ def save(self, fname: str): if 'policy' not in new_val: continue - # If new_val is a subset of old_val, skip it + # If new_val is a subset of old_val, skip it unless there are + # new notes that are different than the old ones. old_val = tmp_a.config.get(conf) if old_val and 'policy' in old_val: try: - if old_val['policy'] == old_val['policy'] | new_val['policy']: - continue + can_skip = old_val['policy'] == old_val['policy'] | new_val['policy'] except TypeError: - if old_val['policy'] == {**old_val['policy'], **new_val['policy']}: + can_skip = old_val['policy'] == {**old_val['policy'], **new_val['policy']} + if can_skip: + if 'note' not in new_val: continue + if 'note' in old_val and 'note' in new_val: + if old_val['note'] == new_val['note']: + continue # Write out the policy (and note) line(s) val = dict(sorted(new_val['policy'].items()))