[licensecheck] 14/112: Improve detection of license Apache.

Jonas Smedegaard dr at jones.dk
Fri Nov 25 22:01:44 UTC 2016


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository licensecheck.

commit 7330b5f8f58ae21714139dfca9f9c7d58394a6ef
Author: Jonas Smedegaard <dr at jones.dk>
Date:   Mon Sep 19 17:33:49 2016 +0200

    Improve detection of license Apache.
---
 lib/App/Licensecheck.pm                            | 14 +++++-
 t/Software-License.t                               |  4 +-
 t/devscripts.t                                     |  2 +-
 t/grant.t                                          | 55 ++++++++++++++++++++++
 .../Apache/one_helper.rb}                          |  0
 t/grant/Apache_and_more/PIE.htc                    |  6 +++
 t/grant/Apache_and_more/rust.lang                  | 12 +++++
 t/grant/Apache_and_more/select2.js                 | 20 ++++++++
 t/grant/Apache_and_more/test_run.py                | 15 ++++++
 t/grant/EPL_and_more/Base64Coder.java              | 18 +++++++
 t/license.t                                        |  5 +-
 11 files changed, 145 insertions(+), 6 deletions(-)

diff --git a/lib/App/Licensecheck.pm b/lib/App/Licensecheck.pm
index 8e4e67f..4fbd67a 100755
--- a/lib/App/Licensecheck.pm
+++ b/lib/App/Licensecheck.pm
@@ -607,7 +607,19 @@ sub parse_license
 
 	# Apache
 	given ($licensetext) {
-		when ( /under the Apache License,? $ver_prefix_re($ver_re)/ ) {
+		when ( /Apache(?: Software)? License(?:,? $ver_prefix_re($ver_re)( or(?: any)? (?:later|newer))?)?(?:(?: or)? [^ ,]*?apache[^ ,]*| \([^(),]+\))*,? or(?: the)?(?:(?: GNU)? General Public License(?: \(GPL\))?|GPL)(?: $ver_prefix_re($ver_re)( or(?: any)? (?:later|newer))?)?/i ) {
+			$gen_license->( 'Apache', $1, $2, 'GPL', $3, $4 );
+		}
+		when ( /Apache(?: Software)? License(?:,? $ver_prefix_re($ver_re)( or(?: any)? (?:later|newer))?)?(?:(?: or)? [^ ,]*?apache[^ ,]*| \([^(),]\))*,? or(?: the)? bsd(?:[ -](\d)-clause)?\b/i ) {
+			$gen_license->( 'Apache', $1, $2, "BSD-$3-clause" );
+		}
+		when ( /Apache(?: Software)? License(?:,? $ver_prefix_re($ver_re)( or(?: any)? (?:later|newer))?)?(?:(?: or)? [^ ,]*?apache[^ ,]*| \([^(),]\))*,? or(?: the)? (?:Expat|MIT)\b/i ) {
+			$gen_license->( 'Apache', $1, $2, 'Expat', $3, $4 );
+		}
+		when ( /Apache(?: Software)? License(?:,? $ver_prefix_re($ver_re)(,? or(?: any)? (?:later|newer))?)?/i ) {
+			$gen_license->( 'Apache', $1, $2 );
+		}
+		when ( m<https?www.apache.org/licenses(?:/LICENSE-($ver_re))?>i ) {
 			$gen_license->( 'Apache', $1 );
 		}
 	}
diff --git a/t/Software-License.t b/t/Software-License.t
index 67a9a22..789ee1b 100644
--- a/t/Software-License.t
+++ b/t/Software-License.t
@@ -8,7 +8,7 @@ use Test::More;
 use Test::Script;
 
 my %LICENSES = (
-	Apache_2_0   => 'UNKNOWN',
+	Apache_2_0   => 'Apache (v2.0)',
 	FreeBSD      => 'BSD (2 clause)',
 	GPL_1        => 'UNKNOWN',
 	GPL_2        => 'UNKNOWN',
@@ -29,7 +29,7 @@ my %LICENSES = (
 	PostgreSQL   => 'UNKNOWN',
 	AGPL_3       => 'UNKNOWN',
 	SSLeay       => 'BSD (2 clause)',
-	Apache_1_1   => 'UNKNOWN',
+	Apache_1_1   => 'Apache (v1.1)',
 	Mozilla_1_1  => 'MPL (v1.1)',
 	GFDL_1_2     => 'UNKNOWN',
 	Sun          => 'UNKNOWN',
diff --git a/t/devscripts.t b/t/devscripts.t
index ab2a935..7ab5805 100644
--- a/t/devscripts.t
+++ b/t/devscripts.t
@@ -43,7 +43,7 @@ subtest 'MultiLine declaration' => sub {
 };
 
 subtest 'Duplicated copyright' => sub {
-	licensecheck '-m --copyright', 'duplicated-copyright.rb',
+	licensecheck '-m --copyright', '../grant/Apache/one_helper.rb',
 		qr{Apache \(v2.0\)	2002-2015,? OpenNebula Project \(OpenNebula.org\), C12G Labs};
 };
 
diff --git a/t/grant.t b/t/grant.t
new file mode 100644
index 0000000..9d89aa3
--- /dev/null
+++ b/t/grant.t
@@ -0,0 +1,55 @@
+use strictures 2;
+
+use Test::Roo;
+use App::Licensecheck;
+
+has encoding => ( is => 'ro' );
+has license  => ( is => 'ro', required => 1 );
+has corpus   => ( is => 'ro' );
+
+sub _build_description { return shift->license }
+
+test "Parse corpus" => sub {
+	my $self = shift;
+
+	my $app = App::Licensecheck->new;
+	$app->lines(0);
+	$app->deb_fmt(1);
+	$app->encoding( $self->encoding ) if $self->encoding;
+
+	foreach (
+		ref( $self->corpus ) eq 'ARRAY' ? @{ $self->corpus } : $self->corpus )
+	{
+		my ( $license, $copyright ) = $app->parse("t/grant/$_");
+		is( $license, $self->license, "Corpus file $_" );
+	}
+};
+
+# Apache
+run_me(
+	{ license => 'Apache-2.0 or GPL-2', corpus => 'Apache_and_more/PIE.htc' }
+);
+run_me(
+	{   license => 'Apache-2.0 or Expat',
+		corpus  => 'Apache_and_more/rust.lang'
+	}
+);
+run_me(
+	{   license => 'Apache-2.0 or GPL-2',
+		corpus  => 'Apache_and_more/select2.js'
+	}
+);
+run_me(
+	{   license => 'Apache-2.0 or BSD-3-clause',
+		corpus  => 'Apache_and_more/test_run.py'
+	}
+);
+
+# EPL
+run_me(
+	{   license => 'LGPL-2.1 and/or Apache-2.0+',
+		corpus  => 'EPL_and_more/Base64Coder.java'
+	}
+);
+
+done_testing;
diff --git a/t/devscripts/duplicated-copyright.rb b/t/grant/Apache/one_helper.rb
similarity index 100%
rename from t/devscripts/duplicated-copyright.rb
rename to t/grant/Apache/one_helper.rb
diff --git a/t/grant/Apache_and_more/PIE.htc b/t/grant/Apache_and_more/PIE.htc
new file mode 100644
index 0000000..852f895
--- /dev/null
+++ b/t/grant/Apache_and_more/PIE.htc
@@ -0,0 +1,6 @@
+<!--
+PIE: CSS3 rendering for IE
+Version 1.0beta4
+http://css3pie.com
+Dual-licensed for use under the Apache License Version 2.0 or the General Public License (GPL) Version 2.
+-->
diff --git a/t/grant/Apache_and_more/rust.lang b/t/grant/Apache_and_more/rust.lang
new file mode 100644
index 0000000..3c7afd7
--- /dev/null
+++ b/t/grant/Apache_and_more/rust.lang
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright 2013-2015 The Rust Project Developers.
+
+Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+<LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+option. This file may not be copied, modified, or distributed
+except according to those terms.
+-->
+
+<!-- Syntax highlighting for the Rust language -->
diff --git a/t/grant/Apache_and_more/select2.js b/t/grant/Apache_and_more/select2.js
new file mode 100644
index 0000000..95e8df5
--- /dev/null
+++ b/t/grant/Apache_and_more/select2.js
@@ -0,0 +1,20 @@
+/*
+Copyright 2012 Igor Vaynberg
+
+Version: 3.5.2 Timestamp: Sat Nov  1 14:43:36 EDT 2014
+
+This software is licensed under the Apache License, Version 2.0 (the "Apache License") or the GNU
+General Public License version 2 (the "GPL License"). You may choose either license to govern your
+use of this software only upon the condition that you accept all of the terms of either the Apache
+License or the GPL License.
+
+You may obtain a copy of the Apache License and the GPL License at:
+
+    http://www.apache.org/licenses/LICENSE-2.0
+    http://www.gnu.org/licenses/gpl-2.0.html
+
+Unless required by applicable law or agreed to in writing, software distributed under the
+Apache License or the GPL License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+CONDITIONS OF ANY KIND, either express or implied. See the Apache License and the GPL License for
+the specific language governing permissions and limitations under the Apache License and the GPL License.
+*/
diff --git a/t/grant/Apache_and_more/test_run.py b/t/grant/Apache_and_more/test_run.py
new file mode 100644
index 0000000..234dfee
--- /dev/null
+++ b/t/grant/Apache_and_more/test_run.py
@@ -0,0 +1,15 @@
+#
+#  subunit: extensions to python unittest to get test results from subprocesses.
+#  Copyright (C) 2011  Robert Collins <robertc at robertcollins.net>
+#
+#  Licensed under either the Apache License, Version 2.0 or the BSD 3-clause
+#  license at the users choice. A copy of both licenses are available in the
+#  project source as Apache-2.0 and BSD. You may not use this file except in
+#  compliance with one of these two licences.
+#  
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under these licenses is distributed on an "AS IS" BASIS, WITHOUT
+#  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+#  license you chose for the specific language governing permissions and
+#  limitations under that license.
+#
diff --git a/t/grant/EPL_and_more/Base64Coder.java b/t/grant/EPL_and_more/Base64Coder.java
new file mode 100644
index 0000000..2dcbbc5
--- /dev/null
+++ b/t/grant/EPL_and_more/Base64Coder.java
@@ -0,0 +1,18 @@
+// Copyright 2003-2010 Christian d'Heureuse, Inventec Informatik AG, Zurich, Switzerland
+// www.source-code.biz, www.inventec.ch/chdh
+//
+// This module is multi-licensed and may be used under the terms
+// of any of the following licenses:
+//
+//  EPL, Eclipse Public License, V1.0 or later, http://www.eclipse.org/legal
+//  LGPL, GNU Lesser General Public License, V2.1 or later, http://www.gnu.org/licenses/lgpl.html
+//  GPL, GNU General Public License, V2 or later, http://www.gnu.org/licenses/gpl.html
+//  AGPL, GNU Affero General Public License V3 or later, http://www.gnu.org/licenses/agpl.html
+//  AL, Apache License, V2.0 or later, http://www.apache.org/licenses
+//  BSD, BSD License, http://www.opensource.org/licenses/bsd-license.php
+//  MIT, MIT License, http://www.opensource.org/licenses/MIT
+//
+// Please contact the author if you need another license.
+// This module is provided "as is", without warranties of any kind.
+//
+// Project home page: www.source-code.biz/base64coder/java
diff --git a/t/license.t b/t/license.t
index 25b739c..1c919ed 100644
--- a/t/license.t
+++ b/t/license.t
@@ -25,8 +25,9 @@ test "Parse corpus" => sub {
 	}
 };
 
-run_me( { license => 'AFL-3.0',    corpus => 'academic.h' } );
-run_me( { license => 'Apache-2.0', corpus => 'duplicated-copyright.rb' } );
+run_me( { license => 'AFL-3.0', corpus => 'academic.h' } );
+run_me(
+	{ license => 'Apache-2.0', corpus => '../grant/Apache/one_helper.rb' } );
 run_me(
 	{   license => 'Artistic-2.0',
 		corpus  => [qw(artistic-2-0-modules.pm artistic-2-0.txt)]

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/licensecheck.git



More information about the Pkg-perl-cvs-commits mailing list