2020-12-24 20:06:38 +01:00
|
|
|
#!/usr/bin/env sh
|
2010-11-19 11:16:43 +01:00
|
|
|
#
|
util/: Replace GPLv2 boiler plate with SPDX header
Used commands:
perl -i -p0e 's|\/\*[\s*]*.*is free software[:;][\s*]*you[\s*]*can[\s*]*redistribute[\s*]*it[\s*]*and\/or[\s*]*modify[\s*]*it[\s*]*under[\s*]*the[\s*]*terms[\s*]*of[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*as[\s*]*published[\s*]*by[\s*]*the[\s*]*Free[\s*]*Software[\s*]*Foundation[;,][\s*]*version[\s*]*2[\s*]*of[\s*]*the[\s*]*License.[\s*]*This[\s*]*program[\s*]*is[\s*]*distributed[\s*]*in[\s*]*the[\s*]*hope[\s*]*that[\s*]*it[\s*]*will[\s*]*be[\s*]*useful,[\s*]*but[\s*]*WITHOUT[\s*]*ANY[\s*]*WARRANTY;[\s*]*without[\s*]*even[\s*]*the[\s*]*implied[\s*]*warranty[\s*]*of[\s*]*MERCHANTABILITY[\s*]*or[\s*]*FITNESS[\s*]*FOR[\s*]*A[\s*]*PARTICULAR[\s*]*PURPOSE.[\s*]*See[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*for[\s*]*more[\s*]*details.[\s*]*\*\/|/* SPDX-License-Identifier: GPL-2.0-only */|' $(cat filelist)
perl -i -p0e 's|This[\s*]*program[\s*]*is[\s*]*free[\s*]*software[:;][\s*]*you[\s*]*can[\s*]*redistribute[\s*]*it[\s*]*and/or[\s*]*modify[\s*]*it[\s*]*under[\s*]*the[\s*]*terms[\s*]*of[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*as[\s*]*published[\s*]*by[\s*]*the[\s*]*Free[\s*]*Software[\s*]*Foundation[;,][\s*]*either[\s*]*version[\s*]*2[\s*]*of[\s*]*the[\s*]*License,[\s*]*or[\s*]*.at[\s*]*your[\s*]*option.*[\s*]*any[\s*]*later[\s*]*version.[\s*]*This[\s*]*program[\s*]*is[\s*]*distributed[\s*]*in[\s*]*the[\s*]*hope[\s*]*that[\s*]*it[\s*]*will[\s*]*be[\s*]*useful,[\s*]*but[\s*]*WITHOUT[\s*]*ANY[\s*]*WARRANTY;[\s*]*without[\s*]*even[\s*]*the[\s*]*implied[\s*]*warranty[\s*]*of[\s*]*MERCHANTABILITY[\s*]*or[\s*]*FITNESS[\s*]*FOR[\s*]*A[\s*]*PARTICULAR[\s*]*PURPOSE.[\s*]*See[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*for[\s*]*more[\s*]*details.[\s*]*\*\/|/* SPDX-License-Identifier: GPL-2.0-or-later */|' $(cat filelist)
perl -i -p0e 's|\/\*[\s*]*.*This[\s*#]*program[\s*#]*is[\s*#]*free[\s*#]*software[;:,][\s*#]*you[\s*#]*can[\s*#]*redistribute[\s*#]*it[\s*#]*and/or[\s*#]*modify[\s*#]*it[\s*#]*under[\s*#]*the[\s*#]*terms[\s*#]*of[\s*#]*the[\s*#]*GNU[\s*#]*General[\s*#]*Public[\s*#]*License[\s*#]*as[\s*#]*published[\s*#]*by[\s*#]*the[\s*#]*Free[\s*#]*Software[\s*#]*Foundation[;:,][\s*#]*either[\s*#]*version[\s*#]*3[\s*#]*of[\s*#]*the[\s*#]*License[;:,][\s*#]*or[\s*#]*.at[\s*#]*your[\s*#]*option.*[\s*#]*any[\s*#]*later[\s*#]*version.[\s*#]*This[\s*#]*program[\s*#]*is[\s*#]*distributed[\s*#]*in[\s*#]*the[\s*#]*hope[\s*#]*that[\s*#]*it[\s*#]*will[\s*#]*be[\s*#]*useful[;:,][\s*#]*but[\s*#]*WITHOUT[\s*#]*ANY[\s*#]*WARRANTY[;:,][\s*#]*without[\s*#]*even[\s*#]*the[\s*#]*implied[\s*#]*warranty[\s*#]*of[\s*#]*MERCHANTABILITY[\s*#]*or[\s*#]*FITNESS[\s*#]*FOR[\s*#]*A[\s*#]*PARTICULAR[\s*#]*PURPOSE.[\s*#]*See[\s*#]*the[\s*#]*GNU[\s*#]*General[\s*#]*Public[\s*#]*License[\s*#]*for[\s*#]*more[\s*#]*details.[\s*]*\*\/|/* SPDX-License-Identifier: GPL-3.0-or-later */|' $(cat filelist)
perl -i -p0e 's|(\#\#*)[\w]*.*is free software[:;][\#\s]*you[\#\s]*can[\#\s]*redistribute[\#\s]*it[\#\s]*and\/or[\#\s]*modify[\#\s]*it[\s\#]*under[\s \#]*the[\s\#]*terms[\s\#]*of[\s\#]*the[\s\#]*GNU[\s\#]*General[\s\#]*Public[\s\#]*License[\s\#]*as[\s\#]*published[\s\#]*by[\s\#]*the[\s\#]*Free[\s\#]*Software[\s\#]*Foundation[;,][\s\#]*version[\s\#]*2[\s\#]*of[\s\#]*the[\s\#]*License.*[\s\#]*This[\s\#]*program[\s\#]*is[\s\#]*distributed[\s\#]*in[\s\#]*the[\s\#]*hope[\s\#]*that[\s\#]*it[\s\#]*will[\#\s]*be[\#\s]*useful,[\#\s]*but[\#\s]*WITHOUT[\#\s]*ANY[\#\s]*WARRANTY;[\#\s]*without[\#\s]*even[\#\s]*the[\#\s]*implied[\#\s]*warranty[\#\s]*of[\#\s]*MERCHANTABILITY[\#\s]*or[\#\s]*FITNESS[\#\s]*FOR[\#\s]*A[\#\s]*PARTICULAR[\#\s]*PURPOSE.[\#\s]*See[\#\s]*the[\#\s]*GNU[\#\s]*General[\#\s]*Public[\#\s]*License[\#\s]*for[\#\s]*more[\#\s]*details.\s(#* *\n)*|\1 SPDX-License-Identifier: GPL-2.0-only\n\n|' $(cat filelist)
perl -i -p0e 's|(\#\#*)[\w*]*.*is free software[:;][\s*]*you[\s*]*can[\s*]*redistribute[\s*]*it[\s*]*and\/or[\s*]*modify[\s*]*it[\s*]*under[\s*]*the[\s*]*terms[\s*]*of[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*as[\s*]*published[\s*]*by[\s*]*the[\s*]*Free[\s*]*Software[\s*]*Foundation[;,][\s*]*version[\s*]*2[\s*]*of[\s*]*the[\s*]*License.[\s*]*This[\s*]*program[\s*]*is[\s*]*distributed[\s*]*in[\s*]*the[\s*]*hope[\s*]*that[\s*]*it[\s*]*will[\s*]*be[\s*]*useful,[\s*]*but[\s*]*WITHOUT[\s*]*ANY[\s*]*WARRANTY;[\s*]*without[\s*]*even[\s*]*the[\s*]*implied[\s*]*warranty[\s*]*of[\s*]*MERCHANTABILITY[\s*]*or[\s*]*FITNESS[\s*]*FOR[\s*]*A[\s*]*PARTICULAR[\s*]*PURPOSE.[\s*]*See[\s*]*the[\s*]*GNU[\s*]*General[\s*]*Public[\s*]*License[\s*]*for[\s*]*more[\s*]*details.\s(#* *\n)*|\1 SPDX-License-Identifier: GPL-2.0-only\n\n|' $(cat filelist)
Change-Id: I1008a63b804f355a916221ac994701d7584f60ff
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/41177
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2020-05-08 20:48:04 +02:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
|
2016-01-12 18:25:49 +01:00
|
|
|
# DESCR: Check that files in have valid license headers
|
|
|
|
# $1 is an optional command line parameter containing directories to check
|
|
|
|
|
2022-06-03 08:06:57 +02:00
|
|
|
|
|
|
|
LINTDIR="$(
|
|
|
|
cd -- "$(dirname "$0")" > /dev/null 2>&1 || return
|
|
|
|
pwd -P
|
|
|
|
)"
|
|
|
|
|
|
|
|
# shellcheck source=helper_functions.sh
|
|
|
|
. "${LINTDIR}/helper_functions.sh"
|
|
|
|
|
2016-01-12 18:25:49 +01:00
|
|
|
# regex list of files and directories to exclude from the search
|
|
|
|
HEADER_EXCLUDED="\
|
2020-05-10 16:34:10 +02:00
|
|
|
^src/commonlib/bsd/lz4.c.inc\$|\
|
|
|
|
^src/cpu/x86/16bit/entry16.inc\$|\
|
|
|
|
^src/device/oprom/x86emu/|\
|
|
|
|
^src/device/oprom/include/x86emu/|\
|
|
|
|
^src/device/oprom/yabel/|\
|
2020-05-18 21:36:58 +02:00
|
|
|
^src/drivers/net/ne2k.c\$|\
|
2020-05-10 16:34:10 +02:00
|
|
|
^src/drivers/xgi/common/initdef.h\$|\
|
|
|
|
^src/drivers/xgi/common/vstruct.h\$|\
|
2018-05-27 03:47:07 +02:00
|
|
|
^src/lib/gnat/|\
|
2020-05-10 16:34:10 +02:00
|
|
|
^src/lib/lzmadecode.[ch]\$|\
|
|
|
|
^src/lib/stack.c\$|\
|
2022-08-22 20:08:40 +02:00
|
|
|
^src/sbom/TAGS|\
|
2016-01-12 18:25:49 +01:00
|
|
|
^src/vendorcode/|\
|
2018-05-27 03:47:07 +02:00
|
|
|
^util/amdtools/example_input/|\
|
|
|
|
^util/cbfstool/lzma/|\
|
2020-05-10 16:34:10 +02:00
|
|
|
^util/cbfstool/lz4/|\
|
2016-01-12 18:25:49 +01:00
|
|
|
^util/kconfig/|\
|
|
|
|
Kconfig|\
|
|
|
|
\<COPYING\>|\
|
|
|
|
\<LICENSE\>|\
|
|
|
|
\<README\>|\
|
|
|
|
Changelog|\
|
2020-09-08 20:25:44 +02:00
|
|
|
AUTHORS|\
|
2016-01-12 18:25:49 +01:00
|
|
|
TODO|\
|
|
|
|
EXAMPLE|\
|
2018-05-27 03:47:07 +02:00
|
|
|
NEWS|\
|
|
|
|
ChangeLog|\
|
|
|
|
Dockerfile|\
|
2022-08-08 01:17:41 +02:00
|
|
|
\.gitignore$|\
|
2018-05-27 03:47:07 +02:00
|
|
|
\.in$|\
|
|
|
|
\.[18]$|\
|
|
|
|
\.md$|\
|
|
|
|
\.wiki$|\
|
|
|
|
\.xxdump$|\
|
|
|
|
\.spec$|\
|
2016-01-12 18:25:49 +01:00
|
|
|
\.txt$|\
|
|
|
|
\.jpg$|\
|
|
|
|
\.cksum$|\
|
|
|
|
\.bin$|\
|
2018-05-04 17:19:07 +02:00
|
|
|
\.vbt$|\
|
2016-01-12 18:25:49 +01:00
|
|
|
\.hex$|\
|
|
|
|
\.patch$|\
|
|
|
|
_shipped$|\
|
|
|
|
/microcode-[^/]*.h$|\
|
|
|
|
/sdram-.*\.inc$|\
|
2016-04-11 21:35:59 +02:00
|
|
|
\.fmd|\
|
2016-10-27 19:43:37 +02:00
|
|
|
\.cb|\
|
2016-04-11 21:35:59 +02:00
|
|
|
\.cfg$|\
|
|
|
|
\.spd|\
|
|
|
|
config|\
|
|
|
|
cmos\.layout|\
|
|
|
|
cmos\.default\
|
2016-01-12 18:25:49 +01:00
|
|
|
"
|
|
|
|
|
|
|
|
#space separated list of directories to test
|
|
|
|
if [ "$1" = "" ]; then
|
|
|
|
HEADER_DIRS="src util"
|
|
|
|
else
|
|
|
|
HEADER_DIRS="$1"
|
|
|
|
fi
|
2010-11-19 11:16:43 +01:00
|
|
|
|
2016-01-12 18:25:49 +01:00
|
|
|
|
|
|
|
#get initial list from git, removing HEADER_EXCLUDED files.
|
|
|
|
#make a copy to check for the old style header later.
|
2023-04-01 14:42:54 +02:00
|
|
|
headerlist=$(${FIND_FILES} $HEADER_DIRS | grep -E -v "($HEADER_EXCLUDED)")
|
2016-01-12 18:25:49 +01:00
|
|
|
|
|
|
|
#update headerlist by removing files that match the license string
|
|
|
|
check_for_license() {
|
2016-04-11 21:35:59 +02:00
|
|
|
if [ -n "$headerlist" ] && [ -z "$2" ]; then
|
2016-01-21 21:20:39 +01:00
|
|
|
headerlist="$(grep -iL "$1" $headerlist 2>/dev/null)"
|
2016-04-11 21:35:59 +02:00
|
|
|
elif [ -n "$headerlist" ]; then
|
|
|
|
p1list="$(grep -il "$1" $headerlist 2>/dev/null)"
|
|
|
|
p2list="$(grep -il "$2" $headerlist 2>/dev/null)"
|
2016-01-21 21:20:39 +01:00
|
|
|
|
|
|
|
# Make list of files that were in both previous lists
|
2016-04-11 21:35:59 +02:00
|
|
|
pbothlist="$(echo $p1list $p2list | tr ' ' "\n" | \
|
2016-01-21 21:20:39 +01:00
|
|
|
sort | uniq -d)"
|
|
|
|
|
|
|
|
# Remove all files that were in both of the previous lists
|
|
|
|
# Note that this is unstable if we ever get any filenames
|
|
|
|
# with spaces.
|
|
|
|
headerlist="$(echo $headerlist $pbothlist | tr ' ' "\n" | \
|
|
|
|
sort | uniq -u)"
|
|
|
|
fi
|
2016-01-12 18:25:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#search the files for license headers
|
2019-09-24 02:14:34 +02:00
|
|
|
check_for_license 'SPDX-License-Identifier: Apache-2.0'
|
2020-05-10 19:56:54 +02:00
|
|
|
check_for_license 'SPDX-License-Identifier: BSD-2-Clause'
|
2019-09-24 02:14:34 +02:00
|
|
|
check_for_license 'SPDX-License-Identifier: BSD-3-Clause'
|
|
|
|
check_for_license 'SPDX-License-Identifier: GPL-2.0-only'
|
|
|
|
check_for_license 'SPDX-License-Identifier: GPL-2.0-or-later'
|
2020-03-27 21:12:47 +01:00
|
|
|
check_for_license 'SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note'
|
2019-09-24 02:14:34 +02:00
|
|
|
check_for_license 'SPDX-License-Identifier: GPL-3.0-only'
|
2022-08-08 01:10:36 +02:00
|
|
|
check_for_license 'SPDX-License-Identifier: GPL-3.0-only WITH GCC-exception-3.1'
|
2019-09-24 02:14:34 +02:00
|
|
|
check_for_license 'SPDX-License-Identifier: GPL-3.0-or-later'
|
2020-05-10 21:19:04 +02:00
|
|
|
check_for_license 'SPDX-License-Identifier: HPND'
|
|
|
|
check_for_license 'SPDX-License-Identifier: HPND-sell-variant'
|
2019-09-24 02:14:34 +02:00
|
|
|
check_for_license 'SPDX-License-Identifier: ISC'
|
|
|
|
check_for_license 'SPDX-License-Identifier: MIT'
|
|
|
|
check_for_license 'SPDX-License-Identifier: X11'
|
|
|
|
|
2020-03-04 14:58:49 +01:00
|
|
|
# This is 4 clause ("with advertising") but the University of Berkeley
|
|
|
|
# declared that 4th clause void, see
|
|
|
|
# ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
|
|
|
|
# With this, BSD-4-Clause-UC becomes GPLv2 compatible, and so SPDX doesn't
|
|
|
|
# differentiate between this license with or without advertising.
|
|
|
|
check_for_license 'SPDX-License-Identifier: BSD-4-Clause-UC'
|
|
|
|
|
2022-08-04 20:20:29 +02:00
|
|
|
# This is the Creative Commons Public Domain Dedication and Certification
|
|
|
|
# for files that are already in the public domain. This includes files
|
|
|
|
# that cannot be licensed such as blank files or files with no "creative"
|
|
|
|
# content.
|
|
|
|
check_for_license 'SPDX-License-Identifier: CC-PDDC'
|
|
|
|
|
2016-01-12 18:25:49 +01:00
|
|
|
for file in $headerlist; do
|
2022-08-08 01:21:17 +02:00
|
|
|
# Verify the file actually exists
|
|
|
|
if [ -f "$file" ]; then
|
2020-05-18 21:25:18 +02:00
|
|
|
echo "$file has no recognized SPDX identifier."
|
2016-01-12 18:25:49 +01:00
|
|
|
fi
|
|
|
|
done
|