The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	Kate Stewart <kstewart@linuxfoundation.org>,
	Philippe Ombredanne <pombredanne@nexb.com>
Subject: Re: [PATCH] USB: add SPDX identifiers to all files in drivers/usb/
Date: Thu, 19 Oct 2017 10:50:44 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.20.1710191045140.1971@nanos> (raw)
In-Reply-To: <20171019083832.GA21820@kroah.com>

[-- Attachment #1: Type: text/plain, Size: 1137 bytes --]

On Thu, 19 Oct 2017, Greg Kroah-Hartman wrote:

> It's good to have SPDX identifiers in all files to make it easier to
> audit the kernel tree for correct licenses.  This patch adds these
> identifiers to all files in drivers/usb/ based on a script and data from
> Thomas Gleixner, Philippe Ombredanne, and Kate Stewart.
> 
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Kate Stewart <kstewart@linuxfoundation.org>
> Cc: Philippe Ombredanne <pombredanne@nexb.com>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> Unless someone really complains, I'm going to add this to my tree for
> 4.15-rc1.
> 
> 
> diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
> index 9650b351c26c..cb8d902b801d 100644
> --- a/drivers/usb/Makefile
> +++ b/drivers/usb/Makefile
> @@ -1,6 +1,7 @@
>  #
>  # Makefile for the kernel USB device drivers.
>  #
> +# SPDX-License-Identifier: GPL-2.0

The last discussion about this was to add the identifier as the first line
of the file or as the second in case of files with a shebang in the first
one.

I think you missed the last version of the script. Attached.

Thanks,

	tglx




[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-python; name=spdxtags2.py, Size: 2749 bytes --]

#!/usr/bin/env python
#
import sys
import os

def insert_at(srclines, pos, tag, style):
    srclines.insert(pos, '%s SPDX-License-Identifier: %s\n' %(style, tag))
    return True

def handle_c_h(srclines, tag):
    return insert_at(srclines, 0, tag, '//')

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
        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.startswith("/*"):
            style = '//'
        else:
            continue
        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',',')
    if tag == 'NOTAG':
        print("Skipping %s" %fname)
        continue

    if not os.path.isfile(fname):
        print("FAIL: File %s does not exist anymore" %fname)
        continue
    
    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('.c') or fname.endswith('.h') or fname.endswith('.uc'):
        ok = handle_c_h(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'):
        ok = insert_at(srclines, 1, tag, '#')

    elif fname.endswith('Makefile') or fname.find('Kconfig') > 0 or fname.find('Kbuild') > 0:
        ok = insert_at(srclines, 0, 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)



  parent reply	other threads:[~2017-10-19  8:50 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-19  8:38 [PATCH] USB: add SPDX identifiers to all files in drivers/usb/ Greg Kroah-Hartman
2017-10-19  8:49 ` Geert Uytterhoeven
2017-10-19  8:52   ` Greg Kroah-Hartman
2017-10-19  9:10     ` Geert Uytterhoeven
2017-10-19  9:15       ` Thomas Gleixner
2017-10-19  9:27     ` Felipe Balbi
2017-10-19  8:50 ` Thomas Gleixner [this message]
2017-10-19  8:57   ` Greg Kroah-Hartman
2017-10-19  8:59   ` Greg Kroah-Hartman
2017-10-19  9:01     ` Thomas Gleixner
2017-10-19  9:10       ` Greg Kroah-Hartman
2017-10-19 10:55         ` Philippe Ombredanne
2017-10-20 17:49         ` Alan Cox
2017-10-21  7:46           ` Greg Kroah-Hartman
2017-10-20 15:26 ` Rob Herring
2017-10-21  7:48   ` Greg Kroah-Hartman
2017-10-24 10:36     ` Philippe Ombredanne
2017-11-03 10:28 ` [PATCH v2] USB: add SPDX identifiers to all remaining " Greg Kroah-Hartman
2017-11-03 10:29   ` Greg Kroah-Hartman
2017-11-03 10:50   ` Felipe Balbi
2017-11-03 12:08     ` Greg Kroah-Hartman
2017-11-03 16:53   ` Johan Hovold
2017-11-04 10:40     ` Greg Kroah-Hartman
2017-11-05 12:53       ` Philippe Ombredanne
2017-11-05 13:51         ` Greg Kroah-Hartman
2017-11-05 15:39           ` Philippe Ombredanne
2017-11-06  8:17             ` Greg Kroah-Hartman
2017-11-09  9:51   ` Pavel Machek
2017-11-09 10:40     ` Greg Kroah-Hartman
2017-11-09 10:42       ` Pavel Machek

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=alpine.DEB.2.20.1710191045140.1971@nanos \
    --to=tglx@linutronix.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=kstewart@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=pombredanne@nexb.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