Hello,

I've suggested to Misha in the past a design where a basic and simple lic_check.sh script would live in the root repository and then each child repo (jdk, langtools, hotspot, etc.) would have a repo-specific license checking script that would encode all the expected values and per-repo rules.

As a simple example, for langtools a first approximation of the expected license rules would be

    # GPL with ClassPath exception expected on normal sources...
    ../make/scripts/lic_check.sh -gplcp `find src "*.java"`

    # but GPL without ClassPath expected expected on tests
    ../make/scripts/lic_check.sh -gpl   `find tests "*.java"

(The full check of langtools would have to account for various exceptions, such as the tests that need to have /nodynamiccopyright/, etc.)

-Joe

On 6/4/2012 5:48 PM, Jonathan Gibbons wrote:
Misha,

"It would be nice" if you could infer the default license type from the type and/or location of file.

"It would be nice" if it could default the set of files to the set of recently modified files, such as determined by "hg status".

-- Jon

On 06/04/2012 04:53 PM, Misha Bykov wrote:

Please, review the webrev is located at:

http://cr.openjdk.java.net/~mbykov/lic_check/webrev.00/

INTRO

It's recommended for a developer, when he introduced or modified source code files, to check whether a license header is precisely correct for every modified file.

The new script allows a JDK developer to check if the specified license header for a given file (or a set of files) matches the right header template.

NAME

lic_check.sh - JDK source code legal headers conformance verification

SYNOPSIS

lic_check.sh [-gpl] or [-gplcp] or [-bsd] file(s)

DESCRIPTION

The script for OpenJDK distribution to verify legal notices in a particular source file or a set of files.

The script must be located in the directory:

$ROOT/make/scripts

It uses templates from:

$ROOT/make/templates

The successful output example:

###
### Checking copyright notice in the file: filename.java
###
No differences encountered
SUCCESS: The license header for filename.java has been verified.

The unsuccessful output example if Oracle copyright string is missing or copyright years are not correct :

###
### Checking copyright notice in the file: filename.java
###
ERROR: Copyright string is not correct or missing in filename.java.

If the copyright string is correct, but the license header is not correct, the script should produce the "diff" output between a template in $ROOT/make/templates and the license header from the given file.

HOW TO TEST

1. Place the script into $ROOT/make/scripts in JDK8 source repository (otherwise it will not find $ROOT/make/templates and produce an error).
2. cd to the directory with the files to check license headers
3. $ROOT/make/scripts/lic_check.sh [-gpl] or [-gplcp] or [-bsd] filename(s)

SUCCESS EXAMPLE

% ./lic_check.sh -gpl update_copyright_year.sh
### Checking copyright notice in the file: update_copyright_year.sh
###
No differences encountered
SUCCESS: The license header for jdk8/make/scripts/update_copyright_year.sh has been verified.
###

FAILURE EXAMPLE

% ./lic_check.sh -gpl hgforest.sh
### Checking copyright notice in the file: hgforest.sh
###
*** /tmp/source_file.9122       Mon Jun  4 17:44:11 2012
--- jdk8/make/scripts/./../templates/gpl-header Wed Apr 11 08:53:09 2012
***************
*** 1,7 ****
Copyright (c) %YEARS% Oracle and/or its affiliates. All rights reserved.
 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.

! This code is free software; you can redistribute it and/or modify itX
 under the terms of the GNU General Public License version 2 only, as
 published by the Free Software Foundation.

--- 1,7 ----
Copyright (c) %YEARS% Oracle and/or its affiliates. All rights reserved.
 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.

! This code is free software; you can redistribute it and/or modify it
 under the terms of the GNU General Public License version 2 only, as
 published by the Free Software Foundation.

ERROR: License header is not correct in /java/jle_build/headers/jdk8/make/scripts/hgforest.sh
See diffs above.
###


NEXT STEPS

In the future, this script will be used by special scripts to allow headers verification in the whole OpenJDK source code base.


Reply via email to