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

[SCM] Debian package checker branch, master, updated. 2.5.11-11-gfc94067



The following commit has been merged in the master branch:
commit fc9406774e7b9c2953438bfaba5bca3e5b18a12e
Author: Bastien ROUCARIÈS <roucaries.bastien@gmail.com>
Date:   Sat Dec 15 21:36:30 2012 +0100

    Improve cruft license check by using a sliding window and detect gfdl
    
    Instead of read line by line every license file, read it by block and use
    a sliding windows for checking license text.
    
    Detect gfdl problem.
    
    [nthykier:
     * style/indentation/whitespace fixes
     * add sliding window test case
     * update tag description and ref the related GR result
     * document some of corner cases of the sliding window
    ]
    
    Signed-off-by: Niels Thykier <niels@thykier.net>

diff --git a/checks/cruft b/checks/cruft
index 1121e16..9c6d353 100644
--- a/checks/cruft
+++ b/checks/cruft
@@ -26,6 +26,11 @@ package Lintian::cruft;
 use strict;
 use warnings;
 
+# Half of the size used in the "sliding window" for detecting bad
+# licenses like GFDL with invariant sections.
+# NB: Keep in sync cruft-gfdl-fp-sliding-win/pre_build.
+use constant BLOCKSIZE => 4096;
+
 use Lintian::Data;
 use Lintian::Relation ();
 use Lintian::Tags qw(tag);
@@ -412,13 +417,50 @@ sub find_cruft {
     # test license problem is source file (only text file)
     if (-T $basename) {
         open my $F, '<', $basename or fail "can't open $name: $!";
-        while (my $line = <$F>) {
-          # json evil license
-          if ($line =~ m/Software\s+shall\s+be\s+used\s+for\s+Good\s*,?\s*not\s+Evil/i) {
-             tag 'license-problem-json-evil', $name;
-          }
+        binmode ($F);
+
+        my @queue = ('', '');
+        my %licenseproblemhash = ();
+
+        # we try to read this file in block and use a sliding window
+        # for efficiency.  We store two blocks in @queue and the whole
+        # string to match in $block. Please emit license tags only once
+        # per file
+        while (read ($F, my $window, BLOCKSIZE)) {
+            my $block;
+            shift @queue;
+            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;
+                }
+            }
+            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".
+                    unless ($block =~m/with \s+ no \s+ Invariant \s+ Sections,?
+                                       \s+ no \s+ Front-Cover \s+ Texts,? \s+ and
+                                       \s+ no \s+ Back-Cover \s+ Texts/xis) {
+                        tag 'license-problem-gfdl-invariants', $name;
+                        $licenseproblemhash{'gfdl-invariants'} = 1;
+                    }
+                }
+            }
         }
-        close $F or fail "can not close opened file $name: $!"
+        close $F or fail "can not close opened file $name: $!";
     }
 }
 
diff --git a/checks/cruft.desc b/checks/cruft.desc
index 084354d..6554f6e 100644
--- a/checks/cruft.desc
+++ b/checks/cruft.desc
@@ -486,3 +486,13 @@ Info: The given source file is copyrighted under the non free
  license of json and the infamous clause:
  The Software shall be used for Good, not Evil.
 Ref: http://wiki.debian.org/qa.debian.org/jsonevil
+
+Tag: license-problem-gfdl-invariants
+Severity: serious
+Certainty: possible
+Info: The given source file is licensed under GFDL with invariant
+ section or front-cover or back-cover text.
+ .
+ GFDL with invariant sections, front-cover or back-cover texts are not
+ suitable for main.
+Ref: http://www.debian.org/vote/2006/vote_001
diff --git a/debian/changelog b/debian/changelog
index cff35c4..7135f12 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -9,6 +9,8 @@ lintian (2.5.12) UNRELEASED; urgency=low
   * checks/cruft:
     + [NT] Do not emit the license-problem-json-evil tag for
       non-free packages.
+    + [NT] Apply patch from Bastien Roucariès to catch GFDL
+      licenses with invariants (etc.).  (Closes: #695967)
   * checks/files{,.desc}:
     + [NT] Apply patch from Bastien Roucariès to catch paths
       in (common) build dirs.  (Closes: #678857)
diff --git a/t/tests/cruft-gfdl-fp-sliding-win/debian/src/normal.texi b/t/tests/cruft-gfdl-fp-sliding-win/debian/src/normal.texi
new file mode 100644
index 0000000..d9c1b54
--- /dev/null
+++ b/t/tests/cruft-gfdl-fp-sliding-win/debian/src/normal.texi
@@ -0,0 +1,6 @@
+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; with no Invariant Sections, no Front-Cover Texts and
+no Back-Cover Texts.  A copy of the license is included in the
+section entitled "GNU Free Documentation License".
diff --git a/t/tests/cruft-gfdl-fp-sliding-win/desc b/t/tests/cruft-gfdl-fp-sliding-win/desc
new file mode 100644
index 0000000..5037ab2
--- /dev/null
+++ b/t/tests/cruft-gfdl-fp-sliding-win/desc
@@ -0,0 +1,5 @@
+Testname: cruft-gfdl-fp-sliding-win
+Sequence: 6000
+Version: 1.0
+Description: Check for FP with GFDL invariants sections
+Test-Against: license-problem-gfdl-invariants
diff --git a/t/tests/cruft-gfdl-fp-sliding-win/pre_build b/t/tests/cruft-gfdl-fp-sliding-win/pre_build
new file mode 100755
index 0000000..85b8668
--- /dev/null
+++ b/t/tests/cruft-gfdl-fp-sliding-win/pre_build
@@ -0,0 +1,45 @@
+#!/usr/bin/perl
+
+# Attempt to break the GFDL so that the "redeeming" part of the
+# license gets in the window /after/ the triggering part.  c/cruft
+# handles this case correctly now and we don't want to mess that up
+# later.
+
+use strict;
+use warnings;
+
+# Keep in sync with checks/cruft
+use constant BLOCK_SIZE => 4096;
+
+my ($rootdir) = @ARGV;
+my $dir = "$rootdir/debian/src";
+my $file = "$dir/good.texi";
+
+unless (-d $dir) {
+    mkdir $dir or die "mkdir $dir: $!";
+}
+
+my $slash = '/';
+my $gfdl_start = <<EOT ;
+Permission is granted to copy, distribute and${slash}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;
+EOT
+
+my $gfdl_end = <<EOT;
+with no Invariant Sections, no Front-Cover Texts and
+no Back-Cover Texts.  A copy of the license is included in the
+section entitled "GNU Free Documentation License".
+EOT
+
+my $fill = BLOCK_SIZE - length $gfdl_start;
+my $prefix = ' ' x ($fill - 1);
+
+open my $fd, '>', $file or die "open $file: $!";
+
+print {$fd} $prefix, "\n";
+print {$fd} $gfdl_start;
+print {$fd} $gfdl_end;
+
+close $fd or die "close $file: $!";
diff --git a/t/debs/deb-format-record-size/tags b/t/tests/cruft-gfdl-fp-sliding-win/tags
similarity index 100%
copy from t/debs/deb-format-record-size/tags
copy to t/tests/cruft-gfdl-fp-sliding-win/tags
diff --git a/t/tests/cruft-gfdl-invariants/debian/src/frontback.html b/t/tests/cruft-gfdl-invariants/debian/src/frontback.html
new file mode 100644
index 0000000..b8e14bc
--- /dev/null
+++ b/t/tests/cruft-gfdl-invariants/debian/src/frontback.html
@@ -0,0 +1,56 @@
+<html lang="en">
+<head>
+<title>Some title</title>
+<!--
+Some verbatim test
+Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997,
+1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
+2010, 2011, 2012
+
+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; with the
+Invariant Sections being "Funding Free Software", the Front-Cover
+Texts being (a) (see below), and with the Back-Cover Texts being (b)
+(see below).  A copy of the license is included in the section entitled
+"GNU Free Documentation License".
+
+(a) The Front-Cover Text is:
+
+     A GNU Manual
+
+(b) The Back-Cover Text is:
+
+     You have freedom to copy and modify this GNU Manual, like GNU
+     software.  Copies published by the Free Software Foundation raise
+     funds.-->
+</head>
+<body>
+This is
+ <pre class="sp">
+</pre>
+Copyright &copy; 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997,
+1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
+2010, 2011, 2012
+
+ <p>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; with the
+Invariant Sections being &ldquo;Funding Free Software&rdquo;, the Front-Cover
+Texts being (a) (see below), and with the Back-Cover Texts being (b)
+(see below).  A copy of the license is included in the section entitled
+&ldquo;GNU Free Documentation License&rdquo;.
+
+ <p>(a) The Front-Cover Text is:
+
+ <p>A GNU Manual
+
+ <p>(b) The Back-Cover Text is:
+
+ <p>You have freedom to copy and modify this GNU Manual, like GNU
+     software.  Copies published raises funds.
+ <pre class="sp">
+
+</pre>
+</body>
+</html>
diff --git a/t/tests/cruft-gfdl-invariants/debian/src/frontback.texi b/t/tests/cruft-gfdl-invariants/debian/src/frontback.texi
new file mode 100644
index 0000000..aa1d8e0
--- /dev/null
+++ b/t/tests/cruft-gfdl-invariants/debian/src/frontback.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; with no
+Invariant Sections, with the Front-Cover Texts being ``A Debian Manual'',
+and with the Back-Cover Texts as in (a) below.  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/invariant.txt b/t/tests/cruft-gfdl-invariants/debian/src/invariant.txt
new file mode 100644
index 0000000..e649d17
--- /dev/null
+++ b/t/tests/cruft-gfdl-invariants/debian/src/invariant.txt
@@ -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; with the Invariant Sections being just "GNU
+Manifesto", 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".
diff --git a/t/tests/cruft-gfdl-invariants/debian/src/normal.texi b/t/tests/cruft-gfdl-invariants/debian/src/normal.texi
new file mode 100644
index 0000000..d9c1b54
--- /dev/null
+++ b/t/tests/cruft-gfdl-invariants/debian/src/normal.texi
@@ -0,0 +1,6 @@
+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; with no Invariant Sections, no Front-Cover Texts and
+no Back-Cover Texts.  A copy of the license is included in the
+section entitled "GNU Free Documentation License".
diff --git a/t/tests/cruft-gfdl-invariants/desc b/t/tests/cruft-gfdl-invariants/desc
new file mode 100644
index 0000000..104ce2a
--- /dev/null
+++ b/t/tests/cruft-gfdl-invariants/desc
@@ -0,0 +1,5 @@
+Testname: cruft-gfdl-invariants
+Sequence: 6000
+Version: 1.0
+Description: Check for GFDL invariants sections
+Test-For: license-problem-gfdl-invariants
diff --git a/t/tests/cruft-gfdl-invariants/tags b/t/tests/cruft-gfdl-invariants/tags
new file mode 100644
index 0000000..dc071c3
--- /dev/null
+++ b/t/tests/cruft-gfdl-invariants/tags
@@ -0,0 +1,3 @@
+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

-- 
Debian package checker


Reply to: