From: "Daniel P. Berrangé" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Cédric Le Goater" <clg@kaod.org>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Daniel P. Berrangé" <berrange@redhat.com>
Subject: [PATCH v5 9/9] scripts/checkpatch: reject license boilerplate on new files
Date: Mon, 19 May 2025 18:10:04 +0100 [thread overview]
Message-ID: <20250519171004.352636-10-berrange@redhat.com> (raw)
In-Reply-To: <20250519171004.352636-1-berrange@redhat.com>
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é <berrange@redhat.com>
---
scripts/checkpatch.pl | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index dc2c3e6aa1..17b8db40ad 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -365,6 +365,18 @@ our @typeList = (
qr{guintptr},
);
+# Match text found in common license boilerplate comments:
+# for new files the SPDX-License-Identifier line is sufficient.
+our @LICENSE_BOILERPLATE = (
+ "licensed under the terms of the GNU GPL",
+ "under the terms of the GNU General Public License",
+ "under the terms of the GNU Lesser General Public",
+ "Permission is hereby granted, free of charge",
+ "GNU GPL, version 2 or later",
+ "See the COPYING file"
+);
+our $LICENSE_BOILERPLATE_RE = join("|", @LICENSE_BOILERPLATE);
+
# Load common spelling mistakes and build regular expression list.
my $misspellings;
my %spelling_fix;
@@ -1497,6 +1509,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, only " .
+ "the SPDX-License-Identifier, unless this file was " .
+ "copied from existing code already having such text.");
+ }
}
sub process {
@@ -1799,6 +1818,10 @@ sub process {
&checkspdx($realfile, $1);
}
+ if ($rawline =~ /$LICENSE_BOILERPLATE_RE/) {
+ $fileinfo->{facts}->{sawboilerplate} = 1;
+ }
+
if ($rawline =~ m,(SPDX-[a-zA-Z0-9-_]+):,) {
my $tag = $1;
my @permitted = qw(
--
2.49.0
next prev parent reply other threads:[~2025-05-19 17:11 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-19 17:09 [PATCH v5 0/9] scripts/checkpatch: fix SPDX-License-Identifier detection Daniel P. Berrangé
2025-05-19 17:09 ` [PATCH v5 1/9] Revert "scripts: mandate that new files have SPDX-License-Identifier" Daniel P. Berrangé
2025-05-19 17:09 ` [PATCH v5 2/9] scripts/checkpatch.pl: fix various indentation mistakes Daniel P. Berrangé
2025-05-19 17:09 ` [PATCH v5 3/9] scripts/checkpatch: introduce tracking of file start/end Daniel P. Berrangé
2025-05-19 17:09 ` [PATCH v5 4/9] scripts/checkpatch: use new hook for ACPI test data check Daniel P. Berrangé
2025-05-19 17:10 ` [PATCH v5 5/9] scripts/checkpatch: use new hook for file permissions check Daniel P. Berrangé
2025-05-19 17:10 ` [PATCH v5 6/9] scripts/checkpatch: expand pattern for matching makefiles Daniel P. Berrangé
2025-05-19 17:10 ` [PATCH v5 7/9] scripts/checkpatch: use new hook for MAINTAINERS update check Daniel P. Berrangé
2025-05-19 17:10 ` [PATCH v5 8/9] scripts/checkpatch: reimplement mandate for SPDX-License-Identifier Daniel P. Berrangé
2025-05-19 17:10 ` Daniel P. Berrangé [this message]
2025-05-19 17:24 ` [PATCH v5 9/9] scripts/checkpatch: reject license boilerplate on new files Peter Maydell
2025-05-19 17:25 ` Cédric Le Goater
2025-05-21 9:05 ` [PATCH v5 10/9] scripts/checkpatch.pl: mandate SPDX tag for Rust src files Daniel P. Berrangé
2025-05-21 17:18 ` Manos Pitsidianakis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250519171004.352636-10-berrange@redhat.com \
--to=berrange@redhat.com \
--cc=clg@kaod.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).