Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

license checker #1181

Merged
merged 1 commit into from
Jun 17, 2014
Merged

license checker #1181

merged 1 commit into from
Jun 17, 2014

Conversation

LudwigKnuepfer
Copy link
Member

Compares all source files against regular expressions for licenses and creates a file structure with files named after licenses that contain a list of files that apply to the respective license. E.g:

$ ./check.sh
$ wc -l out/*
    2 out/1c-BSD
   11 out/1c-BSD-ccnl
   12 out/1c-BSD-embunit
    2 out/1c-BSD-isc
    1 out/2c-BSD-v1
    2 out/3c-BSD-atmel
    1 out/3c-BSD-clark
   26 out/3c-BSD-openbsd
    3 out/3c-BSD-ti
    1 out/3c-BSD-v1
    4 out/3c-BSD-v2
    1 out/chan
    0 out/gplv2-short-v1
   10 out/gplv2-v1
    0 out/gplv3-short-v1
    0 out/gplv3-v1
    0 out/gplv3-v2
    0 out/lgpl-short-broken-grammar
  192 out/lgpl-short-riot
    5 out/lgplv2.1-v1
   33 out/lgplv2-short-v1
   25 out/lgplv2-short-v2
   16 out/lgplv2-short-v3
    1 out/publicdomain-v1
    8 out/unknown
  356 total
$ cat out/publicdomain-v1 
boards/msba2-common/tools/src/pseudoterm.c

@LudwigKnuepfer
Copy link
Member Author

Should we integrate this into Travis? I could just return 1 (indicate an error) if some unknown license is detected.

@OlegHahm
Copy link
Member

As I pointed out during on of the recent developer meetings: I'm not in favor of such checks in the CI system, because that would blurs real building and testing issues.

@LudwigKnuepfer
Copy link
Member Author

I guess someone should implement this against the github API then in order to tag the PR accordingly.

@LudwigKnuepfer
Copy link
Member Author

Broken licenses are a real issue...

@thomaseichinger
Copy link
Member

current output is

wc -l out/*
    2 out/1c-BSD
   11 out/1c-BSD-ccnl
   12 out/1c-BSD-embunit
    2 out/1c-BSD-isc
    1 out/2c-BSD-v1
    2 out/3c-BSD-atmel
    1 out/3c-BSD-clark
   26 out/3c-BSD-openbsd
    3 out/3c-BSD-ti
    1 out/3c-BSD-v1
    4 out/3c-BSD-v2
    1 out/chan
    0 out/gplv2-short-v1
   10 out/gplv2-v1
    0 out/gplv3-short-v1
    0 out/gplv3-v1
    0 out/gplv3-v2
    0 out/lgpl-short-broken-grammar
  208 out/lgpl-short-riot
    5 out/lgplv2.1-v1
   33 out/lgplv2-short-v1
   25 out/lgplv2-short-v2
   11 out/lgplv2-short-v3
    1 out/publicdomain-v1
    7 out/unknown
  366 total

shall we fix the unknown licenses to close #392?

cat out/unknown
boards/msba2-common/tools/src/boot_23xx.c
boards/msba2-common/tools/src/boot_2xxx.c
boards/msba2-common/tools/src/control_2xxx.c
cpu/arm_common/atomic.s
cpu/arm_common/common.s
cpu/lpc2387/asmfunc.s
cpu/lpc2387/startup.s

#!/bin/sh

# customizable
LICENSEDIR=patterns
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use ${VarName:-Default} to have a default string/fallback expression. If $VarName is undeclared or empty, then Default is used. Default can be an expression like ${VarName2:-${VarName3}}, too.
I am not sure if that is POSIX, but the plain Bourne shell and BASH support it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think this will actually be used? I'm too lazy to think of new names right now...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With a probability bordering on certainty not.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I'm not doing it then.

@Kijewski
Copy link
Contributor

I like 👍.

@LudwigKnuepfer
Copy link
Member Author

I'd remove the regular expressions for license strings that have been replaced already.

@OlegHahm OlegHahm modified the milestones: Release NEXT MAJOR, Release 2014.05 May 21, 2014
@LudwigKnuepfer
Copy link
Member Author

I think it's in a merge-able state now.

@LudwigKnuepfer
Copy link
Member Author

squash?

@LudwigKnuepfer LudwigKnuepfer changed the title license checker WIP license checker Jun 11, 2014
@OlegHahm
Copy link
Member

Gogogo.

@LudwigKnuepfer
Copy link
Member Author

squashed & rebased.

@Kijewski
Copy link
Contributor

Maybe use

cd "$( cd "$( dirname "${0}" )" && pwd )"

at the start of the script? Works in ([bd]?a|k)sh.

@LudwigKnuepfer
Copy link
Member Author

Why would I want to do that?

@Kijewski
Copy link
Contributor

Because a user won't expect that he has to run the script out of the script's directory.

@LudwigKnuepfer
Copy link
Member Author

Why is there an extra cd $(pwd) in there?

@Kijewski
Copy link
Contributor

That's the canonical example I found everywhere, I did not question the purpose of the subshell.

@LudwigKnuepfer
Copy link
Member Author

A quick search only came up with DIR="$( cd "$( dirname "${0}" )" && pwd )" (which I think makes sense).

@LudwigKnuepfer
Copy link
Member Author

@Kijewski how about that?

@Kijewski
Copy link
Contributor

I like. 👍

@Kijewski
Copy link
Contributor

ACK.

Creates file structure that maps files to licenses by grepping for
license patterns (patterns for licenses found in RIOT included).
Sets exit code to 1 if an unknown license header is detected.
LudwigKnuepfer added a commit that referenced this pull request Jun 17, 2014
@LudwigKnuepfer LudwigKnuepfer merged commit 0512d2f into RIOT-OS:master Jun 17, 2014
@LudwigKnuepfer LudwigKnuepfer deleted the licenses branch June 17, 2014 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: doc Area: Documentation Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants