Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp2105356ybe; Sat, 7 Sep 2019 08:58:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqwnF9ZuPXarvb/NwDoENM9QBccss5UToCURLW3Er7pcK7ABZF1MXpdHY55tpzY/UaItkC/G X-Received: by 2002:a17:902:b582:: with SMTP id a2mr870795pls.240.1567871939655; Sat, 07 Sep 2019 08:58:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567871939; cv=none; d=google.com; s=arc-20160816; b=uOofNGtkwX5oL9QGaF5EVGxbKMaNnOmWID3O0A9fPqutKAMsAp64I+xWvrwcxWuoD7 Ig/0fb85Kh2gLiMPMI5RIXhlgu0MPp+h0ZRVxpX70jwDxHXiuR6JIPROThIlPKVtdKPe XiJ2ZIQ5PS0KqWK4nC+QLuJopQhpDcZsq/jUEKQUGPBzmZOV/mz/C+NDInpkwJxqFC3f Cj+N9+qQhqxZH45sY+VWsxHdZTD1vpsApq1dEMyKf8VOhezlcQNiOHkckqellGxPfvCp nxhNKD+wsh0o0R2qiqt6vz30HOvQuiEU7HNlWFfAsm9ToANvD0JRtB2Rxeuvu3YLovza TkuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=AN/xZn55x9Paj2FV2HROTLrpQ/d1Z8rdQtqFNYMx15k=; b=xTuDzQk/awMtfF00lDhxrga9MwT1yqn7L0f2RnAkJTTzwS/h8S7R8KNfLFLb5fGjMQ +RYT7aK9E563kEZQyMjao0s98hL+cac9hjhH/d+1XT80TFZMgqOZ0TIiTwAZrw2If/Ib EWlXIr+gdPwq0Bw+LnkQEOhkt0oVj9y84yds+lceSE6iEeWn0sDHZJ8vaqcb5AIUEmp7 c84CSisMzHTXfq59u2aWD3M4lz0PdCXJ/TsRAZ5V7RU+X/n/KVZJLqSMood2JrDwUpoM 0MPGZRsoCpC+XQ5iD/wDKQbAShLV+hX45BUScFNpgVF6Mily8I2KUnkl0/3xpqG670OR 0Arw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=a2LyxNAI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b23si6719210pju.69.2019.09.07.08.58.44; Sat, 07 Sep 2019 08:58:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=a2LyxNAI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2436517AbfIFSRK (ORCPT + 99 others); Fri, 6 Sep 2019 14:17:10 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:46442 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404380AbfIFSRK (ORCPT ); Fri, 6 Sep 2019 14:17:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Subject:Cc:To: From:Date:Sender:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=AN/xZn55x9Paj2FV2HROTLrpQ/d1Z8rdQtqFNYMx15k=; b=a2LyxNAI0Lcsqgpec/cV6Geyu csa/ODYVy4viu6nyQy7lzVgeX7GpkedJsMEKqTRisl8Wqr+6K0CjKYsjdhaxFUi6VTOMC0v1sIWBU BAoQDAixwLCwGLSHROyiiFLjlJXVuTUMAszBhwQBr1TiJeGkDbSpEWUymdCo5+2aqlyJFYZXawsHh D+tLRpYT0rOC4GqQsUfo3GFdznIQ/nBbsUSEdT0bb4M87lFTgalcf1If/McWLOusags15Jnk+Kg8d JG6c/nJ+yLbOSAqk/vDFStx05rvTAxpwoe3uFDutK/ZPKAEVYaPExSpKGtX4Y2ypCaXvvEpe2yk/e gVtYrPU6w==; Received: from [177.159.253.249] (helo=coco.lan) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1i6InE-00047a-18; Fri, 06 Sep 2019 18:17:08 +0000 Date: Fri, 6 Sep 2019 15:17:02 -0300 From: Mauro Carvalho Chehab To: Joe Perches Cc: Greg Kroah-Hartman , Linux Media Mailing List , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org, Jonathan Corbet , Jessica Yu , Federico Vaga , Thomas Gleixner , linux-doc@vger.kernel.org Subject: Re: [PATCH] docs: license-rules.txt: cover SPDX headers on Python scripts Message-ID: <20190906151702.3e67ccf7@coco.lan> In-Reply-To: <9d30210a2d024aae4c36c8995019cdeab29e1e19.camel@perches.com> References: <20190905055614.7958918b@coco.lan> <88e638eb959095ab6657d295f9f8c27169569bf2.1567675272.git.mchehab+samsung@kernel.org> <20190905092703.GA30899@kroah.com> <20190905090701.37dcf75e@coco.lan> <20190906083457.7e7934ec@coco.lan> <9d30210a2d024aae4c36c8995019cdeab29e1e19.camel@perches.com> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Fri, 06 Sep 2019 10:33:42 -0700 Joe Perches 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 = ; 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; }