soc/intel/xeon_sp: Drop uncore_fill_ssdt
[coreboot2.git] / util / lint / lint-000-license-headers
blob68bdae7bad3dfe10b9dc4a648c1e26f9f6a030ae
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 ^util/amdtools/example_input/|\
33 ^util/cbfstool/lzma/|\
34 ^util/cbfstool/lz4/|\
35 ^util/kconfig/|\
36 Kconfig|\
37 \<COPYING\>|\
38 \<LICENSE\>|\
39 \<README\>|\
40 Changelog|\
41 AUTHORS|\
42 TODO|\
43 EXAMPLE|\
44 NEWS|\
45 ChangeLog|\
46 Dockerfile|\
47 \.gitignore$|\
48 \.in$|\
49 \.[18]$|\
50 \.md$|\
51 \.wiki$|\
52 \.xxdump$|\
53 \.spec$|\
54 \.txt$|\
55 \.jpg$|\
56 \.cksum$|\
57 \.bin$|\
58 \.vbt$|\
59 \.hex$|\
60 \.patch$|\
61 _shipped$|\
62 /microcode-[^/]*.h$|\
63 /sdram-.*\.inc$|\
64 \.fmd|\
65 \.cb|\
66 \.cfg$|\
67 \.spd|\
68 config|\
69 cmos\.layout|\
70 cmos\.default\
71 \.apcb$|\
74 #space separated list of directories to test
75 if [ "$1" = "" ]; then
76 HEADER_DIRS="src util"
77 else
78 HEADER_DIRS="$1"
82 #get initial list from git, removing HEADER_EXCLUDED files.
83 #make a copy to check for the old style header later.
84 headerlist=$(${FIND_FILES} $HEADER_DIRS | grep -E -v "($HEADER_EXCLUDED)")
86 #update headerlist by removing files that match the license string
87 check_for_license() {
88 if [ -n "$headerlist" ] && [ -z "$2" ]; then
89 headerlist="$(grep -iL "$1" $headerlist 2>/dev/null)"
90 elif [ -n "$headerlist" ]; then
91 p1list="$(grep -il "$1" $headerlist 2>/dev/null)"
92 p2list="$(grep -il "$2" $headerlist 2>/dev/null)"
94 # Make list of files that were in both previous lists
95 pbothlist="$(echo $p1list $p2list | tr ' ' "\n" | \
96 sort | uniq -d)"
98 # Remove all files that were in both of the previous lists
99 # Note that this is unstable if we ever get any filenames
100 # with spaces.
101 headerlist="$(echo $headerlist $pbothlist | tr ' ' "\n" | \
102 sort | uniq -u)"
106 #search the files for license headers
107 check_for_license 'SPDX-License-Identifier: Apache-2.0'
108 check_for_license 'SPDX-License-Identifier: BSD-2-Clause'
109 check_for_license 'SPDX-License-Identifier: BSD-3-Clause'
110 check_for_license 'SPDX-License-Identifier: GPL-2.0-only'
111 check_for_license 'SPDX-License-Identifier: GPL-2.0-or-later'
112 check_for_license 'SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note'
113 check_for_license 'SPDX-License-Identifier: GPL-3.0-only'
114 check_for_license 'SPDX-License-Identifier: GPL-3.0-only WITH GCC-exception-3.1'
115 check_for_license 'SPDX-License-Identifier: GPL-3.0-or-later'
116 check_for_license 'SPDX-License-Identifier: HPND'
117 check_for_license 'SPDX-License-Identifier: HPND-sell-variant'
118 check_for_license 'SPDX-License-Identifier: ISC'
119 check_for_license 'SPDX-License-Identifier: MIT'
120 check_for_license 'SPDX-License-Identifier: X11'
122 # This is 4 clause ("with advertising") but the University of Berkeley
123 # declared that 4th clause void, see
124 # ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
125 # With this, BSD-4-Clause-UC becomes GPLv2 compatible, and so SPDX doesn't
126 # differentiate between this license with or without advertising.
127 check_for_license 'SPDX-License-Identifier: BSD-4-Clause-UC'
129 # This is the Creative Commons Public Domain Dedication and Certification
130 # for files that are already in the public domain. This includes files
131 # that cannot be licensed such as blank files or files with no "creative"
132 # content.
133 check_for_license 'SPDX-License-Identifier: CC-PDDC'
135 for file in $headerlist; do
136 # Verify the file actually exists
137 if [ -f "$file" ]; then
138 echo "$file has no recognized SPDX identifier."
140 done