[licensecheck] 33/112: Add license patterns bsd_2_clause bsd_3_clause bsd_4_clause, trait patterns clause_retention clause_reproduction clause_advertising clause_non_endorsement disclaimer, and group pattern bsd.
Jonas Smedegaard
dr at jones.dk
Fri Nov 25 22:01:46 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 3ca583087fe8f4b356575330e53552e4c813813a
Author: Jonas Smedegaard <dr at jones.dk>
Date: Sun Oct 9 19:51:43 2016 +0200
Add license patterns bsd_2_clause bsd_3_clause bsd_4_clause, trait patterns clause_retention clause_reproduction clause_advertising clause_non_endorsement disclaimer, and group pattern bsd.
---
lib/App/Licensecheck.pm | 21 ++++-----
lib/Regexp/Pattern/License.pm | 86 +++++++++++++++++++++++++++++++++++++
lib/Regexp/Pattern/License/Parts.pm | 63 ++++++++++++++++++++++++++-
t/SPDX.t | 8 +++-
t/SPDX/BSD-2-Clause.txt | 9 ++++
t/SPDX/BSD-3-Clause.txt | 11 +++++
t/SPDX/BSD-4-Clause.txt | 14 ++++++
t/license.t | 6 +--
8 files changed, 200 insertions(+), 18 deletions(-)
diff --git a/lib/App/Licensecheck.pm b/lib/App/Licensecheck.pm
index 2c201c2..2d8a3c0 100755
--- a/lib/App/Licensecheck.pm
+++ b/lib/App/Licensecheck.pm
@@ -60,9 +60,6 @@ my %SPDX = (
'Adobe-2006' => 'Adobe',
'APAFML' => 'Adobe Postscript AFM',
'Artistic or GPL' => 'Perl',
- 'BSD-2-clause' => 'BSD (2 clause)',
- 'BSD-3-clause' => 'BSD (3 clause)',
- 'BSD-4-clause' => 'BSD (4 clause)',
'CC-BY-SA' => 'CC by-sa',
FSFAP => 'FSF All Permissive',
FSFUL => 'FSF Unlimited',
@@ -643,22 +640,22 @@ sub parse_license
# BSD
if ( $licensetext =~ /THIS SOFTWARE IS PROVIDED .*AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY/ ) {
given ($licensetext) {
- when ( /All advertising materials mentioning features or use of this software must display the following acknowledge?ment.*This product includes software developed by/i ) {
- $gen_license->('BSD-4-clause');
+ when ( /$L{re}{clause_advertising}/i ) {
+ $gen_license->('bsd_4_clause');
}
- when ( /(The name(?:\(s\))? .*? may not|Neither the (names? .*?|authors?) nor the names of( (its|their|other|any))? contributors may) be used to endorse or promote products derived from this software/i ) {
- $gen_license->('BSD-3-clause');
+ when ( /$L{re}{clause_non_endorsement}/i ) {
+ $gen_license->('bsd_3_clause');
}
- when ( /Redistributions in binary form must reproduce the above copyright notice/i ) {
- $gen_license->('BSD-2-clause');
+ when ( /$L{re}{clause_reproduction}/i ) {
+ $gen_license->('bsd_2_clause');
}
default {
- $gen_license->('BSD');
+ $gen_license->('bsd');
}
}
}
elsif ( $licensetext =~ /licen[sc]ebsd(?:-(\d)-clause)?/i ) {
- $gen_license->("BSD-$1-clause");
+ $gen_license->("bsd_${1}_clause");
}
# MPL
@@ -736,7 +733,7 @@ sub parse_license
$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" );
+ $gen_license->( 'Apache', $1, $2, "bsd_${3}_clause" );
}
when ( /Apache(?: Software)? License(?:,? $ver_prefix_re($ver_re)( or(?: any)? (?:later|newer))?)?(?:(?: or)? [^ ,]*?apache[^ ,]*| \([^(),]\))*,? or $L{re}{mit_new}\b/i ) {
$gen_license->( 'Apache', $1, $2, 'mit_new', $3, $4 );
diff --git a/lib/Regexp/Pattern/License.pm b/lib/Regexp/Pattern/License.pm
index 1982a00..f6b3d9b 100644
--- a/lib/Regexp/Pattern/License.pm
+++ b/lib/Regexp/Pattern/License.pm
@@ -24,6 +24,12 @@ Patterns each covering a single license.
=over
+=item * bsd_2_clause
+
+=item * bsd_3_clause
+
+=item * bsd_4_clause
+
=item * curl
=item * dsdp
@@ -58,6 +64,27 @@ while ( my ( $key, $val ) = each %Regexp::Pattern::License::Parts::RE ) {
my $the = qr/(?:[Tt]he )/;
our %RE = (
+ bsd_2_clause => {
+ name => 'BSD-2-Clause',
+ 'name.alt.org.debian' => 'BSD-2-clause',
+ caption => 'BSD (2 clause)',
+ tags => ['bsd'],
+ pat => qr/$P{repro_notice_cond_discl}\b[^a-zA-Z]+$P{discl}/,
+ },
+ bsd_3_clause => {
+ name => 'BSD-3-Clause',
+ 'name.alt.org.debian' => 'BSD-3-clause',
+ caption => 'BSD (3 clause)',
+ tags => ['bsd'],
+ pat => qr/$P{repro_notice_cond_discl}\b[^a-zA-Z]+$P{promo_no_author}/,
+ },
+ bsd_4_clause => {
+ name => 'BSD-4-Clause',
+ 'name.alt.org.debian' => 'BSD-4-clause',
+ caption => 'BSD (4 clause)',
+ tags => ['bsd'],
+ pat => qr/$P{ad_verbatim}/,
+ },
curl => {
tags => ['mit'],
pat =>
@@ -129,18 +156,77 @@ END
},
);
+=head2 Licensing traits
+
+Patterns each covering a single trait occuring in licenses.
+
+=over
+
+=item * clause_retention
+
+=item * clause_reproduction
+
+=item * clause_advertising
+
+=item * clause_non_endorsement
+
+=item * disclaimer
+
+=back
+
+=cut
+
+$RE{'clause_retention'} = {
+ caption => 'retention clause',
+ tags => ['trait'],
+ pat => qr/$P{retain_notice_cond_discl}/,
+};
+
+$RE{'clause_reproduction'} = {
+ caption => 'reproduction clause',
+ tags => ['trait'],
+ pat => qr/$P{repro_notice_cond_discl}/,
+};
+
+$RE{'clause_advertising'} = {
+ caption => 'advertising clause',
+ tags => ['trait'],
+ pat => qr/$P{ad_verbatim}/,
+};
+
+$RE{'clause_non_endorsement'} = {
+ caption => 'non-endorsement clause',
+ tags => ['trait'],
+ pat => qr/$P{promo_no_author}/,
+};
+
+$RE{'disclaimer'} = {
+ tags => ['trait'],
+ pat => qr/$P{discl}/,
+};
+
=head2 Multiple licenses
Patterns each covering multiple licenses.
=over
+=item * bsd
+
=item * mit
=back
=cut
+$RE{'bsd'} = {
+ name => 'BSD~unspecified',
+ caption => 'BSD (unspecified)',
+ tags => ['group'],
+ pat =>
+ qr/$P{repro_notice_cond_discl}(?:(?:[^a-zA-Z]+$P{ad_verbatim}.*)?[^a-zA-Z]+$P{promo_no_author})?/,
+};
+
$RE{'mit'} = {
name => 'MIT~unspecified',
caption => 'MIT (unspecified)',
diff --git a/lib/Regexp/Pattern/License/Parts.pm b/lib/Regexp/Pattern/License/Parts.pm
index 51e4898..8e0f860 100644
--- a/lib/Regexp/Pattern/License/Parts.pm
+++ b/lib/Regexp/Pattern/License/Parts.pm
@@ -27,8 +27,22 @@ Patterns each covering a single part, e.g. a clause or a disclaimer phrase.
=over
+=item * ad_verbatim
+
+=item * discl
+
=item * permission_granted_without
+=item * permission_person_materials
+
+=item * permission_person_sw_doc
+
+=item * promo_no_author
+
+=item * repro_notice_cond_discl
+
+=item * retain_notice_cond_discl
+
=item * use_sw_doc_any
=back
@@ -43,9 +57,16 @@ 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/;
+my $redist_src = qr/Redistributions of source code/;
+my $redist_bin = qr/Redistributions in binary form/;
+my $promote = qr/endorse or promote products derived from this software/;
# text
+my $notice = qr/the above copyright notice/;
+my $cond = qr/this list of conditions/;
+my $discl = qr/the following disclaimer/;
my $no_agreement = qr/without written agreement/;
+my $no_permit = qr/without specific prior written permission/;
# money
my $no_charge = qr/free of charge/;
@@ -55,11 +76,29 @@ 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/;
+my $doc = qr/the documentation/;
+my $other_mat = qr/other materials provided with the distribution/;
+my $ad_mat
+ = qr/All advertising materials mentioning features or use of this software/;
-# subject
+# agent
my $to_person = qr/to any person obtaining a copy/;
+my $no_authors
+ = qr/Neither the (?:names? .*|authors?) nor the names of(?: (?:its|their|other|any))? contributors/;
our %RE = (
+ ad_verbatim => {
+ caption => 'advertisement (verbatim)',
+ tags => ['clause'],
+ pat =>
+ qr/$ad_mat must display the following acknowledge?ment[^a-zA-Z]+This product includes software developed by/,
+ },
+ discl => {
+ caption => 'disclaimer',
+ tags => ['component'],
+ pat => qr/(?:CC0|Zero|0)/,
+ pat => qr/THIS SOFTWARE IS PROVIDED/,
+ },
discl_provide => {
caption => 'disclaimer (provides)',
tags => ['disclaimer'],
@@ -107,11 +146,33 @@ our %RE = (
pat =>
qr/$granted, $no_charge, $to_person of $sw_docfiles \(the "?Software"?\)/,
},
+ promo_no_author => {
+ caption => 'no author in promos',
+ tags => ['clause'],
+ pat =>
+ qr/(?:$no_authors may|The name.*? (?:may|must) not) be used to $promote $no_permit/,
+ },
provided_no_warranty => {
caption => 'provided (no warranty)',
tags => ['clause'],
pat => qr/without express or implied warranty/,
},
+ repro_notice_cond_discl => {
+ caption => 'reproduce in doc (notice, conditions, disclaimer)',
+ tags => ['clause'],
+ pat =>
+ qr/$redist_bin must reproduce $notice, $cond and $discl in $doc and\/or $other_mat/,
+ },
+ retain_notice_cond_discl => {
+ caption => 'retain in source (notice, conditions, disclaimer)',
+ tags => ['clause'],
+ pat => qr/$redist_src must retain $notice,? $cond and $discl/,
+ },
+ use_sw_doc_any => {
+ caption => 'usage (software and documentation, any purpose)',
+ tags => ['clause'],
+ pat => qr/$to_use $sw_doc $any_purpose/,
+ },
);
=encoding UTF-8
diff --git a/t/SPDX.t b/t/SPDX.t
index 7574a3b..db914b9 100644
--- a/t/SPDX.t
+++ b/t/SPDX.t
@@ -10,14 +10,18 @@ $app->deb_fmt(1);
# TODO: make naming scheme configurable
my %Debian2SPDX = (
- 'Expat' => 'MIT',
+ 'BSD-2-clause' => 'BSD-2-Clause',
+ 'BSD-3-clause' => 'BSD-3-Clause',
+ 'BSD-4-clause' => 'BSD-4-Clause',
+ 'Expat' => 'MIT',
);
path("t/SPDX")->visit(
sub {
my ( $license, $copyright ) = $app->parse($_);
is( $Debian2SPDX{$license} || $license, $_->basename('.txt'),
- "Corpus file $_" );
+ "Corpus file $_"
+ );
}
);
diff --git a/t/SPDX/BSD-2-Clause.txt b/t/SPDX/BSD-2-Clause.txt
new file mode 100644
index 0000000..e9ab04d
--- /dev/null
+++ b/t/SPDX/BSD-2-Clause.txt
@@ -0,0 +1,9 @@
+Copyright (c) <<var;name=copyright;original= <year> <owner>;match=.+>> All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY <<var;name=copyrightHolderAsIs;original=THE COPYRIGHT HOLDERS AND CONTRIBUTORS;match=.+>> "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <<var;name=copyrightHolderLiability;original=THE COPYRIGHT HOLDER OR CONTRIBUTORS;match=.+>> BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMA [...]
\ No newline at end of file
diff --git a/t/SPDX/BSD-3-Clause.txt b/t/SPDX/BSD-3-Clause.txt
new file mode 100644
index 0000000..7b87a53
--- /dev/null
+++ b/t/SPDX/BSD-3-Clause.txt
@@ -0,0 +1,11 @@
+Copyright (c) <<var;name=copyright;original= <year> <owner>;match=.+>>. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+
+3. Neither the name of <<var;name=organizationClause3;original=the copyright holder;match=.+>> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY <<var;name=copyrightHolderAsIs;original=THE COPYRIGHT HOLDERS AND CONTRIBUTORS;match=.+>> "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <<var;name=copyrightHolderLiability;original=THE COPYRIGHT HOLDER OR CONTRIBUTORS;match=.+>> BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMA [...]
\ No newline at end of file
diff --git a/t/SPDX/BSD-4-Clause.txt b/t/SPDX/BSD-4-Clause.txt
new file mode 100644
index 0000000..5b124b6
--- /dev/null
+++ b/t/SPDX/BSD-4-Clause.txt
@@ -0,0 +1,14 @@
+Copyright (c) <<var;name=copyright;original=<year> <owner>;match=.+>>. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+
+3. All advertising materials mentioning features or use of this software must display the following acknowledgement:
+This product includes software developed by the <<var;name=organizationClause3;original=the organization;match=.+>>.
+
+4. Neither the name of <<var;name=organizationClause4;original=the copyright holder;match=.+>> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY <<var;name=copyrightHolderAsIs;original=COPYRIGHT HOLDER;match=.+>> "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <<var;name=copyrightHolderLiability;original=COPYRIGHT HOLDER;match=.+>> BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUR [...]
\ No newline at end of file
diff --git a/t/license.t b/t/license.t
index 1c919ed..ae7eb61 100644
--- a/t/license.t
+++ b/t/license.t
@@ -33,9 +33,9 @@ run_me(
corpus => [qw(artistic-2-0-modules.pm artistic-2-0.txt)]
}
);
-run_me( { license => 'Beerware', corpus => 'beerware.cpp' } );
-run_me( { license => 'BSD', corpus => 'bsd-1-clause-1.c' } );
-run_me( { license => 'BSD-2-clause', corpus => 'bsd.f' } );
+run_me( { license => 'Beerware', corpus => 'beerware.cpp' } );
+run_me( { license => 'BSD~unspecified', corpus => 'bsd-1-clause-1.c' } );
+run_me( { license => 'BSD-2-clause', corpus => 'bsd.f' } );
run_me(
{ license => 'BSD-3-clause',
corpus => [
--
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