Bug#698667: Gfdl improve
Hi
Please found here new patch that I expect fullfill your remarks
From 6da4f2d77c2bbe969d95d9dc3480a37c14162873 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bastien=20ROUCARI=C3=88S?= <roucaries.bastien@gmail.com>
Date: Thu, 24 Jan 2013 09:55:22 +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 | 53 +++++++++++++++++++++++++++++++++--------------------
1 file changed, 33 insertions(+), 20 deletions(-)
diff --git a/checks/cruft b/checks/cruft
index 6f2e45e..e4ee299 100644
--- a/checks/cruft
+++ b/checks/cruft
@@ -25,6 +25,8 @@
package Lintian::cruft;
use strict;
use warnings;
+use v5.10;
+use feature "switch";
# Half of the size used in the "sliding window" for detecting bad
# licenses like GFDL with invariant sections.
@@ -432,40 +434,51 @@ 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;
+ given ($block) {
+ # 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;
+ }
+ continue;
}
- }
- 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".
+ given($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) {
+ # 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;
+ }
}
}
+ continue;
}
}
}
--
1.7.10.4
From 9c838ff2c75c96cb87a7e510247034fb87db20a7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bastien=20ROUCARI=C3=88S?= <roucaries.bastien@gmail.com>
Date: Thu, 24 Jan 2013 10:05:11 +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
Conflicts:
checks/cruft
---
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 4436184..334e5dc 100644
--- a/checks/cruft
+++ b/checks/cruft
@@ -455,21 +455,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".
given($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/xiso) {
# 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>)?/xiso) {
# verbatim text of license is ok
}
when(m/^[\.;,\s\r\n]*$/is) {
diff --git a/t/tests/cruft-gfdl-invariants/debian/src/make-stds.texi b/t/tests/cruft-gfdl-invariants/debian/src/make-stds.texi
new file mode 100644
index 0000000..b5c2685
--- /dev/null
+++ b/t/tests/cruft-gfdl-invariants/debian/src/make-stds.texi
@@ -0,0 +1,7 @@
+@c Permission is granted to copy, distribute and/or modify this document
+@c under the terms of the GNU Free Documentation License, Version 1.1
+@c or any later version published by the Free Software Foundation;
+@c with no Invariant Sections, with no
+@c Front-Cover Texts, and with no Back-Cover Texts.
+@c A copy of the license is included in the section entitled ``GNU
+@c Free Documentation License''.
--
1.7.10.4
From b136d3ecb257b408381e31ac4a2ebbe1ca87ab99 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bastien=20ROUCARI=C3=88S?= <roucaries.bastien@gmail.com>
Date: Thu, 24 Jan 2013 09:59:46 +0100
Subject: [PATCH 2/5] Detect empty gfdl statement about invariant sections.
gfdl requests to explicitly mark that you have not invariant section by writing
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.
---
checks/cruft | 5 +++++
checks/cruft.desc | 12 ++++++++++++
t/tests/cruft-gfdl-invariants/debian/src/empty.texi | 5 +++++
t/tests/cruft-gfdl-invariants/debian/src/emptybis.texi | 7 +++++++
t/tests/cruft-gfdl-invariants/tags | 2 ++
5 files changed, 31 insertions(+)
create mode 100644 t/tests/cruft-gfdl-invariants/debian/src/empty.texi
create mode 100644 t/tests/cruft-gfdl-invariants/debian/src/emptybis.texi
diff --git a/checks/cruft b/checks/cruft
index e4ee299..4436184 100644
--- a/checks/cruft
+++ b/checks/cruft
@@ -471,6 +471,11 @@ sub find_cruft {
\s+ and \s+ with \s+ the \s+ Back-Cover \s+ Texts \s+ being
\s+ (?:\@var\{|<var>)? LIST (?:\}|<\/var>)?/xis) {
# verbatim text of license is ok
+ }
+ when(m/^[\.;,\s\r\n]*$/is) {
+ # empty text is ambiguous
+ tag 'license-problem-gfdl-invariants-empty', $name;
+ $licenseproblemhash{'gfdl-invariants'} = 1;
}
default {
tag 'license-problem-gfdl-invariants', $name;
diff --git a/checks/cruft.desc b/checks/cruft.desc
index b184f9f..58daae8 100644
--- a/checks/cruft.desc
+++ b/checks/cruft.desc
@@ -497,3 +497,15 @@ Info: The given source file is licensed under GFDL with invariant
suitable for main.
Ref: http://wiki.debian.org/qa.debian.org/gfdlinvariant,
http://www.debian.org/vote/2006/vote_001
+
+Tag: license-problem-gfdl-invariants-empty
+Severity: minor
+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 requests you to document this non presence.
+ .
+Ref: http://wiki.debian.org/qa.debian.org/gfdlinvariant,
+ http://www.debian.org/vote/2006/vote_001
diff --git a/t/tests/cruft-gfdl-invariants/debian/src/empty.texi b/t/tests/cruft-gfdl-invariants/debian/src/empty.texi
new file mode 100644
index 0000000..8e87b5f
--- /dev/null
+++ b/t/tests/cruft-gfdl-invariants/debian/src/empty.texi
@@ -0,0 +1,5 @@
+Permission is granted to copy, distribute and/or modify this
+document under the terms of the GNU Free Documentation License,
+version 1.3 or any later version published by the Free Software
+Foundation. A copy of the license is included in the
+section entitled "GNU Free Documentation License".
diff --git a/t/tests/cruft-gfdl-invariants/debian/src/emptybis.texi b/t/tests/cruft-gfdl-invariants/debian/src/emptybis.texi
new file mode 100644
index 0000000..7ad0640
--- /dev/null
+++ b/t/tests/cruft-gfdl-invariants/debian/src/emptybis.texi
@@ -0,0 +1,7 @@
+Permission is granted to copy, distribute and/or modify this
+document under the terms of the GNU Free Documentation License,
+version 1.3 or any later version published by the Free Software
+Foundation.
+
+A copy of the license is included in the
+section entitled "GNU Free Documentation License".
diff --git a/t/tests/cruft-gfdl-invariants/tags b/t/tests/cruft-gfdl-invariants/tags
index dc071c3..e216ff6 100644
--- a/t/tests/cruft-gfdl-invariants/tags
+++ b/t/tests/cruft-gfdl-invariants/tags
@@ -1,3 +1,5 @@
+E: cruft-gfdl-invariants source: license-problem-gfdl-invariants src/empty.texi
+E: cruft-gfdl-invariants source: license-problem-gfdl-invariants src/emptybis.texi
E: cruft-gfdl-invariants source: license-problem-gfdl-invariants src/frontback.html
E: cruft-gfdl-invariants source: license-problem-gfdl-invariants src/frontback.texi
E: cruft-gfdl-invariants source: license-problem-gfdl-invariants src/invariant.txt
--
1.7.10.4
From c7c8a1cd680f64b96a5887001c8f8069afa6271b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bastien=20ROUCARI=C3=88S?= <roucaries.bastien@gmail.com>
Date: Thu, 24 Jan 2013 10:17:32 +0100
Subject: [PATCH 4/5] Simplify grouping by using ?'name'
?'name' is better for documentation than $1
---
checks/cruft | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/checks/cruft b/checks/cruft
index 334e5dc..b88194a 100644
--- a/checks/cruft
+++ b/checks/cruft
@@ -450,15 +450,14 @@ sub find_cruft {
# if the "redeeming" part is in the next block.
#
# See cruft-gfdl-fp-sliding-win for the test case
- when(m/GNU \s+ Free \s+ Documentation \s+ License (.{0,1024})
+ when(m/GNU \s+ Free \s+ Documentation \s+ License (?'gfdlsections'.{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".
- given($gfdlsections) {
+ given($+{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/xiso) {
--
1.7.10.4
From 0f870377f5dfcf09fe985e9f84d68146014f05d2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bastien=20ROUCARI=C3=88S?= <roucaries.bastien@gmail.com>
Date: Thu, 24 Jan 2013 10:18:11 +0100
Subject: [PATCH 5/5] Avoid a false positive with tex comments
Tex comments % are allowed in the gfdl.
---
checks/cruft | 2 +-
t/tests/cruft-gfdl-invariants/debian/src/gfdltexcomments.tex | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)
create mode 100644 t/tests/cruft-gfdl-invariants/debian/src/gfdltexcomments.tex
diff --git a/checks/cruft b/checks/cruft
index b88194a..bed2b1c 100644
--- a/checks/cruft
+++ b/checks/cruft
@@ -454,7 +454,7 @@ sub find_cruft {
A \s+ copy \s+ of \s+ the \s+ license \s+ is \s+ included/xis) {
if (!exists $licenseproblemhash{'gfdl-invariants'}) {
# local space
- my $s = '(?:\s|\@c)';
+ my $s = '(?:\s|\@c|%)';
# GFDL license, assume it is bad unless it
# explicitly states it has no "bad sections".
given($+{gfdlsections}) {
diff --git a/t/tests/cruft-gfdl-invariants/debian/src/gfdltexcomments.tex b/t/tests/cruft-gfdl-invariants/debian/src/gfdltexcomments.tex
new file mode 100644
index 0000000..00e496c
--- /dev/null
+++ b/t/tests/cruft-gfdl-invariants/debian/src/gfdltexcomments.tex
@@ -0,0 +1,7 @@
+% Permission is granted to copy, distribute and/or modify this document
+% under the terms of the GNU Free Documentation License, Version 1.1 or
+% any later version published by the Free Software Foundation; with no
+% Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
+% Texts. A copy of the license is included in the section entitled
+% ``GNU Free Documentation License.''
+%
--
1.7.10.4
Reply to: