Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp987521ybe; Fri, 6 Sep 2019 10:09:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqy/xw4sUl3rLyf9R42L0JWP2gC2+GC8N7UkattZvbGlm675K727E/pLoO1OXFLbYDtZ61zg X-Received: by 2002:a65:620a:: with SMTP id d10mr8745361pgv.8.1567789761470; Fri, 06 Sep 2019 10:09:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567789761; cv=none; d=google.com; s=arc-20160816; b=vCBmrLRIfT7TttnnT50DmX2BRAXTATrJGae+Qh02mQH7a3i8V5nuTMyZq5Zf/UoaW9 9kUHjWNJg5z1pw1dT/BZ5ucDBBaVrQKUpBlR8/FiMAfDKe3aB2liJu4aPz5221k9kPUp Tkf344VcWsPYpXTxUwcUNGgXvKXXihs3c2cTVAA0iAc+IIL+LDmXdB+u3J2EJ6ZD7qu/ +7OdfRHi2T6LzKEgKJOi/VYPPDFilIax2jNI/VYyMj3oOMt7xgs3Y+QJX+4V+pmJ2uI7 QbK5QnQLs38ZcytiPPhBvLqm6OLOzeF74A+XlJBd/eLiNmHagJwu2PJc7W4zUH2jXDsE z7Vw== 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=BaJkMB0z7Fy2B1fYpEwhEuwf2lT0IavJbz0NGtBNe7A=; b=tsn7yzgNOLcyS6s8yYzeWv4oUtyTNL5u3DQ5uY3qZI0W5XrIFiSLOaiFn9ohbNmvpn 8ow//JscMVxqe066G//nMxIUQN8RMSiAzz9LAaUJlolQZc8V9MNMZjKdjio2E+jdS983 9Jz+3ZgDjkmqdUJSkqQC1j8Pegevq0pFzuouYf6yp4P6q6rMF5uywzug8ozI2xQoLyef JQMJ/NRU79VW0BV341oAiiCKyE3ZTmlNVlHtbjjiNT8LQLesrsXu0LlKo3Ns7ldyLu1R XFYQkw4u4h3RCAv7GV3U/agYIRaJdaRmsdd426Vz5eWVRrErMDhr6pT/JZV6WOvFcy8Q cOvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Yi4+2SyN; 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 w15si6610995pfj.149.2019.09.06.10.09.05; Fri, 06 Sep 2019 10:09:21 -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=Yi4+2SyN; 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 S2390097AbfIFLhU (ORCPT + 99 others); Fri, 6 Sep 2019 07:37:20 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:35432 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389971AbfIFLhU (ORCPT ); Fri, 6 Sep 2019 07:37:20 -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=BaJkMB0z7Fy2B1fYpEwhEuwf2lT0IavJbz0NGtBNe7A=; b=Yi4+2SyNocYccqH5MaR05tEwk UhWa7a8ZwoiMYGKa7iNi6YtrkC7IQm2mYtRRmN+DxRdmBy2ecV4WVuB9yc7r/UNYLHtYnAzP5yG6+ pvotiKG+LSMrLD04qx5Cy0drkF7LLJlwoa9r4PdTVL2j+lAwCiBPK+PN+OQY/ZlPPUiw0mi8Xu/3C bVTyfZ7DX+LAr5nqg4zh+6PiyTCsY8SEsZT3rTOsCotDT0jv3L6HUGtsQdkpAjJJgsUTjtNXj5t9g cGIyZYV+/6BFXcKN9ry/UVb0S8kLANNXsgUaT0E+C9DCd6DTBbuQZSE6Dq9x9BBlbE8yxyyF7mTae lvrOZvzBQ==; Received: from [177.159.253.249] (helo=coco.lan) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1i6CYJ-0005fo-2Y; Fri, 06 Sep 2019 11:37:19 +0000 Date: Fri, 6 Sep 2019 08:37:14 -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: <20190906083714.0cf7eb20@coco.lan> In-Reply-To: <20190906083457.7e7934ec@coco.lan> References: <20190905055614.7958918b@coco.lan> <88e638eb959095ab6657d295f9f8c27169569bf2.1567675272.git.mchehab+samsung@kernel.org> <20190905092703.GA30899@kroah.com> <20190905090701.37dcf75e@coco.lan> <20190906083457.7e7934ec@coco.lan> 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, 6 Sep 2019 08:34:57 -0300 Mauro Carvalho Chehab escreveu: > Em Thu, 05 Sep 2019 10:45:36 -0700 > Joe Perches escreveu: > > > On Thu, 2019-09-05 at 09:07 -0300, Mauro Carvalho Chehab wrote: > > > There are currently 227 files that don't complain with the "up to line 3" > > > rule, including COPYING (with should probably be excluded from the check). > > > > > > Patches are at: > > > > > > https://git.linuxtv.org/mchehab/experimental.git/log/?h=spdx_pedantic > > > > > > Btw, most violations are due to: > > > > > > /* > > > * SPDX... > > > > Hey Mauro. > > > > Here's a little script to move all of the improperly located > > SPDX-License-Identifier lines in [.ch] files. > > > > Using this command line: > > > > $ git grep -n 'SPDX-License-Identifier: ' -- '*.[ch]' | \ > > grep -v ':1:' | perl move_spdx.pl > > > > and > > > > $ cat move_spdx.pl > > while (<>) { > > /^([^:]+):([^:]+):(.*)/; > > my ($file, $line, $spdx) = ($1, $2, $3); > > $spdx =~ s/^\s*\/?\*\s*//; > > $spdx =~ s/\s*\*\/\s*$//; > > if ($file =~ /\.h$/) { > > $spdx = "/* $spdx */"; > > } else { > > $spdx = "// $spdx"; > > } > > open(FH, '<', $file) or die $!; > > my @lines = ; > > close FH; > > open(FH, '>', $file) or die $!; > > print FH "$spdx\n"; > > my $count = 0; > > foreach (@lines) { > > $count++; > > next if ($count == $line); > > next if ($count == $line - 1 && $_ =~ /^\s*\*\s*$/); > > next if ($count == $line + 1 && $_ =~ /^\s*\*\s*$/); > > print FH "$_"; > > } > > close FH; > > } > > > > which gives this diff for today's -next > > Nice script! > > I did some changes on it In time: I'm enclosing the modified script. just run it directly with: perl ./move_spdx.pl and it will move the SPDX headers where pertinent. Thanks, Mauro --- #!/usr/bin/perl @file_arr = qx(git grep -n 'SPDX-License-Identifier: ' | 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 m/(SPDX-License-Identifier:.*)/; $is_script = 0; if ($file =~ /\.(h|dts|dtsi|S)$/) { $spdx = "/* $spdx */"; } elsif ($file =~ /\.(c)$/) { $spdx = "// $spdx"; } elsif ($file =~ /\.(rst)$/) { $spdx = ".. $spdx"; } elsif ($file =~ /\.(py|pl|sh)$/ || !$file =~ /\./) { $is_script = 1; $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; }