Dpkg
view release on metacpan or search on metacpan
lib/Dpkg/Control/Info.pm view on Meta::CPAN
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 is used in error messages.
The data in the object is reset before parsing new control files.
=cut
sub parse {
my ($self, $fh, $desc) = @_;
$self->reset();
my $cdata = Dpkg::Control->new(type => CTRL_TMPL_SRC);
return if not $cdata->parse($fh, $desc);
$self->{source} = $cdata;
unless (exists $cdata->{Source}) {
$cdata->parse_error($desc, g_("first stanza lacks a '%s' field"),
'Source');
}
while (1) {
$cdata = Dpkg::Control->new(type => CTRL_TMPL_PKG);
last if not $cdata->parse($fh, $desc);
push @{$self->{packages}}, $cdata;
unless (exists $cdata->{Package}) {
$cdata->parse_error($desc, g_("stanza lacks the '%s' field"),
'Package');
}
unless (exists $cdata->{Architecture}) {
$cdata->parse_error($desc, g_("stanza lacks the '%s' field"),
'Architecture');
}
}
}
=item $c->load($file)
Load the content of $file. Exits in case of errors. If file is "-", it
loads from the standard input.
( run in 0.682 second using v1.01-cache-2.11-cpan-454fe037f31 )