This is an automated email from the git hooks/post-receive script. js pushed a commit to branch master in repository licensecheck.
commit 551b151a12a9989cdee4ec5916ee64de03fb6224 Author: Jonas Smedegaard <d...@jones.dk> Date: Wed Sep 21 21:12:32 2016 +0200 Generalize license string composition. --- lib/App/Licensecheck.pm | 152 ++++++++++++++++++++++++------------------------ 1 file changed, 75 insertions(+), 77 deletions(-) diff --git a/lib/App/Licensecheck.pm b/lib/App/Licensecheck.pm index 966ad86..99d8ecc 100755 --- a/lib/App/Licensecheck.pm +++ b/lib/App/Licensecheck.pm @@ -53,6 +53,22 @@ See the script for casual usage. =cut +# legacy descriptive names different from SPDX shortnames +my %SPDX = ( + 'Artistic or GPL' => 'Perl', + 'BSD-2-clause' => 'BSD (2 clause)', + 'BSD-3-clause' => 'BSD (3 clause)', + 'BSD-4-clause' => 'BSD (4 clause)', + FTL => 'Freetype', + Expat => 'MIT/X11 (BSD like)', + Libpng => 'libpng', + 'MS-PL' => 'Ms-PL', + 'public-domain' => 'Public domain', + 'Python' => 'PSF', + 'SGI-B' => 'SGI Free Software License B', + Zlib => 'zlib/libpng', +); + my $ver_prefix_re = qr/(?:version |v\.? ?)?/i; my $ver_re = qr/\d(?:\.\d+)*/; @@ -377,6 +393,26 @@ sub parse_license push @ret, $spdx_extra if $spdx_extra; return @ret; }; + my $gen_license = sub { + my ( $id, $v, $later, $id2, $v2, $later2 ) = @_; + my @spdx; + my $desc = $SPDX{$id} || $id; + $v .= '+' if ($later); + push @spdx, $v ? "$id-$v" : $id if ($id); + my $desc2; + $desc2 = $SPDX{$id2} || $id2 if ($id2); + $v2 .= '+' if ($later2); + push @spdx, $v2 ? "$id2-$v2" : "$id2" if ($id2); + my $legacy = join( + ' ', + $desc, + ( $v ? "(v$v)" : () ), + ( $desc2 ? "or $desc2" : () ), + ( $v2 ? "(v$v2)" : () ), + ); + push @spdx_license, join( ' or ', @spdx ); + $license = join( ' ', ( $SPDX{$legacy} || $legacy ), $license ); + }; #<<< do not let perltidy touch this (keep long regex on one line) @@ -442,8 +478,7 @@ sub parse_license } # For Perl modules handled by Dist::Zilla when ( /this is free software,? licensed under:? (?:the )?(?:GNU (?:Library |Lesser )General Public License|LGPL),? $ver_prefix_re($ver_re)/i ) { - $license = "LGPL (v$1) $license"; - push @spdx_license, "LGPL-$1"; + $gen_license->( 'LGPL', $1 ); } } @@ -479,43 +514,37 @@ sub parse_license # LLGPL given ($licensetext) { when ( /the rights to distribute and use this software as governed by the terms of the Lisp Lesser General Public License|\bLLGPL\b/ ) { - $license = "LLGPL $license"; - push @spdx_license, 'LLGPL'; + $gen_license->('LLGPL'); } } # QPL given ($licensetext) { when ( /This file is part of the .*Qt GUI Toolkit. This file may be distributed under the terms of the Q Public License as defined/ ) { - $license = "QPL (part of Qt) $license"; + $gen_license->('QPL'); } when ( /may (be distributed|redistribute it) under the terms of the Q Public License/ ) { - $license = "QPL $license"; - push @spdx_license, 'QPL'; + $gen_license->('QPL'); } } # MIT given ($licensetext) { when ( /opensource\.org\/licenses\/mit-license\.php/ ) { - $license = "MIT/X11 (BSD like) $license"; - push @spdx_license, 'Expat'; + $gen_license->('Expat'); } 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)/ ) { - $license = "MIT/X11 (BSD like) $license"; - push @spdx_license, 'Expat'; + $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/ ) { - $license = "MIT/X11 (BSD like) $license"; - push @spdx_license, 'Expat'; + $gen_license->('Expat'); } } # ISC given ($licensetext) { when ( /Permission to use, copy, modify, and(\/or)? distribute this software for any purpose with or without fee is hereby granted, provided.*copyright notice.*permission notice.*all copies/ ) { - $license = "ISC $license"; - push @spdx_license, 'ISC'; + $gen_license->('ISC'); } } @@ -523,43 +552,35 @@ sub parse_license 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 ) { - $license = "BSD (4 clause) $license"; - push @spdx_license, 'BSD-4-clause'; + $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 ) { - $license = "BSD (3 clause) $license"; - push @spdx_license, 'BSD-3-clause'; + $gen_license->('BSD-3-clause'); } when ( /Redistributions in binary form must reproduce the above copyright notice/i ) { - $license = "BSD (2 clause) $license"; - push @spdx_license, 'BSD-2-clause'; + $gen_license->('BSD-2-clause'); } default { - $license = "BSD $license"; - push @spdx_license, 'BSD'; + $gen_license->('BSD'); } } } elsif ( $licensetext =~ /licen[sc]ebsd(?:-(\d)-clause)?/i ) { if ($1) { - $license = "BSD ($1 clause) $license"; - push @spdx_license, "BSD-$1-clause"; + $gen_license->("BSD-$1-clause"); } else { - $license = "BSD $license"; - push @spdx_license, "BSD"; + $gen_license->('BSD'); } } # MPL given ($licensetext) { when ( /Mozilla Public License,? $ver_prefix_re($ver_re)/ ) { - $license = "MPL (v$1) $license"; - push @spdx_license, "MPL-$1"; + $gen_license->( 'MPL', $1 ); } when ( /Mozilla Public License,? \($ver_prefix_re($ver_re)\)/ ) { - $license = "MPL (v$1) $license"; - push @spdx_license, "MPL-$1"; + $gen_license->( 'MPL', $1 ); } } @@ -568,82 +589,71 @@ sub parse_license # either *begins* with "The Artistic license v2.0" (hopefully the actual license) # or some license grant, when ( /(?:^ ?|(?:This is free software, licensed|Released|be used|use and modify this (?:module|software)) under (?:the terms of )?)[Tt]he Artistic License v?($ver_re)/ ) { - $license = "Artistic (v$1) $license"; - push @spdx_license, "Artistic-$1"; + $gen_license->( 'Artistic', $1 ); } } given ($licensetext) { when ( /is free software under the Artistic [Ll]icense/ ) { - $license = "Artistic $license"; - push @spdx_license, 'Artistic'; + $gen_license->('Artistic'); } } # Artistic or GPL given ($licensetext) { when ( /This (program )?is free software; you can redistribute it and\/or modify it under the same terms as (the )?Perl( ?5)? (programming |language |system )*itself/ ) { - $license = "Perl $license"; - push @spdx_license, 'Artistic or GPL'; + $gen_license->('Artistic', 0, 0, 'GPL'); } } # Apache given ($licensetext) { when ( /under the Apache License,? $ver_prefix_re($ver_re)/ ) { - $license = "Apache (v$1) $license"; - push @spdx_license, "Apache-$1"; + $gen_license->( 'Apache', $1 ); } } # Beerware given ($licensetext) { when ( /(THE BEER-WARE LICENSE)/i ) { - $license = "Beerware $license"; - push @spdx_license, 'Beerware'; + $gen_license->('Beerware'); } } # FTL given ($licensetext) { when ( /distributed under the terms of the FreeType project/i ) { - $license = "FreeType $license"; - push @spdx_license, 'FTL'; + $gen_license->('FTL'); } } # PHP given ($licensetext) { when ( /This source file is subject to version ($ver_re) of the PHP license/ ) { - $license = "PHP (v$1) $license"; - push @spdx_license, "PHP-$1"; + $gen_license->( 'PHP', $1 ); } } # CECILL given ($licensetext) { when ( /under the terms of the CeCILL-([^ ]+) / ) { - $license = "CeCILL-$1 $license"; - push @spdx_license, "CECILL-$1"; + $gen_license->( 'CeCILL', $1 ); } when ( /under the terms of the CeCILL / ) { - $license = "CeCILL $license"; - push @spdx_license, 'CECILL'; + $gen_license->('CeCILL'); } } # SGI-B given ($licensetext) { when ( /under the SGI Free Software License B/ ) { - $license = "SGI Free Software License B $license"; - push @spdx_license, 'SGI-B'; + $gen_license->('SGI-B'); } } # public-domain given ($licensetext) { when ( /is in the public domain/i ) { - $license = "Public domain $license"; - push @spdx_license, 'public-domain'; # not listed by SPDX + $gen_license->('public-domain'); } } @@ -658,80 +668,68 @@ sub parse_license # MS-PL given ($licensetext) { when ( /Microsoft Permissive License \(Ms-PL\)/ ) { - $license = "Ms-PL $license"; - push @spdx_license, 'MS-PL'; + $gen_license->('MS-PL'); } } # AFL given ($licensetext) { when ( /Licensed under the Academic Free License $ver_prefix_re($ver_re)/ ) { - $license = $1 ? "AFL-$1" : "AFL"; - push @spdx_license, 'AFL' . ( $1 ? "-$1" : '' ); + $gen_license->( 'AFL', $1 ); } } # EPL given ($licensetext) { when ( /This program and the accompanying materials are made available under the terms of the Eclipse Public License $ver_prefix_re($ver_re)/ ) { - $license = $1 ? "EPL-$1" : "EPL"; - push @spdx_license, 'EPL' . ( $1 ? "-$1" : '' ); + $gen_license->( 'EPL', $1 ); } } # BSL given ($licensetext) { when ( /Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the software and accompanying documentation covered by this license \(the Software\)/ ) { - $license = "BSL " . ( $1 ? "(v$2) " : '' ) . $license; - push @spdx_license, 'BSL' . ( $1 ? "-$2" : '' ); + $gen_license->('BSL'); } when ( /Boost Software License([ ,-]+ $ver_prefix_re($ver_re)?(\.))/i ) { - $license = "BSL " . ( $1 ? "(v$2) " : '' ) . $license; - push @spdx_license, 'BSL' . ( $1 ? "-$2" : '' ); + $gen_license->( 'BSL', $1, $2 ); } } # Python given ($licensetext) { when ( /PYTHON SOFTWARE FOUNDATION LICENSE(,? $ver_prefix_re($ver_re))/i ) { - $license = "PSF " . ( $1 ? "(v$2) " : '' ) . $license; - push @spdx_license, 'Python' . ( $1 ? "-$2" : '' ); + $gen_license->( 'Python', $1, $2 ); } } # Zlib/Libpng given ($licensetext) { when ( /The origin of this software must not be misrepresented.*Altered source versions must be plainly marked as such.*This notice may not be removed or altered from any source distribution/ ) { - $license = "zlib/libpng $license"; - push @spdx_license, 'Zlib'; + $gen_license->('Zlib'); } when ( /see copyright notice in zlib\.h/ ) { - $license = "zlib/libpng $license"; - push @spdx_license, 'Zlib'; + $gen_license->('Zlib'); } when ( /This code is released under the libpng license/ ) { - $license = "libpng $license"; - push @spdx_license, 'Libpng'; + $gen_license->('Libpng'); } } # WTFPL given ($licensetext) { when ( /Do What The Fuck You Want To Public License,? $ver_prefix_re($ver_re)/i ) { - $license = "WTFPL (v$1) $license"; - push @spdx_license, "WTFPL-$1"; + $gen_license->( 'WTFPL', $1 ); } } given ($licensetext) { when ( /Do what The Fuck You Want To Public License/i ) { - $license = "WTFPL $license"; - push @spdx_license, "WTFPL"; + $gen_license->('WTFPL'); } } given ($licensetext) { when ( /(License WTFPL|Under (the|a) WTFPL)/i ) { - $license = "WTFPL $license"; - push @spdx_license, "WTFPL"; + $gen_license->('WTFPL'); } } #>>> -- 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