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

js pushed a commit to branch master
in repository licensecheck.

commit 71519261bf82927c62ad5889a85dc985b05323f1
Author: Jonas Smedegaard <d...@jones.dk>
Date:   Sun Oct 9 22:03:03 2016 +0200

    Add license patterns mit_new mit_new_materials mit_old mit_unspecified 
postgresql, and group pattern mit.
---
 lib/App/Licensecheck.pm             | 20 +++++-------
 lib/Regexp/Pattern/License.pm       | 60 ++++++++++++++++++++++++++++++++++-
 lib/Regexp/Pattern/License/Parts.pm | 63 ++++++++++++++++++++++++++++++++++++-
 t/SPDX.t                            | 24 ++++++++++++++
 t/SPDX/MIT.txt                      |  9 ++++++
 t/SPDX/PostgreSQL.txt               | 12 +++++++
 t/grant.t                           |  7 +++++
 t/grant/MIT/harfbuzz-impl.c         | 27 ++++++++++++++++
 8 files changed, 208 insertions(+), 14 deletions(-)

diff --git a/lib/App/Licensecheck.pm b/lib/App/Licensecheck.pm
index 24874b9..12f4b24 100755
--- a/lib/App/Licensecheck.pm
+++ b/lib/App/Licensecheck.pm
@@ -68,7 +68,6 @@ my %SPDX = (
        FSFUL                  => 'FSF Unlimited',
        FSFULLR                => 'FSF Unlimited (with Retention)',
        FTL                    => 'Freetype',
-       Expat                  => 'MIT/X11 (BSD like)',
        Libpng                 => 'libpng',
        'MS-PL'                => 'Ms-PL',
        'public-domain'        => 'Public domain',
@@ -595,14 +594,11 @@ sub parse_license
 
        # MIT
        given ($licensetext) {
-               when ( /opensource\.org\/licenses\/mit-license\.php/ ) {
-                       $gen_license->('Expat');
+               when ( /$L{re}{mit_new}/) {
+                       $gen_license->('mit_new');
                }
-               when ( /Permission is hereby granted, free of charge, to any 
person obtaining a copy of this software and(\/or)? associated documentation 
files \(the (Software|Materials)\), to deal in the (Software|Materials)/ ) {
-                       $gen_license->('Expat');
-               }
-               when ( /Permission is hereby granted, without written agreement 
and without license or royalty fees, to use, copy, modify, and distribute this 
software and its documentation for any purpose/ ) {
-                       $gen_license->('Expat');
+               when ( /$L{re}{'mit_old'}/ ) {
+                       $gen_license->('mit_new');
                }
        }
 
@@ -711,8 +707,8 @@ sub parse_license
                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))?)?(?:(?: or)? [^ 
,]*?apache[^ ,]*| \([^(),]\))*,? or (?:$L{re}{mit_new}|$L{re}{mit})\b/i ) {
+                       $gen_license->( 'Apache', $1, $2, 'mit_new', $3, $4 );
                }
                when ( /Apache(?: Software)? License(?:,? 
$ver_prefix_re($ver_re)(,? or(?: any)? (?:later|newer))?)?/i ) {
                        $gen_license->( 'Apache', $1, $2 );
@@ -843,8 +839,8 @@ sub parse_license
 
        # PostgreSQL
        given ($licensetext) {
-               when ( /Permission to use, copy, modify, and distribute this 
software and its documentation for any purpose, without fee, and without a 
written agreement is hereby granted, provided that the above copyright notice 
and this paragraph and the following two paragraphs appear in all copies/i ) {
-                       $gen_license->('PostgreSQL');
+               when ( /$L{re}{postgresql}/ ) {
+                       $gen_license->('postgresql');
                }
        }
 
diff --git a/lib/Regexp/Pattern/License.pm b/lib/Regexp/Pattern/License.pm
index 356fd14..6f84564 100644
--- a/lib/Regexp/Pattern/License.pm
+++ b/lib/Regexp/Pattern/License.pm
@@ -24,6 +24,14 @@ Patterns each covering a single license.
 
 =over
 
+=item * mit_new
+
+=item * mit_new_materials
+
+=item * mit_old
+
+=item * postgresql
+
 =back
 
 =cut
@@ -33,7 +41,57 @@ while ( my ( $key, $val ) = each 
%Regexp::Pattern::License::Parts::RE ) {
        $P{$key} = $val->{pat};
 }
 
-our %RE = ();
+my $the = qr/(?:[Tt]he )/;
+
+our %RE = (
+       mit_new => {
+               'name.alt.org.spdx'      => 'MIT',
+               'name.alt.org.debian'    => 'Expat',
+               caption                  => 'MIT (Expat)',
+               'caption.alt.org.debian' => 'MIT/X11 (BSD like)',
+               tags                     => ['mit'],
+               pat =>
+                       qr/$P{permission_person_sw_doc}, 
$P{permission_use_deal_sw}|opensource\.org:?\/licenses\/mit-license\.php/,
+       },
+       mit_new_materials => {
+               'name.alt.org.debian' => 'MIT~Khronos',
+               caption               => 'MIT (Khronos)',
+               tags                  => ['mit'],
+               pat =>
+                       qr/$P{permission_person_materials}, 
$P{permission_use_deal_materials}/,
+       },
+       mit_old => {
+               'name.alt.org.debian' => 'MIT~old',
+               'name.alt.org.gentoo' => 'Old-MIT',
+               caption               => 'MIT (old)',
+               tags                  => ['mit'],
+               pat                   => qr/$P{permission_granted_agree_fee}/,
+       },
+       postgresql => {
+               name => 'PostgreSQL',
+               tags => ['mit'],
+               pat  => qr/$P{permission_use_fee_agree}/i,
+       },
+);
+
+=head2 Multiple licenses
+
+Patterns each covering multiple licenses.
+
+=over
+
+=item * mit
+
+=back
+
+=cut
+
+$RE{'mit'} = {
+       name    => 'MIT~unspecified',
+       caption => 'MIT (unspecified)',
+       tags    => ['group'],
+       pat     => qr/$the?MIT/,
+};
 
 =encoding UTF-8
 
diff --git a/lib/Regexp/Pattern/License/Parts.pm 
b/lib/Regexp/Pattern/License/Parts.pm
index bf75f10..937c007 100644
--- a/lib/Regexp/Pattern/License/Parts.pm
+++ b/lib/Regexp/Pattern/License/Parts.pm
@@ -27,11 +27,72 @@ Patterns each covering a single part, e.g. a clause or a 
disclaimer phrase.
 
 =over
 
+=item * permission_granted_without
+
+=item * use_sw_doc_any
+
 =back
 
 =cut
 
-our %RE = ();
+# permission clause
+my $granted = qr/Permission is hereby granted/;
+
+# purpose
+my $to_use      = qr/to use, copy, modify, and distribute/;
+my $to_deal_sw  = qr/to deal in the Software without restriction/;
+my $to_deal_mat = qr/to deal in the Materials without restriction/;
+my $any_purpose = qr/for any purpose/;
+
+# text
+my $no_agreement = qr/without written agreement/;
+
+# money
+my $no_charge = qr/free of charge/;
+my $no_fee    = qr/without fee/;
+my $no_fees   = qr/without license or royalty fees/;
+
+# asset
+my $sw_doc      = qr/this software and its documentation/;
+my $sw_docfiles = qr/this software and associated documentation files/;
+
+# subject
+my $to_person = qr/to any person obtaining a copy/;
+
+our %RE = (
+       permission_granted_agree_fee => {
+               caption => 'permission (granted, no agreement or fee)',
+               tags    => ['clause'],
+               pat     => qr/$granted, $no_agreement and $no_fees/,
+       },
+       permission_use_deal_sw => {
+               caption => 'usage (deal, software, any purpose)',
+               tags    => ['clause'],
+               pat     => qr/$to_deal_sw/,
+       },
+       permission_use_deal_materials => {
+               caption => 'usage (deal, materials, any purpose)',
+               tags    => ['clause'],
+               pat     => qr/$to_deal_mat/,
+       },
+       permission_use_fee_agree => {
+               caption => 'permission (use, no fee or agreement)',
+               tags    => ['clause'],
+               pat     => qr/and without a written agreement/,
+       },
+       permission_person_materials => {
+               caption => 'permission (granted, no charge, person, materials)',
+               tags    => ['clause'],
+               pat =>
+                       qr/$granted, $no_charge, $to_person of $sw_docfiles 
\(the "?Materials"?\)/,
+       },
+       permission_person_sw_doc => {
+               caption => 'permission (granted, no charge, person, software)',
+               tags    => ['clause'],
+               pat =>
+                       qr/$granted, $no_charge, $to_person of $sw_docfiles 
\(the "?Software"?\)/,
+       },
+);
 
 =encoding UTF-8
 
diff --git a/t/SPDX.t b/t/SPDX.t
new file mode 100644
index 0000000..7574a3b
--- /dev/null
+++ b/t/SPDX.t
@@ -0,0 +1,24 @@
+use strictures 2;
+
+use Test::More;
+use App::Licensecheck;
+use Path::Tiny;
+
+my $app = App::Licensecheck->new;
+$app->lines(0);
+$app->deb_fmt(1);
+
+# TODO: make naming scheme configurable
+my %Debian2SPDX = (
+       'Expat' => 'MIT',
+);
+
+path("t/SPDX")->visit(
+       sub {
+               my ( $license, $copyright ) = $app->parse($_);
+               is( $Debian2SPDX{$license} || $license, $_->basename('.txt'),
+                       "Corpus file $_" );
+       }
+);
+
+done_testing;
diff --git a/t/SPDX/MIT.txt b/t/SPDX/MIT.txt
new file mode 100644
index 0000000..3f28a5f
--- /dev/null
+++ b/t/SPDX/MIT.txt
@@ -0,0 +1,9 @@
+MIT License
+
+Copyright (c) <year> <copyright holders>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy 
of this software and associated documentation files (the "Software"), to deal 
in the Software without restriction, including without limitation the rights to 
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 
of the Software, and to permit persons to whom the Software is furnished to do 
so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all 
copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
SOFTWARE.
\ No newline at end of file
diff --git a/t/SPDX/PostgreSQL.txt b/t/SPDX/PostgreSQL.txt
new file mode 100644
index 0000000..ad2fcdd
--- /dev/null
+++ b/t/SPDX/PostgreSQL.txt
@@ -0,0 +1,12 @@
+PostgreSQL Database Management System
+(formerly known as Postgres, then as Postgres95)
+
+Portions Copyright (c) 1996-2010, The PostgreSQL Global Development Group
+
+Portions Copyright (c) 1994, The Regents of the University of California
+
+Permission to use, copy, modify, and distribute this software and its 
documentation for any purpose, without fee, and without a written agreement is 
hereby granted, provided that the above copyright notice and this paragraph and 
the following two paragraphs appear in all copies.
+
+IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR 
DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST 
PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF 
THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, 
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 
PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND 
THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, 
SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
\ No newline at end of file
diff --git a/t/grant.t b/t/grant.t
index 0640354..e7d8d86 100644
--- a/t/grant.t
+++ b/t/grant.t
@@ -74,4 +74,11 @@ run_me(
        }
 );
 
+# MIT
+run_me(
+       {   license => 'Expat',
+               corpus  => 'MIT/harfbuzz-impl.c'
+       }
+);
+
 done_testing;
diff --git a/t/grant/MIT/harfbuzz-impl.c b/t/grant/MIT/harfbuzz-impl.c
new file mode 100644
index 0000000..940f068
--- /dev/null
+++ b/t/grant/MIT/harfbuzz-impl.c
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2007  Red Hat, Inc.
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine library.
+ *
+ * Permission is hereby granted, without written agreement and without
+ * license or royalty fees, to use, copy, modify, and distribute this
+ * software and its documentation for any purpose, provided that the
+ * above copyright notice and the following two paragraphs appear in
+ * all copies of this software.
+ *
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
+ * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ *
+ * Red Hat Author(s): Behdad Esfahbod
+ */

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

_______________________________________________
Pkg-perl-cvs-commits mailing list
Pkg-perl-cvs-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits

Reply via email to