Re: using AptPkg to map from binary package to source package
On Thu, Jun 30, 2005 at 09:14:00PM -0400, Roderick Schertler wrote:
>Using AptPkg (but not AptPkg::Source, I don't want to assume the user
>has downloaded source info), is there a better way to obtain the name of
>the source package which provides a particular binary package than using
>the info in $cache->{$binary_package}{VersionList}[0]{FileList}[0] to
>read the available record and parse it from there?
There's a parser for the available record provided by the
AptPkg::PkgRecords class.
Get an object from $cache->packages, and use the lookup method.
--bod
#!/usr/bin/perl
use AptPkg::Cache;
my $cache = AptPkg::Cache->new;
my $packages = $cache->packages;
for (@ARGV)
{
my $p = $packages->lookup($_) or next;
print "$_\t$p->{SourcePkg}\n";
}
Reply to: