[coreboot-gerrit] Patch set updated for coreboot: util/lint: Update license linter

Martin Roth (martinroth@google.com) gerrit at coreboot.org
Tue Jan 12 21:09:24 CET 2016


Martin Roth (martinroth at google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/12909

-gerrit

commit a8ce58d48813d8edf032427fb4d021035ea511ce
Author: Martin Roth <martinroth at google.com>
Date:   Tue Jan 12 10:25:49 2016 -0700

    util/lint: Update license linter
    
    - Split the script up to make it easier to update and read.
    - Check for multiple different licenses. Not all files are GPL licensed.
    - Don't validate 0 length files
    - Update list of files to exclude from the license header check.
    - Check for files containing the old style GPL header.
    
    Change-Id: I90d4e93a20b4e1638ce4f43f8acbee72dc588625
    Signed-off-by: Martin Roth <martinroth at google.com>
---
 util/lint/lint-000-license-headers | 62 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 60 insertions(+), 2 deletions(-)

diff --git a/util/lint/lint-000-license-headers b/util/lint/lint-000-license-headers
index 3c75ddf..239806f 100755
--- a/util/lint/lint-000-license-headers
+++ b/util/lint/lint-000-license-headers
@@ -2,6 +2,7 @@
 # This file is part of the coreboot project.
 #
 # Copyright (C) 2010 coresystems GmbH
+# Copyright (C) 2016 Google Inc.
 #
 # 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
@@ -15,6 +16,63 @@
 #
 # DESCR: Check that all files in src/ and util/ have valid license headers
 
+# regex list of files and directories to exclude from the search
+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
+INCLUDED="src util"
+
 LC_ALL=C export LC_ALL
-grep -L "You should have received a copy of the GNU General Public License" `git ls-files src util |egrep -v "(^3rdparty|^src/vendorcode/|^util/kconfig/|^util/romcc/tests|\<COPYING\>|\<LICENSE\>|\<README\>|_shipped$|\.patch$|/microcode-[^/]*.h$)"` | \
-	sed -e "s,^.*$,File & has no valid GPL header.,"
+
+#get initial list from git, removing excluded files.
+#make a copy to check for the old style header later.
+filelist=$(git ls-files $INCLUDED | egrep -v "($EXCLUDED)")
+oldheaderlist="$filelist"
+
+#update filelist by removing files that match the license string
+check_for_license() {
+	filelist=$(grep -iL "$1" $filelist 2>/dev/null)
+}
+
+#search the files for license headers
+check_for_license "GNU General Public License"
+check_for_license 'IS PROVIDED .*"AS IS"'
+check_for_license "IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE"
+
+for file in $filelist; 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
+
+#check for the old style header
+oldheaderlist=$(grep -il "You should have received a copy of the GNU" \
+	$oldheaderlist 2>/dev/null)
+
+for file in $oldheaderlist; do
+	echo "$file has the old GPL header."
+done



More information about the coreboot-gerrit mailing list