From: David Marchand <david.marchand@redhat.com>
To: dev@dpdk.org
Cc: thomas@monjalon.net, techboard@dpdk.org
Subject: [PATCH] devtools: enhance the license check
Date: Tue, 10 Dec 2024 10:10:39 +0100 [thread overview]
Message-ID: <20241210091039.3439504-1-david.marchand@redhat.com> (raw)
Reformat the license/exceptions.txt file to make it easier to build
a list of exempted files.
Display all files committed in DPDK that are non compliant
with BSD-3 license.
Signed-off-by: David Marchand <david.marchand@redhat.com>
---
devtools/check-spdx-tag.sh | 59 +++++++++++++++++++++++++++-----------
license/exceptions.txt | 11 ++++---
2 files changed, 47 insertions(+), 23 deletions(-)
diff --git a/devtools/check-spdx-tag.sh b/devtools/check-spdx-tag.sh
index b983268b1e..f893003af6 100755
--- a/devtools/check-spdx-tag.sh
+++ b/devtools/check-spdx-tag.sh
@@ -4,7 +4,8 @@
#
# Produce a list of files with incorrect license tags
-errors=0
+missing_spdx=0
+wrong_license=0
warnings=0
quiet=false
verbose=false
@@ -14,23 +15,44 @@ print_usage () {
exit 1
}
+no_license_list=\
+':^.git* :^.mailmap :^.ci/* :^README :^MAINTAINERS :^VERSION :^ABI_VERSION :^*/Kbuild '\
+':^*/README* :^license/ :^config/ :^buildtools/ :^*/poetry.lock '\
+':^kernel/linux/uapi/.gitignore :^kernel/linux/uapi/version :^*.cocci :^*.abignore '\
+':^*.map :^*.ini :^*.data :^*.json :^*.cfg :^*.txt :^*.svg :^*.png'
+
check_spdx() {
- if $verbose; then
+ if $verbose ; then
echo "Files without SPDX License"
echo "--------------------------"
fi
- git grep -L SPDX-License-Identifier -- \
- ':^.git*' ':^.mailmap' ':^.ci/*' \
- ':^README' ':^MAINTAINERS' ':^VERSION' ':^ABI_VERSION' \
- ':^*/Kbuild' ':^*/README*' \
- ':^license/' ':^config/' ':^buildtools/' ':^*/poetry.lock' \
- ':^kernel/linux/uapi/.gitignore' ':^kernel/linux/uapi/version' \
- ':^*.cocci' ':^*.abignore' \
- ':^*.map' ':^*.ini' ':^*.data' ':^*.json' ':^*.cfg' ':^*.txt' \
- ':^*.svg' ':^*.png' \
- > $tmpfile
-
- errors=$(wc -l < $tmpfile)
+ git grep -L SPDX-License-Identifier -- $no_license_list > $tmpfile
+
+ missing_spdx=$(wc -l < $tmpfile)
+ $quiet || cat $tmpfile
+}
+
+build_exceptions_list() {
+ grep '.*|.*|.*|.*' license/exceptions.txt | grep -v 'TB Approval Date' |
+ while IFS='|' read license tb_date gb_date pattern ; do
+ unset IFS
+ license=${license## *}
+ license=${license%% *}
+ git grep -l "SPDX-License-Identifier:[[:space:]]*$license" $pattern |
+ sed -e 's/^/:^/'
+ done
+}
+
+check_licenses() {
+ if $verbose ; then
+ 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:]]*\(?BSD-3-Clause' > $tmpfile
+
+ wrong_license=$(wc -l < $tmpfile)
$quiet || cat $tmpfile
}
@@ -64,8 +86,11 @@ trap 'rm -f -- "$tmpfile"' INT TERM HUP EXIT
check_spdx
$quiet || echo
-check_boilerplate
+check_licenses
+$quiet || echo
+check_boilerplate
$quiet || echo
-echo "total: $errors errors, $warnings warnings"
-exit $errors
+
+echo "total: $missing_spdx missing SPDX errors, $wrong_license license errors, $warnings warnings"
+exit $((missing_spdx + wrong_license))
diff --git a/license/exceptions.txt b/license/exceptions.txt
index 1ded290eee..d12fac2034 100644
--- a/license/exceptions.txt
+++ b/license/exceptions.txt
@@ -10,11 +10,10 @@ Note that following licenses are not exceptions:-
- GPL-2.0 (*Only for kernel code*)
---------------------------------------------------------------------------------------------------
-SPDX Identifier TB Approval Date GB Approval Date File name
+SPDX Identifier | TB Approval Date | GB Approval Date | File name
---------------------------------------------------------------------------------------------------
-1.MIT 10/23/2019 02/10/2020 lib/eal/windows/include/dirent.h
-2.BSD-2-Clause 10/23/2019 12/18/2019 lib/eal/windows/include/getopt.h
-3.ISC AND
- BSD-2-Clause 10/23/2019 12/18/2019 lib/eal/windows/getopt.c
-4. MIT 10/19/2022 10/18/2022 drivers/net/gve/base/*
+MIT | 10/23/2019 | 02/10/2020 | lib/eal/windows/include/dirent.h
+BSD-2-Clause | 10/23/2019 | 12/18/2019 | lib/eal/windows/include/getopt.h
+ISC AND BSD-2-Clause | 10/23/2019 | 12/18/2019 | lib/eal/windows/getopt.c
+MIT | 10/19/2022 | 10/18/2022 | drivers/net/gve/base/*
---------------------------------------------------------------------------------------------------
--
2.47.0
next reply other threads:[~2024-12-10 9:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-10 9:10 David Marchand [this message]
2024-12-10 17:00 ` Stephen Hemminger
2024-12-11 9:00 ` David Marchand
2024-12-11 14:55 ` Stephen Hemminger
2024-12-11 15:01 ` Thomas Monjalon
2024-12-11 21:22 ` Patrick Robb
2024-12-13 15:51 ` David Marchand
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=20241210091039.3439504-1-david.marchand@redhat.com \
--to=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=techboard@dpdk.org \
--cc=thomas@monjalon.net \
/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;
as well as URLs for NNTP newsgroup(s).