Skip to content

Commit 8729a59

Browse files
david-marchandtmonjalo
authored andcommitted
devtools: enhance licenses check
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 <[email protected]>
1 parent d85aaff commit 8729a59

File tree

2 files changed

+46
-25
lines changed

2 files changed

+46
-25
lines changed

devtools/check-spdx-tag.sh

+41-19
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
#
55
# Produce a list of files with incorrect license tags
66

7-
errors=0
7+
missing_spdx=0
8+
wrong_license=0
89
warnings=0
910
quiet=false
1011
verbose=false
@@ -14,29 +15,47 @@ print_usage () {
1415
exit 1
1516
}
1617

18+
no_license_list=\
19+
':^.git* :^.mailmap :^.ci/* :^README :^*/README* :^MAINTAINERS :^VERSION :^ABI_VERSION '\
20+
':^license/ :^config/ :^buildtools/ :^*.abignore :^*.cocci :^*/poetry.lock '\
21+
':^*/Kbuild :^kernel/linux/uapi/version '\
22+
':^*.map :^*.ini :^*.data :^*.json :^*.cfg :^*.txt :^*.svg :^*.png'
23+
1724
check_spdx() {
18-
if $verbose; then
25+
if $verbose ; then
1926
echo "Files without SPDX License"
2027
echo "--------------------------"
2128
fi
22-
git grep -L SPDX-License-Identifier -- \
23-
':^.git*' ':^.mailmap' ':^.ci/*' \
24-
':^README' ':^MAINTAINERS' ':^VERSION' ':^ABI_VERSION' \
25-
':^*/Kbuild' ':^*/README*' \
26-
':^license/' ':^config/' ':^buildtools/' ':^*/poetry.lock' \
27-
':^kernel/linux/uapi/version' \
28-
':^*.cocci' ':^*.abignore' \
29-
':^*.map' ':^*.ini' ':^*.data' ':^*.json' ':^*.cfg' ':^*.txt' \
30-
':^*.svg' ':^*.png' \
31-
> $tmpfile
32-
33-
errors=$(wc -l < $tmpfile)
29+
git grep -L SPDX-License-Identifier -- $no_license_list > $tmpfile
30+
31+
missing_spdx=$(wc -l < $tmpfile)
32+
$quiet || cat $tmpfile
33+
}
34+
35+
build_exceptions_list() {
36+
grep '.*|.*|.*|.*' license/exceptions.txt | grep -v 'TB Approval Date' |
37+
while IFS='|' read license tb_date gb_date pattern ; do
38+
license=$(echo $license) # trim spaces
39+
git grep -l "SPDX-License-Identifier:[[:space:]]*$license" $pattern |
40+
sed -e 's/^/:^/'
41+
done
42+
}
43+
44+
check_licenses() {
45+
if $verbose ; then
46+
echo "Files with wrong license and no exception"
47+
echo "-----------------------------------------"
48+
fi
49+
exceptions=$(build_exceptions_list)
50+
git grep -l SPDX-License-Identifier: -- $no_license_list $exceptions |
51+
xargs grep -L -E 'SPDX-License-Identifier:[[:space:]]*\(?BSD-3-Clause' > $tmpfile
52+
53+
wrong_license=$(wc -l < $tmpfile)
3454
$quiet || cat $tmpfile
3555
}
3656

3757
check_boilerplate() {
3858
if $verbose ; then
39-
echo
4059
echo "Files with redundant license text"
4160
echo "---------------------------------"
4261
fi
@@ -62,10 +81,13 @@ tmpfile=$(mktemp -t dpdk.checkspdx.XXXXXX)
6281
trap 'rm -f -- "$tmpfile"' INT TERM HUP EXIT
6382

6483
check_spdx
65-
$quiet || echo
84+
$verbose && echo
85+
86+
check_licenses
87+
$verbose && echo
6688

6789
check_boilerplate
90+
$verbose && echo
6891

69-
$quiet || echo
70-
echo "total: $errors errors, $warnings warnings"
71-
exit $errors
92+
echo "total: $missing_spdx missing SPDX, $wrong_license license errors, $warnings warnings"
93+
exit $((missing_spdx + wrong_license))

license/exceptions.txt

+5-6
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@ Note that following licenses are not exceptions:-
1010
- GPL-2.0 (*Only for kernel code*)
1111

1212
---------------------------------------------------------------------------------------------------
13-
SPDX Identifier TB Approval Date GB Approval Date File name
13+
SPDX Identifier | TB Approval Date | GB Approval Date | File name
1414
---------------------------------------------------------------------------------------------------
15-
1.MIT 10/23/2019 02/10/2020 lib/eal/windows/include/dirent.h
16-
2.BSD-2-Clause 10/23/2019 12/18/2019 lib/eal/windows/include/getopt.h
17-
3.ISC AND
18-
BSD-2-Clause 10/23/2019 12/18/2019 lib/eal/windows/getopt.c
19-
4. MIT 10/19/2022 10/18/2022 drivers/net/gve/base/*
15+
MIT | 10/23/2019 | 02/10/2020 | lib/eal/windows/include/dirent.h
16+
BSD-2-Clause | 10/23/2019 | 12/18/2019 | lib/eal/windows/include/getopt.h
17+
ISC AND BSD-2-Clause | 10/23/2019 | 12/18/2019 | lib/eal/windows/getopt.c
18+
MIT | 10/19/2022 | 10/18/2022 | drivers/net/gve/base/*
2019
---------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)