| DPKG-Parse documentation | Contained in the DPKG-Parse distribution. |
DPKG::Parse::Status - Parse the "status" file
use DPKG::Parse::Status;
my $status = DPKG::Parse::Status->new;
while (my $entry = $status->next_package) {
print $entry->package . " " . $entry->version . "\n";
}
my $postfix = $status->get_package('name' => 'postfix');
my $postfix = $status->get_installed('name' => 'postfix');
DPKG::Parse::Status parses a dpkg "status" file and turns each entry into a DPKG::Parse::Entry object. By default, it uses the Debian default location of "/var/lib/dpkg/status".
See DPKG::Parse for more information on the get_package and next_package methods.
See DPKG::Parse::Entry for more information on the entry objects.
Creates a new DPKG::Parse::Status object. By default, it tries to open /var/lib/dpkg/status.
Calls DPKG::Parse::parse, and populates the "installed" accessor with a hash of packages whose "status" is "install ok installed".
Returns a DPKG::Parse::Entry object for the given package, or undef if it's not found.
Adam Jacob, holoway@cpan.org
This library is free software. You can redistribute it and/or modify it under the same terms as perl itself.
| DPKG-Parse documentation | Contained in the DPKG-Parse distribution. |
# # DPKG::Parse::Status.pm # Created by: Adam Jacob, Marchex, <adam@marchex.com> # Created on: 12/19/2005 02:21:25 PM PST # # $Id: $
package DPKG::Parse::Status; use DPKG::Parse::Entry; use Params::Validate qw(:all); use Class::C3; use base qw(DPKG::Parse); use strict; use warnings; DPKG::Parse::Status->mk_accessors(qw(installed));
sub new { my $pkg = shift; my %p = validate(@_, { 'filename' => { 'type' => SCALAR, 'default' => '/var/lib/dpkg/status', 'optional' => 1 }, } ); my $ref = $pkg->next::method('filename' => $p{'filename'}); return $ref; }
sub parse { my $pkg = shift; $pkg->next::method; my $installed; foreach my $entry (@{$pkg->entryarray}) { if ($entry->status =~ /^install ok installed$/) { $installed->{$entry->package} = $entry; } } $pkg->installed($installed); }
sub get_installed { my $pkg = shift; my %p = validate( @_, { 'name' => { 'type' => SCALAR, }, }, ); return $pkg->get_package('name' => $p{'name'}, 'hash' => 'installed'); } 1; __END__