From: Greg KH <gregkh@linuxfoundation.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>,
Andrew Morton <akpm@linux-foundation.org>,
Kate Stewart <kstewart@linuxfoundation.org>,
Philippe Ombredanne <pombredanne@nexb.com>,
Thomas Gleixner <tglx@linutronix.de>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [GIT PULL] License cleanup: add SPDX license identifiers to some kernel files
Date: Thu, 2 Nov 2017 18:45:42 +0100 [thread overview]
Message-ID: <20171102174542.GB27444@kroah.com> (raw)
In-Reply-To: <CA+55aFycwb--5x3B7uCV8L=9SLsqJr0pHaSf3oKrT-sy8=7tpg@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1064 bytes --]
On Thu, Nov 02, 2017 at 10:32:17AM -0700, Linus Torvalds wrote:
> On Thu, Nov 2, 2017 at 10:25 AM, Linus Torvalds
> <torvalds@linux-foundation.org> wrote:
> >
> > So to me, the "just put it as the first syntactically possible line,
> > and just always use the same comment format" is simply to avoid
> > unnecessary arguments/conflicts about which of any number of ways you
> > *could* do it.
>
> Side note: I'm not going to enforce it, it's just a personal wish to
> hopefully make my life easier.
>
> This pull request from Greg already has different comment formats for
> different files. I pulled it despite that.
It should have been consistent, everything except the script files went
as the first line of the file.
For .h files, we had to use /* */
For .c files, we used //
For scripts, and asm, we used the comment "marker" that was used in the
file already.
Attached is the script written by Thomas and tweaked by me to do all of
the tag insertion based on a csv file, it picks the format based on the
name and content of the file.
thanks,
greg k-h
[-- Attachment #2: spdxtags2.py --]
[-- Type: text/x-python, Size: 3311 bytes --]
#!/usr/bin/env python
#
import sys
import os
def insert_at(srclines, pos, tag, style):
if style == '/*':
srclines.insert(pos, '/* SPDX-License-Identifier: %s */\n' %tag)
else:
srclines.insert(pos, '%s SPDX-License-Identifier: %s\n' %(style, tag))
return True
def handle_c(srclines, tag):
return insert_at(srclines, 0, tag, '//')
def is_script(srclines):
for line in srclines:
line.lstrip();
if line.startswith('#!'):
return True;
return False;
def handle_asm(srclines, tag):
# Stupid search for a proper style to comment the SPDX tag
pos = 0
style = None
for line in srclines:
pos += 1
line.lstrip();
if line.startswith(';;;'):
style = ';;;'
elif line.startswith(';;'):
style = ';;'
elif line.startswith(';'):
style = ';'
elif line.startswith('|'):
style = '|'
elif line.startswith('!'):
style = '!'
elif line.startswith('//'):
style = '//'
elif line.find("/*") >= 0:
style = '/*'
else:
# default to /* if we have no clue
style = '/*'
return insert_at(srclines, 0, tag, style)
return False
def handle_sh(srclines, tag):
return insert_at(srclines, 1, tag, '#')
tf = open(sys.argv[1])
for entry in tf.readlines():
if len(entry.strip()) == 0:
continue
nr, fname, tag = entry.strip().split(',')
# FIXME: Use a proper encoder
fname = fname.replace('%2C',',')
fname = fname.replace('%2B','+')
if tag == 'NOTAG':
print("Skipping %s" %fname)
continue
if not os.path.isfile(fname):
print("FAIL: File %s does not exist anymore" %fname)
continue
bname = os.path.basename(fname)
srclines = open(fname).readlines()
done = False
for line in srclines:
if line.find('SPDX-License-Identifier') >= 0:
done = True
break
if done:
print("SPDX id exists already in %s" %fname)
continue
ok = False
if fname.endswith('.h') or fname.endswith('.lds'):
ok = insert_at(srclines, 0, tag, '/*')
elif fname.endswith('.cpp'):
ok = insert_at(srclines, 0, tag, '//')
elif fname.endswith('.c') or fname.endswith('.uc'):
ok = handle_c(srclines, tag)
elif fname.endswith('.S'):
ok = handle_asm(srclines, tag)
elif fname.endswith('.cocci'):
ok = insert_at(srclines, 0, tag, '//')
elif fname.endswith('.dts') or fname.endswith('.dtsi'):
ok = insert_at(srclines, 0, tag, '//')
elif fname.endswith('.py') or fname.endswith('.tc') or fname.endswith('.sh') or fname.endswith('.pl'):
ok = insert_at(srclines, 1, tag, '#')
elif bname.startswith('Makefile') or bname.startswith('Kconfig') or bname.startswith('Kbuild'):
ok = insert_at(srclines, 0, tag, '#')
elif is_script(srclines):
ok = insert_at(srclines, 1, tag, "#")
else:
print("Unhandled or ignored file %s" %fname)
continue
if ok:
open(fname, 'w').writelines(srclines)
print("Inserted %s into %s" %(tag, fname))
else:
print("FAIL: No place for insertion found %s" %fname)
next prev parent reply other threads:[~2017-11-02 17:45 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-02 15:16 [GIT PULL] License cleanup: add SPDX license identifiers to some kernel files Greg KH
2017-11-02 17:09 ` Masahiro Yamada
2017-11-02 17:25 ` Linus Torvalds
2017-11-02 17:32 ` Linus Torvalds
2017-11-02 17:45 ` Greg KH [this message]
2017-11-02 17:52 ` Linus Torvalds
2017-11-02 18:02 ` Greg KH
2017-11-02 18:18 ` Linus Torvalds
2017-11-02 18:21 ` Thomas Gleixner
2017-11-02 18:53 ` Linus Torvalds
2017-11-02 17:25 ` Greg KH
2017-11-08 23:07 ` Rob Herring
2017-11-09 13:40 ` Greg KH
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=20171102174542.GB27444@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=akpm@linux-foundation.org \
--cc=kstewart@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pombredanne@nexb.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=yamada.masahiro@socionext.com \
/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