aboutsummaryrefslogtreecommitdiffstats
path: root/tools/check-copyright.sh
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2020-02-18 16:02:42 +0100
committerDmitry Vyukov <dvyukov@google.com>2020-02-18 16:05:10 +0100
commit135c18aadb0147f93d3e2658e42fc7a479b9ad04 (patch)
tree74ba2b3a708ebe1f06a79adb73e4b44785ba4d95 /tools/check-copyright.sh
parent012fbc3229ebef871a201ea431b16610e6e0d345 (diff)
tools: add script that checks copyright headers
Fixes #1604
Diffstat (limited to 'tools/check-copyright.sh')
-rwxr-xr-xtools/check-copyright.sh21
1 files changed, 21 insertions, 0 deletions
diff --git a/tools/check-copyright.sh b/tools/check-copyright.sh
new file mode 100755
index 000000000..86067564c
--- /dev/null
+++ b/tools/check-copyright.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+# Copyright 2020 syzkaller project authors. All rights reserved.
+# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
+
+FILES=0
+FAILED=""
+for F in $(find -name "*.go" -o -name "*.sh" -o \( -path "./sys/*/*.txt" \) | egrep -v "/vendor/|/gen/"); do
+ ((FILES+=1))
+ cat $F | tr '\n' '_' | egrep "(//|#) Copyright 20[0-9]{2}(/20[0-9]{2})? syzkaller project authors\. All rights reserved\._(//|#) Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file\." >/dev/null
+ if [ $? -eq 0 ]; then continue; fi
+ # Ignore auto-generated files.
+ egrep "(//|#) AUTOGENERATED FILE|(WARNING: This file is machine generated)" $F >/dev/null
+ if [ $? -eq 0 ]; then continue; fi
+ # Ignore untracked files.
+ git ls-files --error-unmatch $F >/dev/null 2>&1
+ if [ $? -ne 0 ]; then continue; fi
+ echo "$F: does not have standard copyright statement"
+ FAILED="1"
+done
+if [ "$FAILED" != "" ]; then exit 1; fi
+echo "$FILES files checked for copyright statement"