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

Bug#713012: [lintian] patch



Package: lintian
Version: 2.5.13

patch here

Notice that I have created a common-license data in case of new license in data for checking .gz
From ab3489353b6504d098bd03efc8f051ff086d83d6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bastien=20ROUCARI=C3=88S?= <roucaries.bastien@gmail.com>
Date: Mon, 29 Jul 2013 13:06:05 +0200
Subject: [PATCH 1/2] Add generic infrastructure for checking common-licenses

Add data/copyright-file/common-licenses in order to robustly check
reference to /usr/share/common-licenses.
---
 checks/copyright-file.pm            |    7 +++++--
 data/copyright-file/common-licenses |   16 ++++++++++++++++
 2 files changed, 21 insertions(+), 2 deletions(-)
 create mode 100644 data/copyright-file/common-licenses

diff --git a/checks/copyright-file.pm b/checks/copyright-file.pm
index e126df6..7fd5251 100644
--- a/checks/copyright-file.pm
+++ b/checks/copyright-file.pm
@@ -32,6 +32,7 @@ use Lintian::Tags qw(tag);
 use Lintian::Util qw(slurp_entire_file file_is_encoded_in_non_utf8);
 
 our $KNOWN_ESSENTIAL = Lintian::Data->new('fields/essential');
+our $KNOWN_COMMON_LICENSES =  Lintian::Data->new('copyright-file/common-licenses');
 
 sub run {
 
@@ -115,8 +116,10 @@ if (m,\r,) {
 
 my $wrong_directory_detected = 0;
 
-if (m,(usr/share/common-licenses/(?:GPL|LGPL|BSD|Artistic)\.gz),) {
-    tag 'copyright-refers-to-compressed-license', $1;
+if (m,(usr/share/common-licenses/(?'licensename'.*?)\.gz),) {
+    if($KNOWN_COMMON_LICENSES->known($+{licensename})) {
+        tag 'copyright-refers-to-compressed-license', $1;
+    }
 }
 
 # Avoid complaining about referring to a versionless license file if the word
diff --git a/data/copyright-file/common-licenses b/data/copyright-file/common-licenses
new file mode 100644
index 0000000..d627204
--- /dev/null
+++ b/data/copyright-file/common-licenses
@@ -0,0 +1,16 @@
+# /usr/share/common-licenses list
+# generated by ls -1 /usr/share/common-licenses/
+Apache-2.0
+Artistic
+BSD
+GFDL
+GFDL-1.2
+GFDL-1.3
+GPL
+GPL-1
+GPL-2
+GPL-3
+LGPL
+LGPL-2
+LGPL-2.1
+LGPL-3
-- 
1.7.10.4

From 17490607edf651969e6762ab6679c4dc9ad63e38 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bastien=20ROUCARI=C3=88S?= <roucaries.bastien@gmail.com>
Date: Mon, 29 Jul 2013 14:29:37 +0200
Subject: [PATCH 2/2] Warm about apache-2 license and no link to common
 license

Warm if license is apache-2 and we do not link to /usr/share/license-common
---
 checks/copyright-file.desc                         |   14 +++++++++++
 checks/copyright-file.pm                           |    3 +++
 .../debian/debian/control.in                       |   14 +++++++++++
 ...right-missing-apache2-license-pointer.copyright |   26 ++++++++++++++++++++
 t/tests/copyright-file-general/desc                |    1 +
 t/tests/copyright-file-general/tags                |    2 ++
 6 files changed, 60 insertions(+)
 create mode 100644 t/tests/copyright-file-general/debian/debian/copyright-missing-apache2-license-pointer.copyright

diff --git a/checks/copyright-file.desc b/checks/copyright-file.desc
index 3f45227..0da7605 100644
--- a/checks/copyright-file.desc
+++ b/checks/copyright-file.desc
@@ -169,6 +169,20 @@ Info: If your package is released under the same terms as Perl itself,
  it should refer to the Artistic and GPL license files in the
  <tt>/usr/share/common-licenses</tt> directory.
 
+Tag: copyright-should-refer-to-common-license-file-for-apache-2
+Severity: important
+Certainty: possible
+Ref: policy 12.5
+Info: The strings Apache License, Version or Apache-2 appear in the
+ copyright file for this package, but the copyright file does not
+ reference <tt>/usr/share/common-licenses</tt> as the location of the
+ Apache-2 on Debian systems.
+ .
+ If the package uses some other license that just mentions the Apache-2 and
+ that Lintian should detect as an exception, please file a Lintian bug.
+ If the copyright file must mention the Apache-2 for reasons other than 
+ stating the license of the package, please add a Lintian override.
+
 Tag: copyright-should-refer-to-common-license-file-for-gpl
 Severity: important
 Certainty: possible
diff --git a/checks/copyright-file.pm b/checks/copyright-file.pm
index 7fd5251..5f5c492 100644
--- a/checks/copyright-file.pm
+++ b/checks/copyright-file.pm
@@ -223,7 +223,10 @@ if (m,/usr/share/common-licenses,
 } elsif (m/GNU General Public License/i or m/\bGPL\b/) {
     tag 'copyright-should-refer-to-common-license-file-for-gpl';
     $gpl = 1;
+} elsif (m/Apache License\s+,? Version 2\.0/i or m/\bApache-2(?:\.0)?\b/) {
+    tag 'copyright-should-refer-to-common-license-file-for-apache-2';
 }
+
 if (m,(?:under )?(?:the )?(?:same )?(?:terms )?as Perl itself,i &&
     !m,usr/share/common-licenses/,) {
     tag 'copyright-file-lacks-pointer-to-perl-license';
diff --git a/t/tests/copyright-file-general/debian/debian/control.in b/t/tests/copyright-file-general/debian/debian/control.in
index 3277846..e98b351 100644
--- a/t/tests/copyright-file-general/debian/debian/control.in
+++ b/t/tests/copyright-file-general/debian/debian/control.in
@@ -182,6 +182,20 @@ Description: checks for perl packages not pointing to common-licenses
  Lintian.  It is part of the Lintian test suite and may do very odd
  things.  It should not be installed like a regular package.  It may
  be an empty package.
+ 
+Package: copyright-missing-apache2-license-pointer
+Architecture: all
+Depends: $\{shlibs:Depends\}, $\{misc:Depends\}
+Description: checks for apache2 packages not pointing to common-licenses
+ Packages under the apache2-license should reference a
+ license in common-licenses.
+ .
+ This is a test package designed to exercise some feature or tag of
+ Lintian.  It is part of the Lintian test suite and may do very odd
+ things.  It should not be installed like a regular package.  It may
+ be an empty package.
+ 
+
 
 Package: copyright-poor-common-licenses
 Architecture: all
diff --git a/t/tests/copyright-file-general/debian/debian/copyright-missing-apache2-license-pointer.copyright b/t/tests/copyright-file-general/debian/debian/copyright-missing-apache2-license-pointer.copyright
new file mode 100644
index 0000000..90188b9
--- /dev/null
+++ b/t/tests/copyright-file-general/debian/debian/copyright-missing-apache2-license-pointer.copyright
@@ -0,0 +1,26 @@
+Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Upstream-Name: Midnight Commander
+Source: http://www.midnight-commander.org/downloads
+Copyright: 1996-2013 Free Software Foundation
+License: Apache-2.0
+
+ 
+Files: *
+Copyright: 2004,2007 Oren Ben-Kiki
+License: Apache-2.0
+
+License: Apache-2.0
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+ .
+ http://www.apache.org/licenses/LICENSE-2.0
+ .
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
\ No newline at end of file
diff --git a/t/tests/copyright-file-general/desc b/t/tests/copyright-file-general/desc
index 1d72ac4..4c75a1b 100644
--- a/t/tests/copyright-file-general/desc
+++ b/t/tests/copyright-file-general/desc
@@ -23,6 +23,7 @@ Test-For:
  copyright-refers-to-nonexistent-license-file
  copyright-refers-to-old-directory
  copyright-refers-to-problematic-php-license
+ copyright-should-refer-to-common-license-file-for-apache-2
  copyright-should-refer-to-common-license-file-for-gfdl
  copyright-should-refer-to-common-license-file-for-gpl
  copyright-should-refer-to-common-license-file-for-lgpl
diff --git a/t/tests/copyright-file-general/tags b/t/tests/copyright-file-general/tags
index 371eb22..492e349 100644
--- a/t/tests/copyright-file-general/tags
+++ b/t/tests/copyright-file-general/tags
@@ -1,5 +1,6 @@
 E: copyright-compressed: copyright-file-compressed
 E: copyright-full-apache-2: copyright-file-contains-full-apache-2-license
+E: copyright-full-apache-2: copyright-should-refer-to-common-license-file-for-apache-2
 E: copyright-full-gfdl: copyright-file-contains-full-gfdl-license
 E: copyright-full-gfdl: copyright-should-refer-to-common-license-file-for-gfdl
 E: copyright-full-gpl-1: copyright-should-refer-to-common-license-file-for-gpl
@@ -13,6 +14,7 @@ E: copyright-misc-errors: copyright-refers-to-compressed-license usr/share/commo
 E: copyright-misc-errors: copyright-refers-to-incorrect-directory usr/share/common-licences
 E: copyright-misc-errors: copyright-refers-to-old-directory
 E: copyright-misc-errors: helper-templates-in-copyright
+E: copyright-missing-apache2-license-pointer: copyright-should-refer-to-common-license-file-for-apache-2
 E: copyright-missing-perl-license-pointer: copyright-file-lacks-pointer-to-perl-license
 E: copyright-old-style: FSSTND-dir-in-usr usr/doc/
 E: copyright-old-style: no-copyright-file
-- 
1.7.10.4


Reply to: