Hi, Quoting Russ Allbery (2014-08-09 23:28:08) > Johannes Schauer <[email protected]> writes: > > More importantly for this bugreport: what constitutes a "license name" and > > how can one check that it is without spaces? > > I think you just need to strip off a trailing "with <exception> exception" > before checking for spaces.
I added this as an additional regex and added tests to check if things work as expected. I also fixed an issue where it was possible to have a stand-alone License paragraph with "or", "and" or otherwise spaces in the license name. The fix is the change in the second hunk of checks/source-copyright.pm and was probably just a typo. The result is a new tag and new test. Thanks for your help! cheers, josch
From 6d61dc10b2dfe562f487aef7687fb899d28aec52 Mon Sep 17 00:00:00 2001 From: josch <[email protected]> Date: Sat, 9 Aug 2014 16:20:15 +0200 Subject: [PATCH] check for space in license short name --- checks/source-copyright.desc | 19 +++++++++++++ checks/source-copyright.pm | 12 +++++--- .../debian/debian/copyright | 32 ++++++++++++++++++++++ t/tests/source-copyright-invalid-license-name/desc | 8 ++++++ t/tests/source-copyright-invalid-license-name/tags | 2 ++ 5 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 t/tests/source-copyright-invalid-license-name/debian/debian/copyright create mode 100644 t/tests/source-copyright-invalid-license-name/desc create mode 100644 t/tests/source-copyright-invalid-license-name/tags diff --git a/checks/source-copyright.desc b/checks/source-copyright.desc index 921e7b9..2e57bf4 100644 --- a/checks/source-copyright.desc +++ b/checks/source-copyright.desc @@ -205,3 +205,22 @@ Info: The paragraph has a "License" and a "Copyright" field, but no Lintian will attempt to guess what you intended and continue based on its guess. If the guess is wrong, you may see spurious tags related to this paragraph. + +Tag: space-in-std-shortname-in-dep5-copyright +Certainty: certain +Severity: normal +Ref: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Info: The <tt>License</tt> header contains a short name with a space, which + does not conform to the specification. License names are case-insensitive, + and may not contain spaces. The <tt>License<tt> header itself may contain + spaces to separate license names from connecting <tt>and</tt> and <tt>or</tt> + and to signify a license exception in the format <tt>[shortname] with [foo] + exception<tt>. + +Tag: more-than-one-short-name-in-dep5-standalone-license-paragraph +Certainty: certain +Severity: normal +Ref: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Info: The first line of a stand-alone <tt>License</tt> paragraph must be + a single license short name or a short name followed by a license exception + and not a concatenation of license short names with "and" or "or". diff --git a/checks/source-copyright.pm b/checks/source-copyright.pm index 6b9a0c5..2405742 100644 --- a/checks/source-copyright.pm +++ b/checks/source-copyright.pm @@ -281,9 +281,10 @@ sub _parse_dep5 { tag 'missing-license-text-in-dep5-copyright', $license, "(paragraph at line $current_line)"; } else { - for (@short_licenses) { - $standalone_licenses{$_} = $i; - $short_licenses_seen{$short_license} = $i; + if ($#short_licenses > 0) { + tag 'more-than-one-short-name-in-dep5-standalone-license-paragraph', $short_license, "(paragraph at line $current_line)"; + } else { + $standalone_licenses{$short_license} = $i; } } } elsif (defined $files) { @@ -301,7 +302,7 @@ sub _parse_dep5 { = parse_license($license,$current_line); if ($found_license) { for (@short_licenses) { - $short_licenses_seen{$short_license} = $i; + $short_licenses_seen{$_} = $i; if (not defined($full_license)) { $required_standalone_licenses{$_} = $i; } @@ -354,6 +355,9 @@ sub _parse_dep5 { "(paragraph at line $lines[$i]{'START-OF-PARAGRAPH'})"; } } + if ($license =~ / / and not $license =~ /^[^ ]+ with [^ ]+ exception$/) { + tag 'space-in-std-shortname-in-dep5-copyright', $license, "(paragraph at line $lines[$i]{'START-OF-PARAGRAPH'})"; + } } return; } diff --git a/t/tests/source-copyright-invalid-license-name/debian/debian/copyright b/t/tests/source-copyright-invalid-license-name/debian/debian/copyright new file mode 100644 index 0000000..2ddff20 --- /dev/null +++ b/t/tests/source-copyright-invalid-license-name/debian/debian/copyright @@ -0,0 +1,32 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: Doohickey +Upstream-Contact: J. Random Hacker <[email protected]> +Source: http://examples.com/doohickey/source/ + +Files: debian/a* +Copyright: 2014, somebody2 +License: license with spaces + Fixme + +Files: debian/b* +Copyright: 2014, somebody2 +License: license with spaces-in exception + Fixme + +Files: debian/c* +Copyright: 2014, somebody2 +License: short1 with foobar exception or short2, and short3 + +License: short2 + Fixme + +License: short3 + Fixme + +License: short1 or short2 + The "or" is not legal in a standalone license paragraph. + The first line of the License field must be a single license + short name or a short name followed by a license exception + +License: short1 with foobar exception + Here, the spaces are legal diff --git a/t/tests/source-copyright-invalid-license-name/desc b/t/tests/source-copyright-invalid-license-name/desc new file mode 100644 index 0000000..a07963c --- /dev/null +++ b/t/tests/source-copyright-invalid-license-name/desc @@ -0,0 +1,8 @@ +Testname: source-copyright-invalid-license-name +Sequence: 6000 +Version: 1.0 +Description: Test for invalid license namings +Options: -I -E --pedantic +Test-For: + space-in-std-shortname-in-dep5-copyright + more-than-one-short-name-in-dep5-standalone-license-paragraph diff --git a/t/tests/source-copyright-invalid-license-name/tags b/t/tests/source-copyright-invalid-license-name/tags new file mode 100644 index 0000000..466fc6a --- /dev/null +++ b/t/tests/source-copyright-invalid-license-name/tags @@ -0,0 +1,2 @@ +W: source-copyright-invalid-license-name source: more-than-one-short-name-in-dep5-standalone-license-paragraph short1 or short2 (paragraph at line 26) +W: source-copyright-invalid-license-name source: space-in-std-shortname-in-dep5-copyright license with spaces (paragraph at line 6) -- 2.0.1

