scripts/spdxcheck: Parse j2 comments correctly
authorThomas Gleixner <tglx@linutronix.de>
Fri, 29 Nov 2024 10:37:45 +0000 (11:37 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 8 Jan 2025 14:38:28 +0000 (15:38 +0100)
j2 files use '#}' as comment closure, which trips up the SPDX
parser:

 tools/.../definition.j2: 1:36 Invalid token: #}

Handle those comments correctly by removing the closure.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/878qt2xr46.ffs@tglx
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
scripts/spdxcheck.py

index 8b8fb115fc819507c6ac3e12970d9ae8cabf6b69..fe57c9aecf37ddc20e0f994de8f924e3908f8f08 100755 (executable)
@@ -217,6 +217,9 @@ class id_parser(object):
                 # Special case for SH magic boot code files
                 if line.startswith('LIST \"'):
                     expr = expr.rstrip('\"').strip()
+                # Remove j2 comment closure
+                if line.startswith('{#'):
+                    expr = expr.rstrip('#}').strip()
                 self.parse(expr)
                 self.spdx_valid += 1
                 #