This file is indexed.

/usr/share/perl5/Debian/Copyright.pm is in libdebian-copyright-perl 0.2-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
=head1 NAME

Debian::Copyright - manage Debian copyright files

=head1 VERSION

This document describes Debian::Copyright version 0.2 .

=head1 SYNOPSIS

    my $c = Debian::Copyright->new();       # construct a new
    $c->read($file1);                       # parse debian copyright file
    $c->read($file2);                       # parse a second
    $c->write($ofile);                      # write to file

=head1 DESCRIPTION

Debian::Copyright can be used for the representation, manipulation and
merging of Debian copyright files in an object-oriented way. It provides easy
reading and writing of the F<debian/copyright> file found in Debian source
packages. Debian has recently started standardising its copyright files
around the machine-readable
L<DEP-5/Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/>
format. 

=head2 note on terminology

The term "Stanza" derives from the
L<dh-make-perl|http://packages.debian.org/sid/dh-make-perl> tool. The official
term would now be "Paragraph". For the purposes of discussing the DEP-5 format the terms are used interchangeably in this documentation.

=head1 FIELDS

=head2 header

An instance of L<Debian::Copyright::Stanza::Header> class. Contains the 
the first stanza of the copyright file. If multiple files were parsed only the
first will be retained.

=head2 files

A hash reference (actually L<Tie::IxHash> instance) with keys being the values
of the C<Files> clause and values instances of
L<Debian::Copyright::Stanza::Files> class.

=head2 licenses

A hash reference (actually L<Tie::IxHash> instance) with keys being the values
of the C<License> clause and values instances of
L<Debian::Copyright::Stanza::License> class.

=cut

package Debian::Copyright;
require v5.10.1;
use base 'Class::Accessor';
use strict;
use Carp;

our $VERSION = '0.2';

__PACKAGE__->mk_accessors(qw( _parser header files licenses ));

use Parse::DebControl;
use Debian::Copyright::Stanza::Header;
use Debian::Copyright::Stanza::Files;
use Debian::Copyright::Stanza::License;
use Tie::IxHash;

=head1 CONSTRUCTOR

=head2 new

Constructs a new L<Debian::Copyright> instance.

The C<header> field is initialised with an empty string.
The C<files_block> and C<license_block> fields are initialised with an
empty instance of L<Tie::IxHash>.

=cut

sub new {
    my $class = shift;

    my $self = $class->SUPER::new();

    $self->_parser( Parse::DebControl->new );

    $self->header(undef);
    $self->files( Tie::IxHash->new );
    $self->licenses( Tie::IxHash->new );

    return $self;
}

=head1 METHODS

=head2 read I<file>

Parse L<debian/copyright> and accessors.

I<file> can be either a file name, an opened file handle or a string scalar
reference.

=cut

sub read {
    my ( $self, $file ) = @_;

    my $parser_method = 'parse_file';

    if ( ref($file) ) {
        $file          = $$file;
        $parser_method = 'parse_mem';
    }

    my $stanzas = $self->_parser->$parser_method( $file,
        { useTieIxHash => 1, verbMultiLine => 1 } );

    if (exists $stanzas->[0]->{Format}) {
        my $header = shift @$stanzas;
        if (! $self->header) {
             $self->header( Debian::Copyright::Stanza::Header->new($header) );
        }
    }

    for (@$stanzas) {
        next if $_->{Format};
        if ( $_->{Files} ) {
            $self->files->Push(
                $_->{Files} => Debian::Copyright::Stanza::Files->new($_) );
            next;
        }
        if ( $_->{License} ) {
            my $license = $_->{License};
            if ($license =~ m{\A([^\n]+)$}xms) {
                $license = $1;
            }
            else {
                croak "License stanza does not make sense";
            }
            $self->licenses->Push(
                $license => Debian::Copyright::Stanza::License->new($_) );
            next;
        }
        die "Got copyright stanza with unrecognised field\n";
    }
    return;
}

=head2 write I<file>

Writes a debian/copyright-like file in I<file> with the contents defined in the
accessor fields.

I<file> can be either a file name, an opened file handle or a string scalar
reference.

=cut

sub write {
    my ( $self, $file ) = @_;

    my @stanzas = (
        $self->header,
        $self->files->Values,
        $self->licenses->Values
    );
    my $string = join "\n", @stanzas;

    if ( ref($file) and ref($file) eq 'SCALAR' ) {
        $$file = $string;
    }
    elsif ( ref($file) and ref($file) eq 'GLOB' ) {
        $file->print($string);
    }
    else {
        my $fh;
        open $fh, '>', $file or die "Unable to open '$file' for writing: $!";

        print $fh $string;
    }
}

=head1 LIMITATIONS

=over

=item This module is written with one particular version of
L<DEP-5|http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/>
in mind. Furthermore version 0.1 of this software was for a draft
version the standard. The changes in going from draft to standard
were such that it was not worth attempting to maintain backwards
compatibility.

=item Test coverage is not yet complete.

=back

=head1 INCOMPATIBILITIES

This version is not backwards compatible with version 0.1.

=head1 ACKNOWLEDGEMENTS

Thanks to Charles Plessy for various comments regarding the documentation.

=head1 COPYRIGHT & LICENSE

Copyright (C) 2011-2012 Nicholas Bamber L<nicholas@periapt.co.uk>

This module was adapted from L<Debian::Control>.
Copyright (C) 2009 Damyan Ivanov L<dmn@debian.org> [Portions]

This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License version 2 as published by the Free
Software Foundation.

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.

=cut

1;