DPKG::Parse::Entry - Parse a Package style entry
use DPKG::Parse::Entry; my $data = <<EOH; Package: kernel-image-22.214.171.124 Source: kernel-source-126.96.36.199 Version: wrk01 Priority: optional Section: base Maintainer: Jamie Heilman <email@example.com> Depends: coreutils | fileutils (>= 4.0) Suggests: lilo (>= 19.1) | grub, fdutils, kernel-doc-188.8.131.52 | kernel-source-184.108.40.206 Provides: kernel-image, kernel-image-2.6 Architecture: i386 Filename: packages/./kernel-image-220.127.116.11_wrk01_i386.deb Size: 4293154 Installed-Size: 10312 MD5sum: 2acf846b127b71a1fa1143214b2b85a9 Description: Linux kernel binary image for version 18.104.22.168. EOH my $entry = DPKG::Parse::Entry->new('data' => $data); print $entry->package . " " . $entry->version . "\n"; $entry->package("kernel-foobar");
DPKG::Parse::Entry parses a dpkg "Package" file entry, creating a new DPKG::Parse::Entry instance for it. You submit the contents, beginning with a "Package:" line, as the 'data' argument to new. After that, all the data is populated as lowercased instance methods. For example, if we used the above to create an $entry object, we would have:
$entry->package == "kernel-image-22.214.171.124" $entry->size == 4293154 $entry->md5sum == 2acf846b127b71a1fa1143214b2b85a9
DPKG::Parse::Entry will skip any attribute it does not know about. You can see what it has skipped by passing a true value to the 'debug' option to 'new()'.
It should know all the attributes present in a Packages, available, and status file.
The following accessor methods correspond directly to the values found in the parsed Package block, with one exception: "-" characters are replaced with "_". So, "build-essential" becomes "build_essential".
The accessors are:
architecture bugs build_essential conflicts config_version conffiles depends description enhances essential filename installed_size maintainer md5sum origin package priority provides pre_depends recommends replaces size source section suggests status task tag url version
Creates a new DPKG::Parse::Entry object. 'data' should be a scalar that contains the text of a dpkg-style Package entry. If the 'debug' flag is set, we will Carp about entries we don't have accessors for.
Does the actual parsing of the Package block given to new(). Probably should only be called once per object.