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 d140ada17daf2fd0ef07624873ed44b05b42d4e4 Author: Dominique Dumont <d...@debian.org> Date: Sun Oct 11 20:47:06 2015 +0200 copyright scanner: user can now fill the blanks... --- lib/Dpkg/Copyright/Scanner.pm | 117 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) diff --git a/lib/Dpkg/Copyright/Scanner.pm b/lib/Dpkg/Copyright/Scanner.pm index 1640251..6498e5c 100644 --- a/lib/Dpkg/Copyright/Scanner.pm +++ b/lib/Dpkg/Copyright/Scanner.pm @@ -8,6 +8,8 @@ use IO::Pipe; use Exporter::Lite; use Array::IntSpan; use Path::Tiny; +use Carp; +use YAML; use feature qw/postderef signatures/; no warnings qw/experimental::postderef experimental::signatures/; @@ -102,6 +104,11 @@ sub scan_files ( %args ) { } } + my $current_dir = $args{from_dir} || path('.'); + my $fill_blank_data = __load_fill_blank_data($current_dir); + + my $is_debian_package = -d 'debian'; + my %copyrights ; my $files = {}; my $id = 0; @@ -145,10 +152,35 @@ sub scan_files ( %args ) { next if $l =~ /unknown/i and $c =~ /no-info-found/i; + # this data overrides what's found in current files. This is done before + # the code that merge and coaslesce entries + my $fill_blank = __get_fill_blank($fill_blank_data, $f); + + next if $fill_blank->{skip}; + + if ( $c =~ /no-info-found/ and $fill_blank->{copyright} ) { + $c = $fill_blank->{copyright}; + } + if ( $l =~/unknown/i and $fill_blank->{license} ) { + $l = $fill_blank->{license}; + } + + if ( $c =~ /no-info-found/ and $is_debian_package) { + warn "Path $f has no copyright info. Add a line in debian/fill.copyright.blank file\n"; + } + if ( $l =~/unknown/i and $is_debian_package ) { + warn "Path $f has no license info. Add a line in debian/fill.copyright.blank file\n"; + } + #say "Storing '$f' : '$c' '$l'"; $files->{$f} = $copyrights{$c}{$l} //= $id++; } + my @notused = grep { ! $fill_blank_data->{$_}{used} and $_; } sort keys %$fill_blank_data ; + if (@notused) { + warn "Warning: the following entries from fill.copyright.blanks were not used\n".join("\n",@notused); + } + my @copyrights_by_id ; foreach my $c (sort keys %copyrights) { foreach my $l (sort keys $copyrights{$c}->%* ) { @@ -417,6 +449,47 @@ sub __squash ($h) { return $h; } +sub __load_fill_blank_data ($current_dir) { + my %fill_blanks ; + my $debian = $current_dir->child('debian'); # may be missing in test environment + + if ($debian->is_dir) { + my @fills = $debian->children(qr/fill\.copyright\.blanks\.yml$/); + + say "Note: loading @fills fixes from copyright fix files" if @fills; + foreach my $file ( @fills) { + my $yaml = $file->slurp_utf8; + my $data = Load $yaml; + foreach my $path (sort keys %$data) { + if ($fill_blanks{$path}) { + say "Warning: skipping duplicated fill blank path $path from file $file"; + } + else { + $fill_blanks{$path} = $data->{$path}; + } + + foreach my $k (keys $fill_blanks{$path}->%*) { + die "Error in file $file: Unexpected key '$k' in path '$path'\n" + unless $k =~/^(skip|license|copyright)$/; + } + } + } + } + + return \%fill_blanks; +} + +sub __get_fill_blank ($fbd,$file) { + + foreach my $path (sort keys %$fbd) { + if ($file =~ m(^$path)) { + $fbd->{$path}{used} = 1; + return $fbd->{$path}; + } + } + return {}; +} + 1; __END__ @@ -443,6 +516,50 @@ license information. Information are packed in a way to ease review and maintenance. Files information is grouped with wildcards ('*') to reduce the list of files. +=head1 Filling the blanks + +Sometimes, upstream coders are not perfect: some source files cannot +be parsed correctly or some legal information is missing. + +A file without copyright and license information is skipped. + +On the other hand, a file with either copyright or license missing +will be used. Unfortunately, this will prevent a correct grouping and +merging of copyright entries. + +Instead of patching upstream source files to fill the blank, you can +specify the missing information in a special file. THis file is +C<debian/fill.copyright.blanks.yml>. It should contain a "mapping" +YAML structure (i.e. a hash), where the key is a Perl pattern used to +match a path. E.g: + + --- + debian: + copyright: 2015, Marcel + license: Expat + share/pkgs/openSUSE/systemd/onedsetup: + copyright: 2015, Marcel + share/vendor/ruby/gems/rbvmomi/lib/rbvmomi.*\.rb: + license: Expat + .*/NOTICE: + skip: 1 + share/websockify/: + license: LGPL-2 + src/sunstone/: + license: Apache-2.0 + +Pattern are matched from the beginning a +path. I.e. C<share/websockify/> pattern will match +C<share/websockify/foo.rb> but will not match +C<web/share/websockify/foo.rb>. + +The C<license> key must contain a license short name as returned by +C<license_check>. + +When C<skip> is true, the file is skipped like a file without any +information. + + =head1 METHODS =head2 print_copyright -- 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