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="\
|
|
|
|
^src/vendorcode/|\
|
|
|
|
^util/kconfig/|\
|
|
|
|
^util/romcc/tests|\
|
|
|
|
^util/romcc/results|\
|
|
|
|
^util/gitconfig|\
|
|
|
|
Kconfig|\
|
|
|
|
\<COPYING\>|\
|
|
|
|
\<LICENSE\>|\
|
|
|
|
\<README\>|\
|
|
|
|
Changelog|\
|
|
|
|
TODO|\
|
|
|
|
EXAMPLE|\
|
|
|
|
\.txt$|\
|
|
|
|
\.jpg$|\
|
|
|
|
\.cksum$|\
|
|
|
|
\.bin$|\
|
|
|
|
\.hex$|\
|
|
|
|
\.patch$|\
|
|
|
|
_shipped$|\
|
|
|
|
/microcode-[^/]*.h$|\
|
|
|
|
/sdram-.*\.inc$|\
|
|
|
|
Makefile\.inc\
|
|
|
|
"
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
|
|
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-01-21 21:20:39 +01:00
|
|
|
if [ -z "$2" ]; then
|
|
|
|
headerlist="$(grep -iL "$1" $headerlist 2>/dev/null)"
|
|
|
|
else
|
|
|
|
local p1list="$(grep -il "$1" $headerlist 2>/dev/null)"
|
|
|
|
local p2list="$(grep -il "$2" $headerlist 2>/dev/null)"
|
|
|
|
|
|
|
|
# Make list of files that were in both previous lists
|
|
|
|
local pbothlist="$(echo $p1list $p2list | tr ' ' "\n" | \
|
|
|
|
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
|
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"'
|
|
|
|
check_for_license "IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE"
|
|
|
|
check_for_license '"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES'
|
|
|
|
|
|
|
|
for file in $headerlist; do
|
|
|
|
#verify the file exists, and has content that requires a header
|
|
|
|
if [ -f "$file" ] && [ "$(wc -l < "$file")" -ne 0 ]; then
|
|
|
|
echo "$file has no recognized license header."
|
|
|
|
fi
|
|
|
|
done
|