The previous commit mandates use of SPDX-License-Identifier on common
source files, and encourages it on all other files.

Some contributors are none the less still also including the license
boilerplate text. This is redundant and will potentially cause
trouble if inconsistent with the SPDX declaration.

Match common boilerplate text blurbs and report them as invalid,
for newly added files.

Signed-off-by: Daniel P. Berrangé <berra...@redhat.com>
---
 scripts/checkpatch.pl | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 87050e6677..cb1942c021 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1496,6 +1496,13 @@ sub process_end_of_file {
                             "' need 'SPDX-License-Identifier'?");
                }
        }
+       if ($fileinfo->{action} eq "new" &&
+           !exists $fileinfo->{facts}->{sawboilerplate}) {
+               ERROR("New file '" . $fileinfo->{filenew} . "' must " .
+                     "not have license boilerplate header text unless " .
+                     "this file is copied from existing code with such " .
+                     "text already present.");
+       }
 }
 
 sub process {
@@ -1798,6 +1805,15 @@ sub process {
                        &checkspdx($realfile, $1);
                }
 
+               if ($rawline =~ /licensed under the terms of the GNU GPL/ ||
+                   $rawline =~ /under the terms of the GNU General Public 
License/ ||
+                   $rawline =~ /under the terms of the GNU Lesser General 
Public/ ||
+                   $rawline =~ /Permission is hereby granted, free of charge/ 
||
+                   $rawline =~ /GNU GPL, version 2 or later/ ||
+                   $rawline =~ /See the COPYING file/) {
+                       $fileinfo->{facts}->{sawboilerplate} = 1;
+               }
+
                if ($rawline =~ m,(SPDX-[a-zA-Z0-9-_]+):,) {
                        my $tag = $1;
                        my @permitted = qw(
-- 
2.49.0


Reply via email to