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
10 cd -- "$
(dirname "$0")" > /dev/null 2>&1 || return
14 # shellcheck source=helper_functions.sh
15 .
"${LINTDIR}/helper_functions.sh"
17 # regex list of files and directories to exclude from the search
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\$|\
28 ^src/lib/lzmadecode.[ch]\$|\
32 ^util/amdtools/example_input/|\
33 ^util/cbfstool/lzma/|\
74 #space separated list of directories to test
75 if [ "$1" = "" ]; then
76 HEADER_DIRS
="src util"
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
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" | \
98 # Remove all files that were in both of the previous lists
99 # Note that this is unstable if we ever get any filenames
101 headerlist
="$(echo $headerlist $pbothlist | tr ' ' "\n" | \
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"
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."