2010-11-19 11:16:43 +01:00
|
|
|
#!/bin/sh
|
|
|
|
# This file is part of the coreboot project.
|
|
|
|
#
|
|
|
|
# Copyright (C) 2010 coresystems GmbH
|
2016-01-12 18:25:49 +01:00
|
|
|
# Copyright (C) 2016 Google Inc.
|
2010-11-19 11:16:43 +01:00
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; version 2 of the License.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
#
|
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
|
|
|
|
|
|
|
|
# regex list of files and directories to exclude from the search
|
|
|
|
HEADER_EXCLUDED="\
|
2018-05-27 03:47:07 +02:00
|
|
|
^src/lib/gnat/|\
|
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/|\
|
2016-01-12 18:25:49 +01:00
|
|
|
^util/kconfig/|\
|
|
|
|
Kconfig|\
|
|
|
|
\<COPYING\>|\
|
|
|
|
\<LICENSE\>|\
|
|
|
|
\<README\>|\
|
|
|
|
Changelog|\
|
|
|
|
TODO|\
|
|
|
|
EXAMPLE|\
|
2018-05-27 03:47:07 +02:00
|
|
|
NEWS|\
|
|
|
|
ChangeLog|\
|
|
|
|
Dockerfile|\
|
|
|
|
\.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
|
|
|
Makefile\.inc|\
|
|
|
|
\.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
|
|
|
"
|
|
|
|
|
2019-09-24 02:14:34 +02:00
|
|
|
HEADER_TEXT="license header"
|
|
|
|
|
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
|
|
|
|
2019-09-24 02:14:34 +02:00
|
|
|
if [ "$2" = "SPDX_ONLY" ]; then
|
|
|
|
SPDX_ONLY=1
|
|
|
|
HEADER_TEXT="SPDX identifier"
|
|
|
|
fi
|
|
|
|
|
2010-11-19 11:16:43 +01:00
|
|
|
LC_ALL=C export LC_ALL
|
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.
|
|
|
|
headerlist=$(git ls-files $HEADER_DIRS | egrep -v "($HEADER_EXCLUDED)")
|
|
|
|
|
|
|
|
#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'
|
|
|
|
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'
|
|
|
|
check_for_license 'SPDX-License-Identifier: GPL-3.0-only'
|
|
|
|
check_for_license 'SPDX-License-Identifier: GPL-3.0-or-later'
|
|
|
|
check_for_license 'SPDX-License-Identifier: ISC'
|
|
|
|
check_for_license 'SPDX-License-Identifier: MIT'
|
|
|
|
check_for_license 'SPDX-License-Identifier: X11'
|
|
|
|
|
|
|
|
if [ ! "${SPDX_ONLY}" = "1" ]; then
|
2016-01-21 21:20:39 +01:00
|
|
|
check_for_license "under the terms of the GNU General Public License" \
|
|
|
|
"WITHOUT ANY WARRANTY"
|
2016-01-12 18:25:49 +01:00
|
|
|
check_for_license 'IS PROVIDED .*"AS IS"'
|
2016-04-11 21:35:59 +02:00
|
|
|
check_for_license 'IS DISTRIBUTED .*"AS IS"'
|
2016-01-12 18:25:49 +01:00
|
|
|
check_for_license "IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE"
|
|
|
|
check_for_license '"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES'
|
2017-04-04 22:35:42 +02:00
|
|
|
check_for_license 'assumes any liability or responsibility for the use'
|
|
|
|
check_for_license 'THE AUTHORS DISCLAIM.*ALL WARRANTIES WITH REGARD TO THIS SOFTWARE'
|
2016-04-11 21:35:59 +02:00
|
|
|
check_for_license 'No license required'
|
2018-05-27 03:47:07 +02:00
|
|
|
check_for_license 'GNU Lesser General Public'
|
2019-09-24 02:14:34 +02:00
|
|
|
fi
|
2016-01-12 18:25:49 +01:00
|
|
|
|
|
|
|
for file in $headerlist; do
|
2017-02-10 01:44:24 +01:00
|
|
|
# Verify the file exists, and has content that requires a header
|
|
|
|
# This assumes that a file that has 4 lines or fewer is not notable
|
|
|
|
# enough to require a license.
|
|
|
|
if [ -f "$file" ] && [ "$(wc -l < "$file")" -gt 4 ]; then
|
2019-09-24 02:14:34 +02:00
|
|
|
echo "$file has no recognized ${HEADER_TEXT}."
|
2016-01-12 18:25:49 +01:00
|
|
|
fi
|
|
|
|
done
|