[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190906151702.3e67ccf7@coco.lan>
Date: Fri, 6 Sep 2019 15:17:02 -0300
From: Mauro Carvalho Chehab <mchehab+samsung@...nel.org>
To: Joe Perches <joe@...ches.com>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Linux Media Mailing List <linux-media@...r.kernel.org>,
Mauro Carvalho Chehab <mchehab@...radead.org>,
linux-kernel@...r.kernel.org, Jonathan Corbet <corbet@....net>,
Jessica Yu <jeyu@...nel.org>,
Federico Vaga <federico.vaga@...a.pv.it>,
Thomas Gleixner <tglx@...utronix.de>, linux-doc@...r.kernel.org
Subject: Re: [PATCH] docs: license-rules.txt: cover SPDX headers on Python
scripts
Em Fri, 06 Sep 2019 10:33:42 -0700
Joe Perches <joe@...ches.com> escreveu:
> On Fri, 2019-09-06 at 08:34 -0300, Mauro Carvalho Chehab wrote:
> > I did some changes on it, plus one change at the pedantic mode of
> > scripts/spdxcheck.py, and placed the corresponding patches at:
> >
> > https://git.linuxtv.org/mchehab/experimental.git/log/?h=spdx_pedantic
>
> Your script needs a modification of this line:
It is yours script, I just made a few improvements for it to also catch
scripts.
> $spdx = $1 if m/(SPDX-License-Identifier:.*)/;
>
> This is on $_ and not $spdx.
>
> This line needs to be:
>
> $spdx = $1 if $spdx =~ m/(SPDX-License-Identifier:.*)/;
Gah, true!
It also doesn't get the case where SPDX-License-Identifier: is
followed by a tab, and fixed an issue when detecting files without
any extension.
The enclosed script does a better job.
I changed the output of it on my testing branch:
https://git.linuxtv.org/mchehab/experimental.git/log/?h=spdx_pedantic
The only thing that it doesn't change is an issue with an asm code,
with uses "@" for comments.
As this is a single file, better to do it manually:
https://git.linuxtv.org/mchehab/experimental.git/commit/?h=spdx_pedantic&id=f1b7b2169ae2c8d8ab80a5997ebef9aa03a42d30
Thanks,
Mauro
---
#!/usr/bin/perl
@file_arr = qx(git grep -nE 'SPDX-License-Identifier:\\s' | grep -v ':1:');
foreach (@file_arr) {
/^([^:]+):([^:]+):(.*)/;
my ($file, $line, $spdx) = ($1, $2, $3);
next if ($file =~ m,(COPYING|LICENSES/|sha1-armv4-large.S),);
next if ($line > 10);
$spdx =~ s/^\s*\/?\*\s*//;
$spdx =~ s/\s*\*\/\s*$//;
$spdx = $1 if $spdx =~ m/(SPDX-License-Identifier:.*)/;
$spdx =~ s/(SPDX-License-Identifier:)\s+/$1 /;
if ($file =~ /\.(h|dts|dtsi|S)$/) {
$spdx = "/* $spdx */";
} elsif ($file =~ /\.(c)$/) {
$spdx = "// $spdx";
} elsif ($file =~ /\.(rst)$/) {
$spdx = ".. $spdx";
} elsif ($file =~ /\.(py|pl|sh|tc)$/ || !($file =~ /\./)) {
$spdx = "# $spdx";
} else {
next;
}
open(FH, '<', $file) or die $!;
my @lines = <FH>;
close FH;
open(FH, '>', $file) or die $!;
my $count = 0;
my $print_spdx = 1;
foreach (@lines) {
$count++;
if ($print_spdx) {
if ($count == 1 && (/:orphan:/ || /^#\!/)) {
print FH "$_";
next;
}
if ($count <= 2 && /^[ \t\f]*#.*?coding[:=][ \t]*([-_.a-zA-Z0-9]+)/) {
print FH "$_";
next;
}
print FH "$spdx\n";
$print_spdx = 0;
}
next if ($count == $line);
next if ($count == $line - 1 && $_ =~ /^\s*\*\s*$/);
next if ($count == $line + 1 && $_ =~ /^\s*\*\s*$/);
next if ($count == $line - 1 && $_ =~ /^$/);
print FH "$_";
}
close FH;
}
Powered by blists - more mailing lists