Commit 91f29bac authored by Nicholas Bamber's avatar Nicholas Bamber

Added support for Artistic-2.0, GPL-3 and GPL-3+

* Added support for Artistic-2.0, GPL-3 and GPL-3+
* Added --suggest-stanzas option
parent f4850187
...@@ -11,9 +11,13 @@ my $help = 0; ...@@ -11,9 +11,13 @@ my $help = 0;
# If this is set we don't actually report errors # If this is set we don't actually report errors
# at all, but merely succeed or fail. # at all, but merely succeed or fail.
# TODO: abstract output to allow flexibility of reporting
my $quiet = 0; my $quiet = 0;
# If set output suggested DEP-5 Stanzas
my $suggest_stanzas = 0;
# TODO: abstract output to allow flexibility of reporting
# TODO: What's this again? # TODO: What's this again?
my $display_mapping = 0; my $display_mapping = 0;
my $check_copyright = 1; my $check_copyright = 1;
...@@ -45,6 +49,7 @@ GetOptions( ...@@ -45,6 +49,7 @@ GetOptions(
'config-file=s' => \$config_file, 'config-file=s' => \$config_file,
'changelog-file=s' => \$changelog_file, 'changelog-file=s' => \$changelog_file,
'check-copyright!' => \$check_copyright, 'check-copyright!' => \$check_copyright,
'suggest-stanzas!' => \$suggest_stanzas,
'filters=s@' => sub { 'filters=s@' => sub {
shift; # name of option shift; # name of option
my $value = shift; my $value = shift;
...@@ -74,6 +79,7 @@ my $app = Debian::LicenseReconcile::App->new( ...@@ -74,6 +79,7 @@ my $app = Debian::LicenseReconcile::App->new(
filters => \@filters, filters => \@filters,
format_spec => $format_spec, format_spec => $format_spec,
files => $files, files => $files,
suggest_stanzas => $suggest_stanzas,
); );
exit($app->run); exit($app->run);
...@@ -94,7 +100,7 @@ license-reconcile - reconcile debian/copyright against source ...@@ -94,7 +100,7 @@ license-reconcile - reconcile debian/copyright against source
B<license-reconcile> B<--help>|B<--man> B<license-reconcile> B<--help>|B<--man>
B<license-reconcile> [B<--copyright-file=>I<file>] [B<--no-check-copyright>] [B<--no-format-spec>] [B<--quiet>] [B<--display-mapping>] [B<--directory=>I<directory>] [B<--filters=>I<module1 module2 ...>] [B<--config-file=>I<file>] [B<--changelog-file=>I<file>] [I<files...>] B<license-reconcile> [B<--copyright-file=>I<file>] [B<--no-check-copyright>] [B<--suggest-stanzas>] [B<--no-format-spec>] [B<--quiet>] [B<--display-mapping>] [B<--directory=>I<directory>] [B<--filters=>I<module1 module2 ...>] [B<--config-file=>I<file>] [B<--changelog-file=>I<file>] [I<files...>]
=head1 DESCRIPTION =head1 DESCRIPTION
...@@ -241,6 +247,10 @@ The Debian changelog file which defaults to C<debian/changelog>. The Rules filte ...@@ -241,6 +247,10 @@ The Debian changelog file which defaults to C<debian/changelog>. The Rules filte
uses this to get the current version and the ChangeLog filter gets its data uses this to get the current version and the ChangeLog filter gets its data
from it. from it.
=head2 B<--suggest-stanzas>
If set print out the license and copyright data in DEP-5 format.
=head1 Filters =head1 Filters
By default the filters are processed in the order below. Once a file has been By default the filters are processed in the order below. Once a file has been
......
...@@ -3,6 +3,8 @@ license-reconcile (0.9) UNRELEASED; urgency=medium ...@@ -3,6 +3,8 @@ license-reconcile (0.9) UNRELEASED; urgency=medium
* Code reviewed: bin/license-reconcile [in progress] * Code reviewed: bin/license-reconcile [in progress]
* Allow file aguments to restrict activity to stated files * Allow file aguments to restrict activity to stated files
* Added bash completion file * Added bash completion file
* Added support for Artistic-2.0, GPL-3 and GPL-3+
* Added --suggest-stanzas option
-- Nicholas Bamber <nicholas@periapt.co.uk> Sat, 07 Nov 2015 23:55:16 +0000 -- Nicholas Bamber <nicholas@periapt.co.uk> Sat, 07 Nov 2015 23:55:16 +0000
...@@ -25,7 +27,6 @@ license-reconcile (0.8) unstable; urgency=medium ...@@ -25,7 +27,6 @@ license-reconcile (0.8) unstable; urgency=medium
* Corrected sequence of filters and commented * Corrected sequence of filters and commented
* Replaced examples directory with list of projects in the documentation * Replaced examples directory with list of projects in the documentation
* Updated debian/license-reconcile.yml * Updated debian/license-reconcile.yml
* Added support for Artistic-2.0, GPL-3 and GPL-3+
-- Nicholas Bamber <nicholas@periapt.co.uk> Thu, 05 Nov 2015 15:44:47 +0000 -- Nicholas Bamber <nicholas@periapt.co.uk> Thu, 05 Nov 2015 15:44:47 +0000
......
_license_reconcile()
{
local cur prev words cword _DC_FILE
_init_completion || return
case $prev in
--copyright-file)
_DC_FILE=debian/copyright
if [[ -r $_DC_FILE && $_DC_FILE =~ ^$cur ]]
then
COMPREPLY=( $_DC_FILE )
return 0
fi
_filedir
return 0
;;
--changelog-file)
_DC_FILE=debian/changelog
if [[ -r $_DC_FILE && $_DC_FILE =~ ^$cur ]]
then
COMPREPLY=( $_DC_FILE )
return 0
fi
_filedir
return 0
;;
--config-file)
_DC_FILE=debian/license-reconcile.yml
if [[ -r $_DC_FILE && $_DC_FILE =~ ^$cur ]]
then
COMPREPLY=( $_DC_FILE )
return 0
fi
_filedir
return 0
;;
--directory)
_filedir -d
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--copyright-file --no-check-copyright
--no-format-spec --quiet --suggest-stanzas --display-mapping --directory --filters
--config-file --changelog-file' -- "$cur" ) )
else
_filedir
fi
return 0
}
complete -F _license_reconcile license-reconcile
...@@ -16,6 +16,7 @@ use Class::XSAccessor ...@@ -16,6 +16,7 @@ use Class::XSAccessor
filters => 'filters', filters => 'filters',
format_spec => 'format_spec', format_spec => 'format_spec',
files=>'files', files=>'files',
suggest_stanzas=> 'suggest_stanzas',
}, },
; ;
use File::Slurp; use File::Slurp;
...@@ -118,6 +119,7 @@ sub run { ...@@ -118,6 +119,7 @@ sub run {
Readonly my $CONFIG => $self->_parse_config; Readonly my $CONFIG => $self->_parse_config;
Readonly my $LICENSECHECK => $self->_build_licensecheck($CONFIG); Readonly my $LICENSECHECK => $self->_build_licensecheck($CONFIG);
Readonly my $COPYRIGHT_TARGET => $self->_read_copyright_file; Readonly my $COPYRIGHT_TARGET => $self->_read_copyright_file;
my $file_checked = {};
if ($COPYRIGHT_TARGET) { if ($COPYRIGHT_TARGET) {
Readonly my $FILE_MAPPING => $self->_build_file_mapping($COPYRIGHT_TARGET); Readonly my $FILE_MAPPING => $self->_build_file_mapping($COPYRIGHT_TARGET);
...@@ -125,7 +127,6 @@ sub run { ...@@ -125,7 +127,6 @@ sub run {
Debian::LicenseReconcile->new( Debian::LicenseReconcile->new(
$COPYRIGHT_TARGET->patterns($self->check_copyright) $COPYRIGHT_TARGET->patterns($self->check_copyright)
); );
my $file_checked = {};
foreach my $filter_name (@{$self->filters}) { foreach my $filter_name (@{$self->filters}) {
$file_checked = $self->_run_filter( $file_checked = $self->_run_filter(
$filter_name, $filter_name,
...@@ -139,6 +140,26 @@ sub run { ...@@ -139,6 +140,26 @@ sub run {
} }
} }
if ($self->suggest_stanzas) {
foreach my $f (sort keys %$file_checked) {
print "Files: $f\n";
if ($self->check_copyright) {
my @copyright = @{$file_checked->{$f}->{copyright}};
if (1 == scalar @copyright) {
print "Copyright: $copyright[0]\n";
}
else {
foreach my $line (@copyright) {
print " $line\n";
}
}
}
print "License: $file_checked->{$f}->{license}\n";
print "\n";
}
}
return $self->_report_errors; return $self->_report_errors;
} }
...@@ -172,7 +193,7 @@ sub _run_filter { ...@@ -172,7 +193,7 @@ sub _run_filter {
foreach my $titbit ($test->get_info) { foreach my $titbit ($test->get_info) {
next if $file_checked->{$titbit->{file}}; next if $file_checked->{$titbit->{file}};
next if $self->files and not exists $self->files->{$titbit->{file}}; next if $self->files and not exists $self->files->{$titbit->{file}};
$file_checked->{$titbit->{file}} = 1; $file_checked->{$titbit->{file}} = $titbit;
if (exists $file_mapping->{$titbit->{file}}) { if (exists $file_mapping->{$titbit->{file}}) {
$reconcile->check( $reconcile->check(
$titbit, $titbit,
...@@ -270,7 +291,7 @@ Nicholas Bamber, C<< <nicholas at periapt.co.uk> >> ...@@ -270,7 +291,7 @@ Nicholas Bamber, C<< <nicholas at periapt.co.uk> >>
=head1 LICENSE AND COPYRIGHT =head1 LICENSE AND COPYRIGHT
Copyright 2012, 2015, Nicholas Bamber C<< <nicholas at periapt.co.uk> >>. Copyright 2012, 2015, Nicholas Bamber <nicholas at periapt.co.uk> .
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
under the terms of either: the GNU General Public License as published under the terms of either: the GNU General Public License as published
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment