util: Break up spdx identifier text in scripts & makefiles

The SPDX parsers can find the SPDX identifiers in the scripts and
makefiles if they aren't broken up. This unnecessarily confuses things
when we're doing license parsing.

Change-Id: I215ed047397f342c912f1a969315fa184a124f6a
Signed-off-by: Martin Roth <gaumless@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/80585
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Matt DeVillier <matt.devillier@amd.corp-partner.google.com>
Reviewed-by: Varshit Pandya <pandyavarshit@gmail.com>
This commit is contained in:
Martin Roth 2024-02-16 10:19:07 -07:00 committed by Felix Held
parent 3fc7a8f507
commit 1eccf77a78
3 changed files with 25 additions and 21 deletions

View File

@ -13,6 +13,7 @@ override objutil := ..
VBOOT_SOURCE ?= $(top)/3rdparty/vboot VBOOT_SOURCE ?= $(top)/3rdparty/vboot
VBOOT_HOST_BUILD ?= $(abspath $(objutil)/vboot_lib) VBOOT_HOST_BUILD ?= $(abspath $(objutil)/vboot_lib)
SPDX_ID_STRING := SPDX-License-Identifier
.PHONY: all .PHONY: all
all: cbfstool ifittool fmaptool rmodtool ifwitool cbfs-compression-tool elogtool cse_fpt cse_serger all: cbfstool ifittool fmaptool rmodtool ifwitool cbfs-compression-tool elogtool cse_fpt cse_serger
@ -54,7 +55,7 @@ linux_trampoline.c: linux_trampoline.S
$(CC) -m32 -o linux_trampoline linux_trampoline.S -ffreestanding -nostdlib -nostdinc -Wl,--defsym=_start=0 $(CC) -m32 -o linux_trampoline linux_trampoline.S -ffreestanding -nostdlib -nostdinc -Wl,--defsym=_start=0
$(OBJCOPY) -Obinary -j .data linux_trampoline trampoline $(OBJCOPY) -Obinary -j .data linux_trampoline trampoline
echo "/* This file is automatically generated. Do not manually change */" > trampoline.c echo "/* This file is automatically generated. Do not manually change */" > trampoline.c
echo "/* SPDX-License-Identifier: GPL-2.0-only */" >> trampoline.c echo "/* $(SPDX_ID_STRING): GPL-2.0-only */" >> trampoline.c
xxd -c 16 -i trampoline >> trampoline.c xxd -c 16 -i trampoline >> trampoline.c
mv trampoline.c linux_trampoline.c mv trampoline.c linux_trampoline.c
rm linux_trampoline trampoline rm linux_trampoline trampoline

View File

@ -12,6 +12,7 @@ set -u
scratch_file='' scratch_file=''
coreboot_top='' coreboot_top=''
pname='' pname=''
SPDX_ID_STRING="SPDX-License-Identifier"
cleanup() cleanup()
{ {
@ -41,7 +42,7 @@ usage()
update_copyright() update_copyright()
{ {
local spdx='/* SPDX-License-Identifier: BSD-3-Clause */' local spdx="/* ${SPDX_ID_STRING}: BSD-3-Clause */"
local f=$1 local f=$1
# replace existing copyright with empty lines # replace existing copyright with empty lines

View File

@ -84,13 +84,15 @@ fi
#make a copy to check for the old style header later. #make a copy to check for the old style header later.
headerlist=$(${FIND_FILES} $HEADER_DIRS | grep -E -v "($HEADER_EXCLUDED)") headerlist=$(${FIND_FILES} $HEADER_DIRS | grep -E -v "($HEADER_EXCLUDED)")
LICENSE_ID_STRING="SPDX-License-Identifier"
#update headerlist by removing files that match the license string #update headerlist by removing files that match the license string
check_for_license() { check_for_license() {
if [ -n "$headerlist" ] && [ -z "$2" ]; then if [ -n "$headerlist" ] && [ -z "$2" ]; then
headerlist="$(grep -iL "$1" $headerlist 2>/dev/null)" headerlist="$(grep -iL "${LICENSE_ID_STRING}: $1" $headerlist 2>/dev/null)"
elif [ -n "$headerlist" ]; then elif [ -n "$headerlist" ]; then
p1list="$(grep -il "$1" $headerlist 2>/dev/null)" p1list="$(grep -il "${LICENSE_ID_STRING}: $1" $headerlist 2>/dev/null)"
p2list="$(grep -il "$2" $headerlist 2>/dev/null)" p2list="$(grep -il "${LICENSE_ID_STRING}: $2" $headerlist 2>/dev/null)"
# Make list of files that were in both previous lists # Make list of files that were in both previous lists
pbothlist="$(echo $p1list $p2list | tr ' ' "\n" | \ pbothlist="$(echo $p1list $p2list | tr ' ' "\n" | \
@ -105,33 +107,33 @@ check_for_license() {
} }
#search the files for license headers #search the files for license headers
check_for_license 'SPDX-License-Identifier: Apache-2.0' check_for_license 'Apache-2.0'
check_for_license 'SPDX-License-Identifier: BSD-2-Clause' check_for_license 'BSD-2-Clause'
check_for_license 'SPDX-License-Identifier: BSD-3-Clause' check_for_license 'BSD-3-Clause'
check_for_license 'SPDX-License-Identifier: GPL-2.0-only' check_for_license 'GPL-2.0-only'
check_for_license 'SPDX-License-Identifier: GPL-2.0-or-later' check_for_license 'GPL-2.0-or-later'
check_for_license 'SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note' check_for_license 'GPL-2.0-only WITH Linux-syscall-note'
check_for_license 'SPDX-License-Identifier: GPL-3.0-only' check_for_license 'GPL-3.0-only'
check_for_license 'SPDX-License-Identifier: GPL-3.0-only WITH GCC-exception-3.1' check_for_license 'GPL-3.0-only WITH GCC-exception-3.1'
check_for_license 'SPDX-License-Identifier: GPL-3.0-or-later' check_for_license 'GPL-3.0-or-later'
check_for_license 'SPDX-License-Identifier: HPND' check_for_license 'HPND'
check_for_license 'SPDX-License-Identifier: HPND-sell-variant' check_for_license 'HPND-sell-variant'
check_for_license 'SPDX-License-Identifier: ISC' check_for_license 'ISC'
check_for_license 'SPDX-License-Identifier: MIT' check_for_license 'MIT'
check_for_license 'SPDX-License-Identifier: X11' check_for_license 'X11'
# This is 4 clause ("with advertising") but the University of Berkeley # This is 4 clause ("with advertising") but the University of Berkeley
# declared that 4th clause void, see # declared that 4th clause void, see
# ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change # 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 # With this, BSD-4-Clause-UC becomes GPLv2 compatible, and so SPDX doesn't
# differentiate between this license with or without advertising. # differentiate between this license with or without advertising.
check_for_license 'SPDX-License-Identifier: BSD-4-Clause-UC' check_for_license 'BSD-4-Clause-UC'
# This is the Creative Commons Public Domain Dedication and Certification # This is the Creative Commons Public Domain Dedication and Certification
# for files that are already in the public domain. This includes files # 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" # that cannot be licensed such as blank files or files with no "creative"
# content. # content.
check_for_license 'SPDX-License-Identifier: CC-PDDC' check_for_license 'CC-PDDC'
for file in $headerlist; do for file in $headerlist; do
# Verify the file actually exists # Verify the file actually exists