From: Lukas Bulwahn Date: Wed, 8 Jan 2025 12:52:07 +0000 (+0100) Subject: scripts/spdxcheck: Handle license identifiers in Jinja comments X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=154916f4b59dc2228caad5fc98e9e6a7e1a84e19;p=users%2Fjedix%2Flinux-maple.git scripts/spdxcheck: Handle license identifiers in Jinja comments Commit 4b132aacb076 ("tools: Add xdrgen") adds a tool, which uses Jinja template files, i.e., files with the j2 file extension, for its lightweight code generation. These template files for this tool have proper headers with the SPDX License information, which are included as Jinja comments by enclosing the text with '{#' and '#}'. Sofar, the spdxcheck script does not support to properly parse this license information in Jinja comments and it reports back with 'Invalid token: #}'. Parse Jinja comments properly by stripping the known Jinja comment suffix. Signed-off-by: Lukas Bulwahn Link: https://lore.kernel.org/r/20250108125207.57486-1-lukas.bulwahn@redhat.com Signed-off-by: Greg Kroah-Hartman --- diff --git a/scripts/spdxcheck.py b/scripts/spdxcheck.py index fe57c9aecf37d..8d608f61bf371 100755 --- a/scripts/spdxcheck.py +++ b/scripts/spdxcheck.py @@ -214,6 +214,9 @@ class id_parser(object): # Remove trailing xml comment closure if line.strip().endswith('-->'): expr = expr.rstrip('-->').strip() + # Remove trailing Jinja2 comment closure + if line.strip().endswith('#}'): + expr = expr.rstrip('#}').strip() # Special case for SH magic boot code files if line.startswith('LIST \"'): expr = expr.rstrip('\"').strip()