This file is indexed.

/usr/share/perl5/DPKG/Log/Entry.pm is in libdpkg-log-perl 1.20-2.

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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
=head1 NAME

DPKG::Log::Entry - Describe a log entry in a dpkg.log

=head1 VERSION

version 1.20

=head1 SYNOPSIS

use DPKG::Log::Entry;

$dpkg_log_entry = DPKG::Log::Entry->new( line => $line, $lineno => 1)

$dpkg_log_entry->timestamp($dt);

$dpkg_log_entry->associated_package("foo");


=head1 DESCRIPTION

This module is used to describe one line in a dpkg log
by parameterizing every line into generic parameters like

=over 3

=item * Type of log entry (startup-, status-, action-lines)

=item * Timestamp

=item * Subject of log entry (e.g. package, packages or archives)

=item * Package name (if log entry refers to a package subject)

=back

and so on.

The various parameters are described below together with
the various methods to access or modify them. 

=head1 METHODS


=over 4

=cut
package DPKG::Log::Entry;
BEGIN {
  $DPKG::Log::Entry::VERSION = '1.20';
}

use strict;
use warnings;
use overload ( '""' => 'line' );

require Exporter;
our @ISA = qw(Exporter);
our @EXPORT = qw( $valid_types $valid_actions );

our $valid_types = {
    status => 1,
    action => 1,
    startup => 1,
    conffile_action => 1
    
};

our $valid_actions = {
   'install' => 1,
   'configure' => 1,
   'trigproc' => 1,
   'upgrade' => 1,
   'remove' => 1,
   'purge' => 1,
};

use Params::Validate qw(:all);

=item $dpkg_log_entry = PACKAGE->new( 'line' => $line, 'lineno' => $lineno )

Returns a new DPKG::Log::Entry object.
The arguments B<line> and B<lineno> are mandatore. They store the complete line
as stored in the log and the line number.

Additionally its possible to specify every attribute the object can store,
as 'key' => 'value' pairs.

=back

=cut
sub new {
    my $package = shift;
    $package = ref($package) if ref($package);

    my %params = validate( 
        @_, { 
                'line' => { 'type' => SCALAR },
                'lineno' => { 'type' => SCALAR },
                'timestamp' => '',
                'associated_package' => '',
                'action' => '',
                'status' => '',
                'subject' => '',
                'type' => '',
                'installed_version' => '',
                'available_version' => '',
                'decision' => '',
                'conffile' => '',
             }
    );
    my $self = {
        %params
    };
    bless($self, $package);
    return $self;
}

=head1 ATTRIBUTES

=over 4

=item $dpkg_log_entry->line() / line

Return the full log line. This attribute is set on object initialization.

=cut
sub line {
    my $self = shift;
    return $self->{line};
}

=item $dpkg_log_entry->lineno() / lineno

Return the line number of this entry. This attribute is set on object initialization.

=cut
sub lineno {
    my $self = shift;
    return $self->{lineno};
}

=item $dpkg_log_entry->timestamp() / timestamp

Get or set the timestamp of this object. Should be a DateTime object.

=cut
sub timestamp {
    my ($self, $timestamp) = @_;

    if ($timestamp) {
        if ((not ref($timestamp)) or (ref($timestamp) ne "DateTime")) {
            croak("timestamp has to be a DateTime object");
        }
        $self->{timestamp} = $timestamp;
    } else {
        $timestamp = $self->{timestamp};
    }
    return $timestamp;
}

=item $dpkg_log_entry->type() / type

Get or set the type of this entry. Specifies weither this is a startup,
status or action line.

=cut 
sub type {
    my ($self, $type) = @_;

    if ($type) {
        if (not defined($valid_types->{$type})) {
            croak("$type is not a valid type. has to be one of ".join(",", keys %{$valid_types}));
        }
        $self->{type} = $type;
    } else {
        $type = $self->{type}
    }
    return $type;
}

=item $dpkg_log_entry->associated_package() / associated_package

Get or set the associated_package of this entry. This is for lines that are associated to a certain
package like in action or status lines. Its usually unset for startup and status lines.

=cut 
sub associated_package {
    my ($self, $associated_package) = @_;

    if ($associated_package) {
        $self->{associated_package} = $associated_package;
    } else {
        $associated_package = $self->{associated_package};
    }
    return $associated_package;
}

=item $dpkg_log_entry->action() / action

Get or set the action of this entry. This is for lines that have a certain action,
like in startup-lines (unpack, configure) or action lines (install, remove).
It is usally unset for status lines.

=cut 
sub action {
    my ($self, $action) = @_;

    if ($action) {
        if (not defined($valid_actions->{$action})) {
            croak("$action is not a valid action. has to be one of ".join(",", keys %{$valid_actions}));
        }
        $self->{action} = $action;
    } else {
        $action = $self->{action};
    }
    return $action;
}

=item $dpkg_log_entry->status() / status

Get or set the status of the package this entry refers to.

=cut 
sub status {
    my ($self, $status) = @_;

    if ($status) {
        $self->{'status'} = $status;
    } else {
        $status = $self->{status}
    }
    return $status;
}

=item $dpkg_log_entry->subject() / subject

Gets or Defines the subject of the entry. For startup lines this is usually 'archives' or 'packages'
for all other lines its 'package'.

=cut 

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

    if ($subject) {
        $self->{subject} = $subject;
    } else {
        $subject = $self->{subject};
    }
    return $subject;
}

=item $dpkg_log_entry->installed_version() / installed_version

Gets or Defines the installed_version of the package this entry refers to.
It refers to the current installed version of the package depending on the
current status. Is "<none>" (or similar) if action is 'install', old version in
case of an upgrade.
=cut 
sub installed_version {
    my ($self, $installed_version) = @_;

    if ($installed_version) {
        $self->{'installed_version'} = $installed_version;
    } else {
        $installed_version = $self->{installed_version};
    }
    return $installed_version;
}

=item $dpkg_log_entry->available_version() / available_version

Gets or Defines the available_version of the package this entry refers to.
It refers to the currently available version of the package depending on the
current status. Is different from installed_version if the action is install or upgrade.
=cut 
sub available_version {
    my ($self, $available_version) = @_;
    if ($available_version) {
       $self->{'available_version'} = $available_version;
    } else {
        $available_version = $self->{available_version};
    }
    return $available_version;
}

=item $dpkg_log_entry->conffile() / conffile

Get or set a conffile for a line indicating a conffile change.

=cut
sub conffile {
    my ($self, $conffile) = @_;
    if ($conffile) {
        $self->{conffile} = $conffile;
    } else {
        $conffile = $self->{conffile};
    }
}

=item $dpkg_log_entry->decision() / decision

Gets or defines the decision for a line indicating a conffile change.

=cut
sub decision {
    my ($self, $decision) = @_;
    if ($decision) {
        $self->{decision} = $decision;
    } else {
        $decision = $self->{decision}
    }
}

=back

=head1 SEE ALSO

L<DateTime>

=head1 AUTHOR

Patrick Schoenfeld <schoenfeld@debian.org>.

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2011 Patrick Schoenfeld <schoenfeld@debian.org>

This library is free software.
You can redistribute it and/or modify it under the same terms as perl itself.

=cut

1;
# vim: expandtab:ts=4:sw=4