drivers/wifi: Remove unnecessary data structure copy
[coreboot2.git] / util / lint / lint-000-license-headers
blob44657d27c900f0f104f7c807d9dede1ad4ee68c2
1 #!/usr/bin/env sh
3 # SPDX-License-Identifier: GPL-2.0-only
5 # DESCR: Check that files in have valid license headers
6 # $1 is an optional command line parameter containing directories to check
9 LINTDIR="$(
10 cd -- "$(dirname "$0")" > /dev/null 2>&1 || return
11 pwd -P
14 # shellcheck source=helper_functions.sh
15 . "${LINTDIR}/helper_functions.sh"
17 # regex list of files and directories to exclude from the search
18 HEADER_EXCLUDED="\
19 ^src/commonlib/bsd/lz4.c.inc\$|\
20 ^src/cpu/x86/16bit/entry16.inc\$|\
21 ^src/device/oprom/x86emu/|\
22 ^src/device/oprom/include/x86emu/|\
23 ^src/device/oprom/yabel/|\
24 ^src/drivers/net/ne2k.c\$|\
25 ^src/drivers/xgi/common/initdef.h\$|\
26 ^src/drivers/xgi/common/vstruct.h\$|\
27 ^src/lib/gnat/|\
28 ^src/lib/lzmadecode.[ch]\$|\
29 ^src/lib/stack.c\$|\
30 ^src/sbom/TAGS|\
31 ^src/vendorcode/|\
32 ^tests/data/|\
33 ^util/amdtools/example_input/|\
34 ^util/cbfstool/lzma/|\
35 ^util/cbfstool/lz4/|\
36 ^util/kconfig/|\
37 Kconfig|\
38 \<COPYING\>|\
39 \<LICENSE\>|\
40 \<README\>|\
41 Changelog|\
42 AUTHORS|\
43 TODO|\
44 EXAMPLE|\
45 NEWS|\
46 ChangeLog|\
47 Dockerfile|\
48 \.gitignore$|\
49 \.in$|\
50 \.[18]$|\
51 \.md$|\
52 \.wiki$|\
53 \.xxdump$|\
54 \.spec$|\
55 \.txt$|\
56 \.jpg$|\
57 \.cksum$|\
58 \.bin$|\
59 \.vbt$|\
60 \.hex$|\
61 \.patch$|\
62 _shipped$|\
63 /microcode-[^/]*.h$|\
64 /sdram-.*\.inc$|\
65 \.fmd|\
66 \.cb|\
67 \.cfg$|\
68 \.spd|\
69 config|\
70 cmos\.layout|\
71 cmos\.default|\
72 \.apcb$\
75 #space separated list of directories to test
76 if [ "$1" = "" ]; then
77 HEADER_DIRS="src util"
78 else
79 HEADER_DIRS="$1"
83 #get initial list from git, removing HEADER_EXCLUDED files.
84 #make a copy to check for the old style header later.
85 headerlist=$(${FIND_FILES} $HEADER_DIRS | grep -E -v "($HEADER_EXCLUDED)")
87 LICENSE_ID_STRING="SPDX-License-Identifier"
89 #update headerlist by removing files that match the license string
90 check_for_license() {
91 if [ -n "$headerlist" ] && [ -z "$2" ]; then
92 headerlist="$(grep -iL "${LICENSE_ID_STRING}: $1" $headerlist 2>/dev/null)"
93 elif [ -n "$headerlist" ]; then
94 p1list="$(grep -il "${LICENSE_ID_STRING}: $1" $headerlist 2>/dev/null)"
95 p2list="$(grep -il "${LICENSE_ID_STRING}: $2" $headerlist 2>/dev/null)"
97 # Make list of files that were in both previous lists
98 pbothlist="$(echo $p1list $p2list | tr ' ' "\n" | \
99 sort | uniq -d)"
101 # Remove all files that were in both of the previous lists
102 # Note that this is unstable if we ever get any filenames
103 # with spaces.
104 headerlist="$(echo $headerlist $pbothlist | tr ' ' "\n" | \
105 sort | uniq -u)"
109 #search the files for license headers
110 check_for_license 'Apache-2.0'
111 check_for_license 'BSD-2-Clause'
112 check_for_license 'BSD-3-Clause'
113 check_for_license 'GPL-2.0-only'
114 check_for_license 'GPL-2.0-or-later'
115 check_for_license 'GPL-2.0-only WITH Linux-syscall-note'
116 check_for_license 'GPL-3.0-only'
117 check_for_license 'GPL-3.0-only WITH GCC-exception-3.1'
118 check_for_license 'GPL-3.0-or-later'
119 check_for_license 'HPND'
120 check_for_license 'HPND-sell-variant'
121 check_for_license 'ISC'
122 check_for_license 'MIT'
123 check_for_license 'X11'
125 # This is 4 clause ("with advertising") but the University of Berkeley
126 # declared that 4th clause void, see
127 # ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
128 # With this, BSD-4-Clause-UC becomes GPLv2 compatible, and so SPDX doesn't
129 # differentiate between this license with or without advertising.
130 check_for_license 'BSD-4-Clause-UC'
132 # This is the Creative Commons Public Domain Dedication and Certification
133 # for files that are already in the public domain. This includes files
134 # that cannot be licensed such as blank files or files with no "creative"
135 # content.
136 check_for_license 'CC-PDDC'
138 for file in $headerlist; do
139 # Verify the file actually exists
140 if [ -f "$file" ]; then
141 echo "$file has no recognized SPDX identifier."
143 done