From: Thomas Monjalon <thomas@monjalon.net>
To: dev@dpdk.org
Subject: [PATCH v3 2/2] devtools: check SPDX syntax
Date: Wed, 4 Feb 2026 21:46:06 +0100 [thread overview]
Message-ID: <20260204204945.3893117-3-thomas@monjalon.net> (raw)
In-Reply-To: <20260204204945.3893117-1-thomas@monjalon.net>
The script check-spdx-tag.sh is updated to detect some syntax errors
in SPDX declaration:
- the line must start with /* or # or ; or ..
- AND / OR must be uppercased
The Markdown files (.md) are skipped as other text files.
The quiet mode (-q) is made really quiet if no issue is found.
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
devtools/check-spdx-tag.sh | 33 ++++++++++++++++++++++++++++++---
1 file changed, 30 insertions(+), 3 deletions(-)
diff --git a/devtools/check-spdx-tag.sh b/devtools/check-spdx-tag.sh
index 984825026e..2390941c74 100755
--- a/devtools/check-spdx-tag.sh
+++ b/devtools/check-spdx-tag.sh
@@ -19,17 +19,41 @@ no_license_list=\
':^.git* :^.mailmap :^.ci/* :^README :^*/README* :^MAINTAINERS :^VERSION :^ABI_VERSION '\
':^license/ :^config/ :^buildtools/ :^*.abignore :^*.cocci :^*/poetry.lock '\
':^*/Kbuild :^kernel/linux/uapi/version '\
-':^*.ini :^*.data :^*.json :^*.cfg :^*.txt :^*.svg :^*.png'
+':^*.ini :^*.data :^*.json :^*.cfg :^*.txt :^*.md :^*.svg :^*.png'
check_spdx() {
if $verbose ; then
echo "Files without SPDX License"
echo "--------------------------"
fi
+
git grep -L SPDX-License-Identifier -- $no_license_list > $tmpfile
missing_spdx=$(wc -l < $tmpfile)
$quiet || cat $tmpfile
+
+ if $verbose ; then
+ echo
+ echo "Files with wrong SPDX format"
+ echo "----------------------------"
+ fi
+
+ files_without_spdx=$(cat $tmpfile)
+ git grep -LE '(/\*|#|;|\.\.) *SPDX-License-Identifier: [A-Z(]' -- $no_license_list > $tmpfile
+ for file in $files_without_spdx ; do
+ sed -i "/^$file$/d" $tmpfile
+ done
+
+ warnings=$(($warnings + $(wc -l < $tmpfile)))
+ $quiet || cat $tmpfile
+
+ files_with_andor=$(git grep -lEi 'SPDX-License-Identifier:.*\<(AND|OR)\>' -- $no_license_list)
+ for file in $files_with_andor ; do
+ grep -LE 'SPDX-License-Identifier:.*\<(AND|OR)\>' "$file"
+ done > $tmpfile
+
+ warnings=$(($warnings + $(wc -l < $tmpfile)))
+ $quiet || cat $tmpfile
}
build_exceptions_list() {
@@ -46,6 +70,7 @@ check_licenses() {
echo "Files with wrong license and no exception"
echo "-----------------------------------------"
fi
+
exceptions=$(build_exceptions_list)
git grep -l SPDX-License-Identifier: -- $no_license_list $exceptions |
xargs grep -L -E 'SPDX-License-Identifier:[[:space:]]*(\(?|.* OR )BSD-3-Clause' > $tmpfile
@@ -63,7 +88,7 @@ check_boilerplate() {
git grep -l Redistribution -- \
':^license/' ':^/devtools/check-spdx-tag.sh' > $tmpfile
- warnings=$(wc -l <$tmpfile)
+ warnings=$(($warnings + $(wc -l <$tmpfile)))
$quiet || cat $tmpfile
}
@@ -89,5 +114,7 @@ $verbose && echo
check_boilerplate
$verbose && echo
-echo "total: $missing_spdx missing SPDX, $wrong_license license errors, $warnings warnings"
+if [ $missing_spdx -gt 0 -o $wrong_license -gt 0 -o $warnings -gt 0 ] || ! $quiet ; then
+ echo "total: $missing_spdx missing SPDX, $wrong_license license errors, $warnings warnings"
+fi
exit $((missing_spdx + wrong_license))
--
2.52.0
next prev parent reply other threads:[~2026-02-04 20:50 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-12 9:13 [PATCH] license: standardize SPDX tag for 3-Clause BSD Thomas Monjalon
2025-11-12 9:31 ` Bruce Richardson
2025-11-12 9:38 ` Thomas Monjalon
2025-11-12 9:41 ` Bruce Richardson
2025-11-12 9:43 ` Thomas Monjalon
2026-01-14 6:00 ` Stephen Hemminger
2026-01-28 16:20 ` [PATCH v2] license: standardize SPDX tag Thomas Monjalon
2026-01-28 16:30 ` Bruce Richardson
2026-01-28 17:44 ` Thomas Monjalon
2026-01-28 17:46 ` Bruce Richardson
2026-02-04 20:46 ` [PATCH v3 0/2] " Thomas Monjalon
2026-02-04 20:46 ` [PATCH v3 1/2] license: " Thomas Monjalon
2026-02-05 5:34 ` Hemant Agrawal
2026-02-04 20:46 ` Thomas Monjalon [this message]
2026-02-05 1:41 ` [PATCH v3 0/2] " Stephen Hemminger
2026-02-05 8:44 ` Bruce Richardson
2026-02-05 14:30 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260204204945.3893117-3-thomas@monjalon.net \
--to=thomas@monjalon.net \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox