Skip to content

Commit

Permalink
UBUNTU: [Packaging] annotations: prevent duplicate include lines
Browse files Browse the repository at this point in the history
Includes are always parsed recursively, but when we save them (e.g.,
when the annotations file is updated) we should always save only the
top-level includes, without repeating the recursive ones.

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
  • Loading branch information
Andrea Righi committed Mar 28, 2023
1 parent 6cb1f60 commit 9f3e2d8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions debian/scripts/misc/kconfig/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class Annotation(Config):
"""
Parse body of annotations file
"""
def _parse_body(self, data: str):
def _parse_body(self, data: str, parent=True):
for line in data.splitlines():
# Replace tabs with spaces, squeeze multiple into singles and
# remove leading and trailing spaces
Expand All @@ -85,10 +85,11 @@ def _parse_body(self, data: str):
# Handle includes (recursively)
m = re.match(r'^include\s+"?([^"]*)"?', line)
if m:
self.include.append(m.group(1))
if parent:
self.include.append(m.group(1))
include_fname = dirname(abspath(self.fname)) + '/' + m.group(1)
include_data = self._load(include_fname)
self._parse_body(include_data)
self._parse_body(include_data, parent=False)
continue

# Handle policy and note lines
Expand Down

0 comments on commit 9f3e2d8

Please sign in to comment.