From: Rusty Russell Date: Thu, 21 Jul 2011 02:26:15 +0000 (+0930) Subject: ccanlint: tighten license check. X-Git-Url: http://git.ozlabs.org/?p=ccan;a=commitdiff_plain;h=f826598e1f39c723cca1e6955b50b19f14b23538;hp=8fc7a90a8db345c4276419d11f8731afc63f65f5;ds=sidebyside ccanlint: tighten license check. Now we've made GPL wording uniform, use it everywhere. There's no point allowing variants which might be unclear. We still have some non-conformant licenses in the tree (eg. just "BSD"), so we only warn on unknown license strings for now. --- diff --git a/tools/ccanlint/tests/license_exists.c b/tools/ccanlint/tests/license_exists.c index 9cf86083..dbfe29b5 100644 --- a/tools/ccanlint/tests/license_exists.c +++ b/tools/ccanlint/tests/license_exists.c @@ -25,33 +25,37 @@ static struct doc_section *find_license_tag(const struct manifest *m) return NULL; } +/* See GPLv2 and v2 (basically same wording) for interpreting versions: + * the "any later version" means the recepient can choose. */ static enum license which_license(struct doc_section *d) { - if (strstarts(d->lines[0], "GPL")) { - if (strchr(d->lines[0], '3')) - return LICENSE_GPLv3; - else if (strchr(d->lines[0], '2')) { - if (strreg(NULL, d->lines[0], "or (any )?later", NULL)) - return LICENSE_GPLv2_PLUS; - else - return LICENSE_GPLv2; - } + /* This means "user chooses what version", including GPLv1! */ + if (streq(d->lines[0], "GPL")) return LICENSE_GPL; - } - - if (strstarts(d->lines[0], "LGPL")) { - if (strchr(d->lines[0], '3')) - return LICENSE_LGPLv3; - else if (strchr(d->lines[0], '2')) { - if (strreg(NULL, d->lines[0], "or (any )?later", NULL)) - return LICENSE_LGPLv2_PLUS; - else - return LICENSE_LGPLv2; - } + /* This means "v2 only". */ + if (streq(d->lines[0], "GPLv2")) + return LICENSE_GPLv2; + /* This means "v2 or above" at user's choice. */ + if (streq(d->lines[0], "GPL (v2 or any later version)")) + return LICENSE_GPLv2_PLUS; + /* This means "v3 or above" at user's choice. */ + if (streq(d->lines[0], "GPL (v3 or any later version)")) + return LICENSE_GPLv3; + + /* This means "user chooses what version" */ + if (streq(d->lines[0], "LGPL")) return LICENSE_LGPL; - } - if (streq(d->lines[0], "BSD-MIT") - || streq(d->lines[0], "MIT")) + /* This means "v2.1 only". */ + if (streq(d->lines[0], "LGPLv2.1")) + return LICENSE_LGPLv2; + /* This means "v2.1 or above" at user's choice. */ + if (streq(d->lines[0], "LGPL (v2.1 or any later version)")) + return LICENSE_LGPLv2_PLUS; + /* This means "v3 or above" at user's choice. */ + if (streq(d->lines[0], "LGPL (v3 or any later version)")) + return LICENSE_LGPLv3; + + if (streq(d->lines[0], "BSD-MIT") || streq(d->lines[0], "MIT")) return LICENSE_MIT; if (streq(d->lines[0], "BSD (3 clause)")) return LICENSE_BSD; @@ -129,6 +133,14 @@ static void check_has_license(struct manifest *m, } m->license = which_license(d); + if (m->license == LICENSE_UNKNOWN) { + score_file_error(score, m->info_file, d->srcline, + "WARNING: unknown License: in _info: %s", + d->lines[0]); + /* FIXME: For historical reasons, don't fail here. */ + score->pass = true; + return; + } /* If they have a license tag at all, we pass. */ score->pass = true;