4
4
#
5
5
# Produce a list of files with incorrect license tags
6
6
7
- errors=0
7
+ missing_spdx=0
8
+ wrong_license=0
8
9
warnings=0
9
10
quiet=false
10
11
verbose=false
@@ -14,29 +15,47 @@ print_usage () {
14
15
exit 1
15
16
}
16
17
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
+
17
24
check_spdx () {
18
- if $verbose ; then
25
+ if $verbose ; then
19
26
echo " Files without SPDX License"
20
27
echo " --------------------------"
21
28
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 )
34
54
$quiet || cat $tmpfile
35
55
}
36
56
37
57
check_boilerplate () {
38
58
if $verbose ; then
39
- echo
40
59
echo " Files with redundant license text"
41
60
echo " ---------------------------------"
42
61
fi
@@ -62,10 +81,13 @@ tmpfile=$(mktemp -t dpdk.checkspdx.XXXXXX)
62
81
trap ' rm -f -- "$tmpfile"' INT TERM HUP EXIT
63
82
64
83
check_spdx
65
- $quiet || echo
84
+ $verbose && echo
85
+
86
+ check_licenses
87
+ $verbose && echo
66
88
67
89
check_boilerplate
90
+ $verbose && echo
68
91
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))
0 commit comments