This file is indexed.

/usr/share/perl5/Pod/Weaver/Section/Legal/Complicated.pm is in libpod-weaver-section-legal-complicated-perl 1.22-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
package Pod::Weaver::Section::Legal::Complicated;
$Pod::Weaver::Section::Legal::Complicated::VERSION = '1.22';
use utf8;
## Copyright (C) 2013-2017 Carnë Draug <carandraug+dev@gmail.com>
##
## 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/>.

# ABSTRACT: Different authors, copyright holders, and licenses for each module.
# AUTHOR:   Carnë Draug <cdraug@cpan.org>
# OWNER:    Carnë Draug
# LICENSE:  GPL_3

use strict;
use warnings;
use Module::Load;
use Moose;
use MooseX::Types::Moose qw(Bool Int);
use List::MoreUtils qw(uniq);
use Pod::Elemental::Element::Nested;
use Pod::Elemental::Element::Pod5::Ordinary;
with (
  'Pod::Weaver::Role::Section',
);
use namespace::autoclean;



has add_dist_license => (
  is      => 'ro',
  isa     => Bool,
  lazy    => 1,
  default => 0,
);


has head => (
  is      => 'ro',
  isa     => Int,
  lazy    => 1,
  default => 1,
);


sub _extract_comments {
  my (undef, $input, $tag) = @_;
  my $ppi_document = $input->{ppi_document};

  my @comments;
  $ppi_document->find( sub {
    my $ppi_node = $_[1];
    if ($ppi_node->isa('PPI::Token::Comment') &&
        $ppi_node->content =~ qr/^\s*#+\s*$tag:\s*(.+?)\s*$/m ) {
      push (@comments, $1);
    }
    return 0;
  });
  return @comments;
}


sub _join {
  my $text;
  if (@_ == 1) {
    $text = $_[0];
  } else {
    $text  = join (", ", @_[0 .. $#_ -1]);
    $text .= ", and $_[-1]";
  }
  return $text;
}


sub weave_section {
  my ($self, $document, $input) = @_;
  my $filename  = $input->{filename};

  my @authors   = $self->_extract_comments($input, "AUTHOR");
  my @owners    = $self->_extract_comments($input, "OWNER");
  my @licenses  = $self->_extract_comments($input, "LICENSE");

  @licenses  = map {
    my $license = "Software::License::$_";
    eval {
      load $license;
      ## it doesn't matter who's the holder at this point. We just want the
      ## pretty text for the license name
      $license = $license->new({holder => "does not matter"})
    };
    Carp::croak "Possibly $_ license module not installed: $@" if $@;
    $license;
  } @licenses;

  if ($self->add_dist_license && $input->{license}) {
    push (@licenses, $input->{license});
  }

  Carp::croak "Unable to find an author for $filename" unless scalar (@authors);
  Carp::croak "Unable to find a copyright owner for $filename" unless scalar (@owners);
  Carp::croak "Unable to find a copyright license for $filename" unless scalar (@licenses);

  my ($author_text, $license_text);

  $author_text  = join ("\n\n", @authors);

  ## One day, we might need a more complex legal text but in the mean
  ## time, this is fine to avoid repeated entries
  @licenses = uniq (map { lcfirst($_->name) } @licenses);
  ## and make pretty English with year and owner names
  @owners = map {
    my $text;
    ## there may be spaces and dashes on the years:
    ##  2003, 2004
    ##  2006-2007, 2008
    ##
    ## so it must start and end with numbers, but in the middle we allow spaces,
    ## dashes and commas as well.
    $_ =~ m/^([\d][\d\s\-,]*[\d])?\s*(.+)$/;
    $text .= "$1 " if $1;
    $text .= "by $2";
    $text;
  } @owners;

  $license_text .= "This software is copyright (c) ". _join (@owners) . ".\n";
  $license_text .= "\n";
  $license_text .= "This software is available under " . _join (@licenses) . ".";

  push (@{$document->children}, Pod::Elemental::Element::Nested->new({
    command  => "head" . $self->head,
    content  => @authors > 1? "AUTHORS" : "AUTHOR",
    children => [Pod::Elemental::Element::Pod5::Ordinary->new({ content => $author_text })],
  }));

  push (@{$document->children}, Pod::Elemental::Element::Nested->new({
    command  => "head" . $self->head,
    content  => "COPYRIGHT",
    children => [Pod::Elemental::Element::Pod5::Ordinary->new({ content => $license_text })],
  }));
}

__PACKAGE__->meta->make_immutable;
1;

__END__

=pod

=encoding UTF-8

=head1 NAME

Pod::Weaver::Section::Legal::Complicated - Different authors, copyright holders, and licenses for each module.

=head1 VERSION

version 1.22

=head1 SYNOPSIS

In your F<weaver.ini>

  [Legal::Complicated]

=head1 DESCRIPTION

This plugin is aimed at distributions that have several files, each of them with
possibly different authors, copyright owners and licenses.

It will look for these values in comments of the source code (analyzed
through a C<ppi_document>) with the following form:

  # AUTHOR:  John Doe <john.doe@otherside.com>
  # AUTHOR:  Mary Jane <mary.jane@thisside.com>
  # OWNER:   2001-2005 University of Over Here
  # OWNER:   2012 Mary Jane
  # LICENSE: GPL_3

This example would generate the following POD:

  =head2 AUTHORS

  John Doe <john.doe@otherside.com>
  Mary Jane <mary.jane@thisside.com>

  =head2 COPYRIGHT

  This software is copyright (c) 2001-2005 by University of Over Here, and 2012 by Mary Jane.

  This software is available under The GNU General Public License, Version 3, June 2007.

Note that this plugin makes a distinction between the authors (whoever wrote the
code), and the actual copyright owners (possibly the person who paid them to
write it).

I am not a lawyer myself, any feedback on better ways to deal with this kind of
situations is most welcome.

=head1 ATTRIBUTES

=head2 add_dist_license

If true, it will also add the distribution license to each of the files.
Defaults to false.

=head2 head

Sets the heading level for the legal section. Defaults to 1.

=head1 NOTE ON DEPENDENCIES

This plugin is dependent on the L<Software::License::*> module of the license
being used. Since it is not feasible to list them all, only L<Software::License>
is listed as dependency (of the distribution, even though it is not actually
used directly.

=for Pod::Coverage _extract_comments

=for Pod::Coverage _join
makes sure there's not too many "and" when there's too many entries

=for Pod::Coverage weave_section

=head1 AUTHOR

Carnë Draug <cdraug@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is Copyright (c) 2013-2017 by Carnë Draug.

This is free software, licensed under:

  The GNU General Public License, Version 3, June 2007

=cut