rev 10906 - in people/modax/copyright-helper/trunk: . licenses

Modestas Vainius modax-guest at alioth.debian.org
Mon Jun 9 11:56:47 UTC 2008


Author: modax-guest
Date: 2008-06-09 11:56:46 +0000 (Mon, 09 Jun 2008)
New Revision: 10906

Added:
   people/modax/copyright-helper/trunk/licenses/gnulgpl.pm
Modified:
   people/modax/copyright-helper/trunk/CHLicenses.pm
   people/modax/copyright-helper/trunk/copyright-helper.pl
Log:
Support LGPL

Modified: people/modax/copyright-helper/trunk/CHLicenses.pm
===================================================================
--- people/modax/copyright-helper/trunk/CHLicenses.pm	2008-06-09 11:37:38 UTC (rev 10905)
+++ people/modax/copyright-helper/trunk/CHLicenses.pm	2008-06-09 11:56:46 UTC (rev 10906)
@@ -67,7 +67,7 @@
 
 sub CHLicenses::LicenseBase::new {
     my $self = {
-        "version" => -1,
+        "version" => undef,
         "later" => 0,
         "foundInText" => ""
     };
@@ -86,7 +86,7 @@
     my ($self, $verPrefix, $verAnyStr) = @_;
     $verAnyStr = "" unless defined($verAnyStr);
     my $ver = $self->getVersion();
-    return ($ver > 0) ? "${verPrefix}${ver}" : $verAnyStr
+    return (defined $ver) ? "${verPrefix}${ver}" : $verAnyStr
 }
 
 sub CHLicenses::LicenseBase::getID($) {
@@ -151,7 +151,7 @@
 
 sub CHLicenses::LicenseBase::isValid($) {
     my ($self) = @_;
-    return $self->getFoundInText() && $self->getVersion() > -1;
+    return $self->getFoundInText() && defined($self->getVersion());
 }
 
 sub CHLicenses::LicenseBase::matchCopyrightedFile($\@) {

Modified: people/modax/copyright-helper/trunk/copyright-helper.pl
===================================================================
--- people/modax/copyright-helper/trunk/copyright-helper.pl	2008-06-09 11:37:38 UTC (rev 10905)
+++ people/modax/copyright-helper/trunk/copyright-helper.pl	2008-06-09 11:56:46 UTC (rev 10906)
@@ -220,7 +220,7 @@
 }
 
 # Entry point
-${main::VERSION}='0.4.0';
+${main::VERSION}='0.4.5';
 print_msg "\n";
 print_msg "Copyright Helper v${main::VERSION}\n";
 print_msg "Extracts copyright and license information from source code\n\n";

Added: people/modax/copyright-helper/trunk/licenses/gnulgpl.pm
===================================================================
--- people/modax/copyright-helper/trunk/licenses/gnulgpl.pm	                        (rev 0)
+++ people/modax/copyright-helper/trunk/licenses/gnulgpl.pm	2008-06-09 11:56:46 UTC (rev 10906)
@@ -0,0 +1,105 @@
+# Copyright (C) 2008 Modestas Vainius <modestas at vainius.eu>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>
+
+package CHLicenses::gnulgpl;
+use strict;
+use CHLicenses;
+our @ISA = qw( CHLicenses::LicenseBase );
+
+sub matchCopyrightedFile($\@) {
+    my ($self, $text) = @_;
+    for my $p (@$text) {
+        # Preamle is usually like:
+        # This library is free software: you can redistribute it and/or modify
+        # it under the terms of the GNU Lesser General Public License as published by
+        # the Free Software Foundation, either version 2.1 or 3 of the License.
+        if ($p =~ m/redistribute.*modify.*GNU\sLesser\sGeneral\sPublic\sLicense\sas\spublished(.*)/so ||
+            $p =~ m/redistribute.*modify.*GNU\sLibrary\sGeneral\sPublic\sLicense(.*)/so) {
+            my $version = $1;
+            my $license = new CHLicenses::gnulgpl;
+            # Check for version and later clause (optional)
+            if ($version =~ m/version (.+) (?:of the License|as published)(.*)/soi) {
+                $license->{"version"} = $1;
+                $version = $2;
+                $license->{"later"} = 1 if ($version =~ m/any\slater\sversion/);
+            }
+            $license->{"foundInText"} = $p;
+            return $license;
+        }
+    }
+    return 0;
+}
+
+sub matchLicenseText($\@) {
+    my ($self, $text) = @_;
+    my $m_title = 0;
+    my $m_version = 0;
+    my $license = new CHLicenses::gnulgpl;
+
+    for my $p (@$text) {
+        if (!$m_title) {
+            # text is post-splitting to paragraphs
+            if ($m_title = ($p =~ m/^\s*GNU LESSER GENERAL PUBLIC LICENSE(.*)$/so)) {
+                my $verstr = $1;
+                if ($verstr =~ m/^\s*Version (\d), (.+?)\s*$/o) {
+                    $m_version = $1;
+                    my $date = $2;
+                    if (($m_version eq '2.1' && $date eq "February 1999") ||
+                        ($m_version eq '3' && $date eq "29 June 2007")) {
+                        $license->{'version'} = $m_version;
+                        $license->{'foundInText'} = $p;
+                    } else {
+                        $m_version = 0; # Not recognized or not supported
+                    }
+                }
+            } elsif ($m_title = ($p =~ m/^\s*GNU LIBRARY GENERAL PUBLIC LICENSE(.*)$/so)) {
+                my $verstr = $1;
+                if ($verstr =~ m/^\s*Version (\d), (.+?)\s*$/o) {
+                    $m_version = $1;
+                    my $date = $2;
+                    if (($m_version eq '2' && $date eq "Version 2, June 1991")) {
+                        $license->{'version'} = $m_version;
+                        $license->{'foundInText'} = $p;
+                    } else {
+                        $m_version = 0; # Not recognized or not supported
+                    }
+                }
+            }
+        } elsif ($m_version eq '2') {
+            if ($p =~ /This license, the Library General Public License, applies to some/) {
+                return $license;
+            }
+        } elsif ($m_version eq '2.1') {
+            if ($p =~ /This license, the Lesser General Public License, applies to some/) {
+                return $license;
+            }
+        } elsif ($m_version eq '3') {
+            if ($p =~ /As used herein, "this License" refers to version 3 of the GNU Lesser/) {
+                return $license;
+            }
+        }
+    }
+
+    return 0;
+}
+
+sub getShortName($) {
+    "LGPL";
+}
+
+sub getLongName($) {
+    "GNU Lesser General Public License";
+}
+




More information about the pkg-kde-commits mailing list