Skip to content

Commit

Permalink
checkpatch: validate SPDX license with spdxcheck.py
Browse files Browse the repository at this point in the history
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/[email protected]
Signed-off-by: Joe Perches <[email protected]>
Acked-by: Rob Herring <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
JoePerches authored and torvalds committed Aug 22, 2018
1 parent 8c8c45c commit 3b6e8ac
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions scripts/checkpatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,16 @@ sub is_maintained_obsolete {
return $status =~ /obsolete/i;
}

sub is_SPDX_License_valid {
my ($license) = @_;

return 1 if (!$tree || which("python") eq "" || !(-e "$root/scripts/spdxcheck.py"));

my $status = `echo "$license" | python $root/scripts/spdxcheck.py -`;
return 0 if ($status ne "");
return 1;
}

my $camelcase_seeded = 0;
sub seed_camelcase_includes {
return if ($camelcase_seeded);
Expand Down Expand Up @@ -2978,8 +2988,14 @@ sub process {

if ($comment !~ /^$/ &&
$rawline !~ /^\+\Q$comment\E SPDX-License-Identifier: /) {
WARN("SPDX_LICENSE_TAG",
"Missing or malformed SPDX-License-Identifier tag in line $checklicenseline\n" . $herecurr);
WARN("SPDX_LICENSE_TAG",
"Missing or malformed SPDX-License-Identifier tag in line $checklicenseline\n" . $herecurr);
} elsif ($rawline =~ /(SPDX-License-Identifier: .*)/) {
my $spdx_license = $1;
if (!is_SPDX_License_valid($spdx_license)) {
WARN("SPDX_LICENSE_TAG",
"'$spdx_license' is not supported in LICENSES/...\n" . $herecurr);
}
}
}
}
Expand Down

0 comments on commit 3b6e8ac

Please sign in to comment.