[libconfig-model-dpkg-perl] 01/27: Added update implementation for dpkg-copyright

dod at debian.org dod at debian.org
Mon Jan 12 07:09:46 UTC 2015


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

dod pushed a commit to branch master
in repository libconfig-model-dpkg-perl.

commit 30840684af46b3f3642d2b9fcd8e6cc15ba634f7
Author: Dominique Dumont <dod at debian.org>
Date:   Wed Dec 3 12:10:55 2014 +0100

    Added update implementation for dpkg-copyright
---
 lib/Config/Model/Dpkg/Copyright.pm | 107 +++++++++++++++++++++++++++++++++++++
 1 file changed, 107 insertions(+)

diff --git a/lib/Config/Model/Dpkg/Copyright.pm b/lib/Config/Model/Dpkg/Copyright.pm
new file mode 100644
index 0000000..461b4d5
--- /dev/null
+++ b/lib/Config/Model/Dpkg/Copyright.pm
@@ -0,0 +1,107 @@
+# ABSTRACT: Fill the File sections of debian/copyright file
+
+package Config::Model::Dpkg::Copyright ;
+
+use strict;
+use warnings;
+
+use 5.20.0;
+use IO::Pipe;
+
+use feature qw/postderef signatures/;
+no warnings qw/experimental::postderef experimental::signatures/;
+
+use base qw/Config::Model::Node/;
+
+
+
+# license and copyright sanitisation pilfered from Jonas's licensecheck2deb
+# hence this file is GPL-2+ not LGPL-2.1+
+
+# Copyright 2014 Dominique Dumont <dod at debian.org>
+# Copyright © 2005-2012 Jonas Smedegaard <dr at jones.dk>
+# Description: Reformat licencecheck output to copyright file format
+#
+# 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 2, 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/>.
+
+sub update {
+    my ($self) = @_;
+
+
+    my $pipe = IO::Pipe->new();
+    $pipe->reader("licensecheck -c '\.js' --copyright -m -r .");
+
+    my %cop ;
+
+    while(my $line = $pipe->getline) {
+        chomp $line; 
+        my ($f,$l,$c) = split /\t/, $line; 
+        if ($c =~ /^\*No/) {
+            say "no info for $f, check manually this file";
+            next;
+        } ;
+        $f =~ s!\./!!;
+        $l =~ s/([*?\\])/\\$1/g;
+        $l =~ s/\s*\(unversioned\/unknown version\)//;
+        $l =~ s/\s*\(with incorrect FSF address\)//;
+        $l =~ s/\s+\(v([^)]+) or later\)/-$1+/;
+        $l =~ s/\s+\(v([^)]+)\)/-$1/;
+        $l =~ s/^\s*(GENERATED FILE)/UNKNOWN/;
+        $l =~ s/\s+(GENERATED FILE)//;
+        $l =~ s/^\s*zlib\/libpng$/Zlib/;
+        $l =~ s/^\s*MIT\/X11 \(BSD like\)$/Expat/;
+        $l =~ s/^\s*BSD \((\d) clause\)$/BSD-$1-clause/;
+        $c =~ s/'//g;
+        $c =~ s/^©\s*//;
+        $c =~ s/(?<=\b\d{4})\s*-\s*\d{4}(?=\s*-\s*(\d{4})\b)//g;
+        $c =~ s/\b(\d{4}),?\s+([\S^\d])/$1, $2/g;
+
+        my $a = $cop{$c}{$l} ||= [];
+        push $a->@* , $f;
+    }
+
+    foreach my $c (keys %cop) {
+        foreach my $l (keys $cop{$c}->%* ) {
+            my $f = $cop{$c}{$l};
+            $self->load( qq(! Files:"@$f" Copyright="$c" License short_name="$l" ) );
+        }
+    }
+
+    # Fill also licence text if not present ?
+
+    $self->load( " ! Files:.sort " );
+    return ''; # improve returned message ?
+}
+
+__END__
+
+=head1 SYNOPSIS
+
+ $ cme update dpkg-copyright
+
+=head1 DESCRIPTION
+
+This command scans current package directory to extract copyright and
+licensse information and store them in the Files sections of
+debian/copyright file.
+
+In debian package directory:
+
+* run 'cme update dpkg-copyright' or 'cme update dpkg'  
+* check the result with your favorite VCS diff tool. (you do use 
+  a VCS for your package files, do you ?)
+
+Note: this command is experimental.
+
+=cut

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



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