/usr/share/perl5/Dpkg/Control/Info.pm is in libdpkg-perl 1.16.1.2ubuntu7.7.
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 | # Copyright © 2007-2010 Raphaël Hertzog <hertzog@debian.org>
#
# 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 2 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/>.
package Dpkg::Control::Info;
use strict;
use warnings;
our $VERSION = "1.00";
use Dpkg::Control;
use Dpkg::ErrorHandling;
use Dpkg::Gettext;
use base qw(Dpkg::Interface::Storable);
use overload
'@{}' => sub { return [ $_[0]->{source}, @{$_[0]->{packages}} ] };
=encoding utf8
=head1 NAME
Dpkg::Control::Info - parse files like debian/control
=head1 DESCRIPTION
It provides an object to access data of files that follow the same
syntax than debian/control.
=head1 FUNCTIONS
=over 4
=item $c = Dpkg::Control::Info->new($file)
Create a new Dpkg::Control::Info object for $file. If $file is omitted, it
loads debian/control. If file is "-", it parses the standard input.
=cut
sub new {
my ($this, $arg) = @_;
my $class = ref($this) || $this;
my $self = {
'source' => undef,
'packages' => [],
};
bless $self, $class;
if ($arg) {
$self->load($arg);
} else {
$self->load("debian/control");
}
return $self;
}
=item $c->reset()
Resets what got read.
=cut
sub reset {
my $self = shift;
$self->{source} = undef;
$self->{packages} = [];
}
=item $c->load($file)
Load the content of $file. Exits in case of errors. If file is "-", it
loads from the standard input.
=item $c->parse($fh, $description)
Parse a control file from the given filehandle. Exits in case of errors.
$description is used to describe the filehandle, ideally it's a filename
or a description of where the data comes from. It's used in error
messages.
=cut
sub parse {
my ($self, $fh, $desc) = @_;
$self->reset();
my $cdata = Dpkg::Control->new(type => CTRL_INFO_SRC);
return if not $cdata->parse($fh, $desc);
$self->{source} = $cdata;
unless (exists $cdata->{Source}) {
syntaxerr($desc, _g("first block lacks a source field"));
}
while (1) {
$cdata = Dpkg::Control->new(type => CTRL_INFO_PKG);
last if not $cdata->parse($fh, $desc);
push @{$self->{packages}}, $cdata;
unless (exists $cdata->{Package}) {
syntaxerr($desc, _g("block lacks the '%s' field"), "Package");
}
unless (exists $cdata->{Architecture}) {
syntaxerr($desc, _g("block lacks the '%s' field"), "Architecture");
}
}
}
=item $c->[0]
=item $c->get_source()
Returns a Dpkg::Control object containing the fields concerning the
source package.
=cut
sub get_source {
my $self = shift;
return $self->{source};
}
=item $c->get_pkg_by_idx($idx)
Returns a Dpkg::Control object containing the fields concerning the binary
package numbered $idx (starting at 1).
=cut
sub get_pkg_by_idx {
my ($self, $idx) = @_;
return $self->{packages}[--$idx];
}
=item $c->get_pkg_by_name($name)
Returns a Dpkg::Control object containing the fields concerning the binary
package named $name.
=cut
sub get_pkg_by_name {
my ($self, $name) = @_;
foreach my $pkg (@{$self->{packages}}) {
return $pkg if ($pkg->{Package} eq $name);
}
return undef;
}
=item $c->get_packages()
Returns a list containing the Dpkg::Control objects for all binary packages.
=cut
sub get_packages {
my $self = shift;
return @{$self->{packages}};
}
=item $c->output($filehandle)
Dump the content into a filehandle.
=cut
sub output {
my ($self, $fh) = @_;
my $str;
$str .= $self->{source}->output($fh);
foreach my $pkg (@{$self->{packages}}) {
print $fh "\n";
$str .= "\n" . $pkg->output($fh);
}
return $str;
}
=item "$c"
Return a string representation of the content.
=item @{$c}
Return a list of Dpkg::Control objects, the first one is corresponding to
source information and the following ones are the binary packages
information.
=back
=head1 AUTHOR
Raphaël Hertzog <hertzog@debian.org>.
=cut
1;
|