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 cd07b1ad20f9d45e04c77a149d1cf3b9befeb47f
Author: Dominique Dumont <d...@debian.org>
Date:   Thu Jul 2 21:30:02 2015 +0200

    Scanner: find main license info found in LICENSE or COPYING or README
    
    The "weight" is the found info is light: A license file count
    as much as a simple file. Mostly useful if no other license
    info is specified in header of files.
---
 lib/Dpkg/Copyright/Scanner.pm     |  32 ++++++++--
 t/scanner/examples/libtommath.in  | 125 ++++++++++++++++++++++++++++++++++++++
 t/scanner/examples/libtommath.out |   4 ++
 3 files changed, 155 insertions(+), 6 deletions(-)

diff --git a/lib/Dpkg/Copyright/Scanner.pm b/lib/Dpkg/Copyright/Scanner.pm
index 07ebdc0..a1fa6e0 100644
--- a/lib/Dpkg/Copyright/Scanner.pm
+++ b/lib/Dpkg/Copyright/Scanner.pm
@@ -93,11 +93,13 @@ sub scan_files ( %args ) {
         @lines = $args{in}->lines_utf8; # for other tests
     }
     else {
-        my $pipe = IO::Pipe->new();
-        $pipe->reader("licensecheck --copyright -m -r .");
-        binmode($pipe, ":encoding(UTF-8)");
-        @lines = $pipe->getlines;
-        $pipe->close;
+        foreach my $opts ( ('',q! -c '(?i:readme|license|copying).*'!)) {
+            my $pipe = IO::Pipe->new();
+            $pipe->reader("licensecheck --copyright -m -r $opts .");
+            binmode($pipe, ":encoding(UTF-8)");
+            push @lines, $pipe->getlines;
+            $pipe->close;
+        }
     }
 
     my %copyrights ;
@@ -141,6 +143,9 @@ sub scan_files ( %args ) {
 
         $c = __pack_copyright($c);
 
+        next if $l =~ /unknown/i and $c =~ /no-info-found/i;
+
+        #say "Storing '$f' : '$c' '$l'";
         $files->{$f} = $copyrights{$c}{$l} //= $id++;
     }
 
@@ -343,10 +348,24 @@ sub __coalesce_copyright_years($entries, $owners) {
 }
 
 # $h is a tree of hash matching the directory structure. Each leaf is a
-# copyright id.
+# copyright id. Each key is a file name in a directory (not the full path)
 sub __squash ($h) {
     my %count ;
 
+    # find main license info found in LICENCE or COPYING or README
+    # file
+    foreach my $info_name (qw/readme copying license/) {
+        my $re = qr!$info_name[.\w]*$!i;
+        foreach my $name (sort keys %$h) {
+            if ($name =~ $re) {
+                my $id = delete $h->{$name};
+                #say "del global lic info $name with ".Dumper($id);
+                # using 1 means that info from this file is easy to override
+                $count{$id} = 1;
+            };
+        }
+    }
+
     # count the number of times each (c) info is used in this directory.
     # (including the main (c) info of each subdirectory)
     foreach my $name (sort keys %$h) {
@@ -366,6 +385,7 @@ sub __squash ($h) {
     }
 
     # find the most used (c) info in this directory (or the existing '*' entry)
+    # unless info was already found in LICENSE or README content
     my $max = 0;
     my $main_license_id = $h->{'*'};
     if (not defined $main_license_id) {
diff --git a/t/scanner/examples/libtommath.in b/t/scanner/examples/libtommath.in
new file mode 100644
index 0000000..697f0d8
--- /dev/null
+++ b/t/scanner/examples/libtommath.in
@@ -0,0 +1,125 @@
+./bn_s_mp_mul_digs.c   UNKNOWN *No copyright*
+./bn_mp_clear.c        UNKNOWN *No copyright*
+./bn_fast_mp_montgomery_reduce.c       UNKNOWN *No copyright*
+./bn_s_mp_add.c        UNKNOWN *No copyright*
+./bn_mp_reduce.c       UNKNOWN *No copyright*
+./bn_mp_init.c UNKNOWN *No copyright*
+./bn_mp_xor.c  UNKNOWN *No copyright*
+./bn_mp_mul_d.c        UNKNOWN *No copyright*
+./bn_mp_div_2.c        UNKNOWN *No copyright*
+./bn_mp_invmod.c       UNKNOWN *No copyright*
+./bn_mp_mul.c  UNKNOWN *No copyright*
+./bn_mp_div_2d.c       UNKNOWN *No copyright*
+./bn_mp_read_radix.c   UNKNOWN *No copyright*
+./bn_mp_to_signed_bin.c        UNKNOWN *No copyright*
+./bn_mp_get_int.c      UNKNOWN *No copyright*
+./bn_mp_montgomery_reduce.c    UNKNOWN *No copyright*
+./bn_mp_reduce_2k.c    UNKNOWN *No copyright*
+./bn_mp_karatsuba_sqr.c        UNKNOWN *No copyright*
+./bn_mp_toom_mul.c     UNKNOWN *No copyright*
+./bn_mp_mulmod.c       UNKNOWN *No copyright*
+./bn_mp_expt_d.c       UNKNOWN *No copyright*
+./bn_mp_signed_bin_size.c      UNKNOWN *No copyright*
+./bn_mp_dr_setup.c     UNKNOWN *No copyright*
+./bn_mp_grow.c UNKNOWN *No copyright*
+./bn_mp_sub_d.c        UNKNOWN *No copyright*
+./bn_mp_cmp.c  UNKNOWN *No copyright*
+./bn_mp_to_unsigned_bin.c      UNKNOWN *No copyright*
+./bn_mp_get_long.c     UNKNOWN *No copyright*
+./bn_mp_2expt.c        UNKNOWN *No copyright*
+./bn_reverse.c UNKNOWN *No copyright*
+./bn_mp_read_signed_bin.c      UNKNOWN *No copyright*
+./bn_mp_zero.c UNKNOWN *No copyright*
+./bn_mp_prime_fermat.c UNKNOWN *No copyright*
+./bn_mp_abs.c  UNKNOWN *No copyright*
+./bn_mp_copy.c UNKNOWN *No copyright*
+./bn_mp_dr_is_modulus.c        UNKNOWN *No copyright*
+./bn_mp_mul_2.c        UNKNOWN *No copyright*
+./bn_fast_s_mp_mul_high_digs.c UNKNOWN *No copyright*
+./bn_mp_init_set_int.c UNKNOWN *No copyright*
+./bn_mp_unsigned_bin_size.c    UNKNOWN *No copyright*
+./bn_mp_gcd.c  UNKNOWN *No copyright*
+./bn_mp_radix_smap.c   UNKNOWN *No copyright*
+./bn_mp_to_unsigned_bin_n.c    UNKNOWN *No copyright*
+./tommath_class.h      UNKNOWN *No copyright*
+./bn_mp_or.c   UNKNOWN *No copyright*
+./bn_mp_toom_sqr.c     UNKNOWN *No copyright*
+./bn_mp_clamp.c        UNKNOWN *No copyright*
+./bn_mp_fread.c        UNKNOWN *No copyright*
+./bn_mp_cmp_mag.c      UNKNOWN *No copyright*
+./bn_mp_prime_is_prime.c       UNKNOWN *No copyright*
+./bn_mp_prime_next_prime.c     UNKNOWN *No copyright*
+./tommath_superclass.h UNKNOWN *No copyright*
+./bn_mp_toradix_n.c    UNKNOWN *No copyright*
+./bn_mp_exch.c UNKNOWN *No copyright*
+./bn_mp_sqrmod.c       UNKNOWN *No copyright*
+./bn_mp_exptmod.c      UNKNOWN *No copyright*
+./bn_error.c   UNKNOWN *No copyright*
+./bn_mp_init_copy.c    UNKNOWN *No copyright*
+./bn_mp_toradix.c      UNKNOWN *No copyright*
+./bn_mp_shrink.c       UNKNOWN *No copyright*
+./bn_mp_clear_multi.c  UNKNOWN *No copyright*
+./bn_mp_lcm.c  UNKNOWN *No copyright*
+./bn_mp_cnt_lsb.c      UNKNOWN *No copyright*
+./bn_mp_mul_2d.c       UNKNOWN *No copyright*
+./bn_mp_lshd.c UNKNOWN *No copyright*
+./bn_mp_and.c  UNKNOWN *No copyright*
+./bn_mp_prime_is_divisible.c   UNKNOWN *No copyright*
+./bn_mp_karatsuba_mul.c        UNKNOWN *No copyright*
+./bn_mp_sqrt.c UNKNOWN *No copyright*
+./bn_mp_rshd.c UNKNOWN *No copyright*
+./bn_mp_cmp_d.c        UNKNOWN *No copyright*
+./bn_mp_add_d.c        UNKNOWN *No copyright*
+./tommath.h    UNKNOWN *No copyright*
+./bn_mp_div.c  UNKNOWN *No copyright*
+./bn_mp_dr_reduce.c    UNKNOWN *No copyright*
+./bn_mp_exteuclid.c    UNKNOWN *No copyright*
+./bn_mp_addmod.c       UNKNOWN *No copyright*
+./bn_mp_add.c  UNKNOWN *No copyright*
+./bn_mp_set_int.c      UNKNOWN *No copyright*
+./bn_mp_fwrite.c       UNKNOWN *No copyright*
+./bn_s_mp_sqr.c        UNKNOWN *No copyright*
+./bn_mp_set_long.c     UNKNOWN *No copyright*
+./bn_mp_exptmod_fast.c UNKNOWN *No copyright*
+./bn_s_mp_exptmod.c    UNKNOWN *No copyright*
+./bn_fast_mp_invmod.c  UNKNOWN *No copyright*
+./bn_mp_sub.c  UNKNOWN *No copyright*
+./bn_mp_reduce_2k_setup_l.c    UNKNOWN *No copyright*
+./bn_mp_to_signed_bin_n.c      UNKNOWN *No copyright*
+./bn_mp_init_multi.c   UNKNOWN *No copyright*
+./bn_mp_set.c  UNKNOWN *No copyright*
+./bn_mp_div_d.c        UNKNOWN *No copyright*
+./bn_mp_prime_random_ex.c      UNKNOWN *No copyright*
+./bn_mp_reduce_is_2k_l.c       UNKNOWN *No copyright*
+./bn_mp_neg.c  UNKNOWN *No copyright*
+./bn_mp_mod_d.c        UNKNOWN *No copyright*
+./bn_mp_reduce_2k_setup.c      UNKNOWN *No copyright*
+./bn_mp_is_square.c    UNKNOWN *No copyright*
+./bn_fast_s_mp_sqr.c   UNKNOWN *No copyright*
+./bn_s_mp_mul_high_digs.c      UNKNOWN *No copyright*
+./bn_mp_reduce_setup.c UNKNOWN *No copyright*
+./bn_mp_mod_2d.c       UNKNOWN *No copyright*
+./bn_mp_montgomery_calc_normalization.c        UNKNOWN *No copyright*
+./bn_fast_s_mp_mul_digs.c      UNKNOWN *No copyright*
+./bncore.c     UNKNOWN *No copyright*
+./bn_mp_count_bits.c   UNKNOWN *No copyright*
+./bn_mp_read_unsigned_bin.c    UNKNOWN *No copyright*
+./bn_mp_reduce_2k_l.c  UNKNOWN *No copyright*
+./bn_mp_rand.c UNKNOWN *No copyright*
+./bn_s_mp_sub.c        UNKNOWN *No copyright*
+./bn_mp_sqr.c  UNKNOWN *No copyright*
+./bn_mp_div_3.c        UNKNOWN *No copyright*
+./bn_prime_tab.c       UNKNOWN *No copyright*
+./bn_mp_init_size.c    UNKNOWN *No copyright*
+./bn_mp_invmod_slow.c  UNKNOWN *No copyright*
+./bn_mp_init_set.c     UNKNOWN *No copyright*
+./bn_mp_prime_rabin_miller_trials.c    UNKNOWN *No copyright*
+./bn_mp_montgomery_setup.c     UNKNOWN *No copyright*
+./bn_mp_n_root.c       UNKNOWN *No copyright*
+./bn_mp_prime_miller_rabin.c   UNKNOWN *No copyright*
+./bn_mp_mod.c  UNKNOWN *No copyright*
+./bn_mp_reduce_is_2k.c UNKNOWN *No copyright*
+./bn_mp_jacobi.c       UNKNOWN *No copyright*
+./bn_mp_submod.c       UNKNOWN *No copyright*
+./bn_mp_radix_size.c   UNKNOWN *No copyright*
+LICENSE        WTFPL   2004 Sam Hocevar <s...@hocevar.net>
diff --git a/t/scanner/examples/libtommath.out 
b/t/scanner/examples/libtommath.out
new file mode 100644
index 0000000..ba4bb35
--- /dev/null
+++ b/t/scanner/examples/libtommath.out
@@ -0,0 +1,4 @@
+Files: *
+Copyright: 2004, Sam Hocevar <s...@hocevar.net>
+License: WTFPL
+

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-perl/packages/libconfig-model-dpkg-perl.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