aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2018-08-22 00:57:47 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-08-22 13:52:48 -0400
commit3b6e8ac9e740b71b07df4a1e89ba5841686d8e9f (patch)
tree2223a323f0df172a7e149403f3ecfae5cc659813 /scripts
parent8c8c45cfdd5d8dd555da0d13c1d53b48f99ffe6f (diff)
checkpatch: validate SPDX license with spdxcheck.py
Use the existing scripts/spdxcheck.py to validate any SPDX-License-Identifier found in line 1 or 2 of patches or files. Miscellanea: o Properly indent the existing SPDX-License-Identifier block. Link: http://lkml.kernel.org/r/05b832407b24e0a27e419906187cd863bc1617c7.camel@perches.com Signed-off-by: Joe Perches <joe@perches.com> Acked-by: Rob Herring <robh@kernel.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/checkpatch.pl20
1 files changed, 18 insertions, 2 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 34e4683de7a3..4523dd6d0476 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -849,6 +849,16 @@ sub is_maintained_obsolete {
849 return $status =~ /obsolete/i; 849 return $status =~ /obsolete/i;
850} 850}
851 851
852sub is_SPDX_License_valid {
853 my ($license) = @_;
854
855 return 1 if (!$tree || which("python") eq "" || !(-e "$root/scripts/spdxcheck.py"));
856
857 my $status = `echo "$license" | python $root/scripts/spdxcheck.py -`;
858 return 0 if ($status ne "");
859 return 1;
860}
861
852my $camelcase_seeded = 0; 862my $camelcase_seeded = 0;
853sub seed_camelcase_includes { 863sub seed_camelcase_includes {
854 return if ($camelcase_seeded); 864 return if ($camelcase_seeded);
@@ -2978,8 +2988,14 @@ sub process {
2978 2988
2979 if ($comment !~ /^$/ && 2989 if ($comment !~ /^$/ &&
2980 $rawline !~ /^\+\Q$comment\E SPDX-License-Identifier: /) { 2990 $rawline !~ /^\+\Q$comment\E SPDX-License-Identifier: /) {
2981 WARN("SPDX_LICENSE_TAG", 2991 WARN("SPDX_LICENSE_TAG",
2982 "Missing or malformed SPDX-License-Identifier tag in line $checklicenseline\n" . $herecurr); 2992 "Missing or malformed SPDX-License-Identifier tag in line $checklicenseline\n" . $herecurr);
2993 } elsif ($rawline =~ /(SPDX-License-Identifier: .*)/) {
2994 my $spdx_license = $1;
2995 if (!is_SPDX_License_valid($spdx_license)) {
2996 WARN("SPDX_LICENSE_TAG",
2997 "'$spdx_license' is not supported in LICENSES/...\n" . $herecurr);
2998 }
2983 } 2999 }
2984 } 3000 }
2985 } 3001 }