[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#698667: [lintian] Improve gfdl detection



On 2013-01-21 23:25, bastien ROUCARIES wrote:
> Package: lintian
> Version: 2.5.10.3
> Severity: normal
> 
> Please found some patch to improve gfdl detection
> 

We talked about some of this over IRC yesterday, but anyway.

> 
> 0001-Simplify-cruft-test-of-license-by-using-for-when-str.patch
> 
> 
> From c52ab1461d430b14601348d697fe02fca31af205 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Bastien=20ROUCARI=C3=88S?= <roucaries.bastien@gmail.com>
> Date: Mon, 21 Jan 2013 21:42:16 +0100
> Subject: [PATCH 1/5] Simplify cruft test of license by using for/when
>  structure
> 
> Simplify the cruft test by using a case like structure
> ---
>  checks/cruft |   50 ++++++++++++++++++++++++++++++--------------------
>  1 file changed, 30 insertions(+), 20 deletions(-)
> 
> diff --git a/checks/cruft b/checks/cruft
> index 6f2e45e..9e7ed6f 100644
> --- a/checks/cruft
> +++ b/checks/cruft
> @@ -25,6 +25,7 @@
>  package Lintian::cruft;
>  use strict;
>  use warnings;
> +use v5.14;

This is no good as long as stable has perl 5.10.  That said, 'use v5.10'
(possibly with a 'use feature "switch"') should work as well.

>  
>  # Half of the size used in the "sliding window" for detecting bad
>  # licenses like GFDL with invariant sections.
> @@ -432,38 +433,47 @@ sub find_cruft {
>              push @queue, $window;
>              $block =  join '', @queue;
>  
> -            # json evil license
> -            if (!exists $licenseproblemhash{'json-evil'}) {
> -                if ($block =~ m/Software\s+shall\s+be\s+used\s+for\s+Good\s*,?\s*not\s+Evil/is) {
> -                    tag 'license-problem-json-evil', $name;
> -                    $licenseproblemhash{'json-evil'} = 1;
> +            for ($block) {

About this "for ($block)" - could we use "given" instead?  I think it
would better signal what is intended.

> +                # json evil license
> +                when (m/Software\s+shall\s+be\s+used\s+for\s+Good\s*,?\s*not\s+Evil/is) {
> +                    if(!exists $licenseproblemhash{'json-evil'}) {
> +                         tag 'license-problem-json-evil', $name;
> +                         $licenseproblemhash{'json-evil'} = 1;
> +                    }
>                  }

Is it possible for the json-license and the GFDL license to appear in
the same block?  If so, you might be missing a continue here.

> -            }
> -            if (!exists $licenseproblemhash{'gfdl-invariants'}) {
>                  # check GFDL block - The ".{0,1024}"-part in the regex
>                  # will contain the "no invariants etc."  part if
>                  # it is a good use of the license.  We include it
>                  # here to ensure that we do not emit a false positive
>                  # if the "redeeming" part is in the next block.
>                  #
> -                # See cruft-gfdl-fp-sliding-win for the test case.
> -                if ($block =~m/GNU \s+ Free \s+ Documentation \s+ License (.{0,1024})
> -                               A \s+ copy \s+ of \s+ the \s+ license \s+ is \s+ included/xis) {
> -                    # GFDL license, assume it is bad unless it
> -                    # explicitly states it has no "bad sections".
> -                    my $gfdlsections = $1;
> -                    unless ($gfdlsections =~m/with \s+ (?:the\s+)? no \s+ Invariant \s+ Sections,?
> -                                       \s+ (?:with\s+)? (?:the\s+)? no \s+ Front-Cover \s+ Texts,? \s+ and
> -                                       \s+ (?:with\s+)? (?:the\s+)? no \s+ Back-Cover \s+ Texts/xis) {
> -                        # license gfdl text verbatim is ok
> -                        unless ($gfdlsections =~m/with \s+ the \s+ Invariant \s+ Sections \s+ being
> +                # See cruft-gfdl-fp-sliding-win for the test case
> +                when(m/GNU \s+ Free \s+ Documentation \s+ License (.{0,1024})
> +                         A \s+ copy \s+ of \s+ the \s+ license \s+ is \s+ included/xis) {
> +                    if (!exists $licenseproblemhash{'gfdl-invariants'}) {
> +                        my $gfdlsections = $1;
> +                        # local space
> +                        my $s = '(?:\s+|\@c)';
> +                         # GFDL license, assume it is bad unless it
> +                        # explicitly states it has no "bad sections".
> +                        for($gfdlsections) {

(just as a reminder: s/for/given/ here as well)

> +                            when(m/with \s+ (?:the\s+)? no \s+ Invariant \s+ Sections,?
> +                                        \s+ (?:with\s+)? (?:the\s+)? no \s+ Front-Cover \s+ Texts,? \s+ and
> +                                        \s+ (?:with\s+)? (?:the\s+)? no \s+ Back-Cover \s+ Texts/xis) {
> +                                # no invariant
> +                            }
> +                            when(m/with \s+ the \s+ Invariant \s+ Sections \s+ being
>                                          \s+ (?:\@var\{|<var>)? LIST \s+ THEIR \s+TITLES (?:\}|<\/var>)? \s? ,?
>                                          \s+ with \s+ the \s+ Front-Cover \s+ Texts \s+ being
>                                          \s+ (?:\@var\{|<var>)? LIST (?:\}|<\/var>)? \s? ,?
>                                          \s+ and \s+ with \s+ the \s+ Back-Cover \s+ Texts \s+ being
>                                          \s+ (?:\@var\{|<var>)? LIST (?:\}|<\/var>)?/xis) {
> -                            tag 'license-problem-gfdl-invariants', $name;
> -                            $licenseproblemhash{'gfdl-invariants'} = 1;
> +                                # verbatim text of license is ok
> +                            }
> +                            default {
> +                                tag 'license-problem-gfdl-invariants', $name;
> +                                $licenseproblemhash{'gfdl-invariants'} = 1;
> +                            }
>                          }
>                      }
>                  }
> -- 1.7.10.4
> 
> 
> 0002-Detect-empty-gfdl-statement-about-invariant-sections.patch
> 
> 
> From 9751cf4000e22d39df47b736d172cf4a08a3ff22 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Bastien=20ROUCARI=C3=88S?= <roucaries.bastien@gmail.com>
> Date: Mon, 21 Jan 2013 22:15:29 +0100
> Subject: [PATCH 2/5] Detect empty gfdl statement about invariant sections.
> 
> gfdl ask to explicitly mark that you have not invariant section by writing
       ^^^

asks?

> text like this:
> "with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts."
> 
> Some author instead use empty text. Detect this usage.

> ---
>  [...]
> +
> +Tag: license-problem-gfdl-invariants-empty
> +Severity: important
> +Certainty: possible
> +Info: The given source file is licensed under GFDL, but without any 
> + precision about the presence of invariant sections, front-cover or 
> + back-cover text.
> + .
> + GFDL license explicitly ask you to document this non presence.
> + .
> + GFDL with invariant sections, front-cover or back-cover texts are not
> + suitable for main. 
> +Ref: http://wiki.debian.org/qa.debian.org/gfdlinvariant,
> + http://www.debian.org/vote/2006/vote_001

As mentioned, I am not convinced that this is actually a
serious/important (E) problem.  The vote out come says that:

"""
This means that works that don't include any Invariant Sections, Cover
Texts, Acknowledgements, and Dedications (or that do, but permission to
remove them is explicitly granted), are suitable for the main component
of our distribution.
"""

So (based on my understanding) if no invariant (etc.) sections are
listed, then it has no bad sections and should be "good enough for main".
  Though I assume that "ask" here is a "request/recommends" rather than
"demands/requires".  If the GFDL is "invalid" without that explicit
listing, then it is possibly still an E tag (but for a different reason)

> [...]
> 
> 
> 0003-Avoid-false-positive-with-texi.patch
> 
> 
> From a75186673c27b322e91b6a6383dca34721110d60 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Bastien=20ROUCARI=C3=88S?= <roucaries.bastien@gmail.com>
> Date: Mon, 21 Jan 2013 22:45:30 +0100
> Subject: [PATCH 3/5] Avoid false positive with texi
> 
> Some texi file use gfdl with @c for comment instead of space.
> Avoid false positive by allowing @c
> ---
>  checks/cruft                                       |   22 ++++++++++----------
>  .../debian/src/make-stds.texi                      |    7 +++++++
>  2 files changed, 18 insertions(+), 11 deletions(-)
>  create mode 100644 t/tests/cruft-gfdl-invariants/debian/src/make-stds.texi
> 
> diff --git a/checks/cruft b/checks/cruft
> index 53206e1..5b467e6 100644
> --- a/checks/cruft
> +++ b/checks/cruft
> @@ -453,21 +453,21 @@ sub find_cruft {
>                      if (!exists $licenseproblemhash{'gfdl-invariants'}) {
>                          my $gfdlsections = $1;
>                          # local space
> -                        my $s = '(?:\s+|\@c)';
> -                         # GFDL license, assume it is bad unless it
> +                        my $s = '(?:\s|\@c)';
> +                        # GFDL license, assume it is bad unless it
>                          # explicitly states it has no "bad sections".
>                          for($gfdlsections) {
> -                            when(m/with \s+ (?:the\s+)? no \s+ Invariant \s+ Sections,?
> -                                        \s+ (?:with\s+)? (?:the\s+)? no \s+ Front-Cover \s+ Texts,? \s+ and
> -                                        \s+ (?:with\s+)? (?:the\s+)? no \s+ Back-Cover \s+ Texts/xis) {
> +                            when(m/with $s+ (?:the$s+)? no $s+ Invariant $s+ Sections,?
> +                                        $s+ (?:with$s+)? (?:the$s+)? no $s+ Front-Cover $s+ Texts,? $s+ and
> +                                        $s+ (?:with$s+)? (?:the$s+)? no $s+ Back-Cover $s+ Texts/xis) {

Can you please add an "o" to the regex modifier here ($s never changes)

>                                  # no invariant
>                              }
> -                            when(m/with \s+ the \s+ Invariant \s+ Sections \s+ being
> -                                        \s+ (?:\@var\{|<var>)? LIST \s+ THEIR \s+TITLES (?:\}|<\/var>)? \s? ,?
> -                                        \s+ with \s+ the \s+ Front-Cover \s+ Texts \s+ being
> -                                        \s+ (?:\@var\{|<var>)? LIST (?:\}|<\/var>)? \s? ,?
> -                                        \s+ and \s+ with \s+ the \s+ Back-Cover \s+ Texts \s+ being
> -                                        \s+ (?:\@var\{|<var>)? LIST (?:\}|<\/var>)?/xis) {
> +                            when(m/with $s+ the $s+ Invariant $s+ Sections $s+ being
> +                                        $s+ (?:\@var\{|<var>)? LIST $s+ THEIR $s+TITLES (?:\}|<\/var>)? $s? ,?
> +                                        $s+ with $s+ the $s+ Front-Cover $s+ Texts $s+ being
> +                                        $s+ (?:\@var\{|<var>)? LIST (?:\}|<\/var>)? $s? ,?
> +                                        $s+ and $s+ with $s+ the $s+ Back-Cover $s+ Texts $s+ being
> +                                        $s+ (?:\@var\{|<var>)? LIST (?:\}|<\/var>)?/xis) {

Same here.

>                                  # verbatim text of license is ok
>                              } 
>                              when(m/^[\.;,\s\r\n]*$/is) {
> [...]
> 
> 
> 0004-Simplify-grouping-by-using-name.patch
> [...]
> 0005-Avoid-a-false-positive-with-tex-comments.patch
> [...]
> 

No comments on those two patches.

~Niels


Reply to: