On Thu, May 15, 2025 at 02:59:36PM +0100, Daniel P. Berrangé wrote:
> 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é <[email protected]>
> ---
> 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}) {
/face-palm - I forgot to remove the '!' here so the check is
inverted and my test patch had two very similarly named files
so didn't notice it :-(
> + 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
>
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|