[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

AptPkg: How to map from AptPkg::Cache::Package to AptPkg::Source object



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

how can I associate an package object with the related source object?
See example (with my thoughts in comments) below. It looks very ugly to
me therefore I'm sure there is an (easy) way.
`apt-cache show package` also lists source name and version if they
differ from binary ones.

Please cc me as I'm not subscribed to this list.


Thank you for your help :)

Dominique


Example: I have a specific package "foobar" with last version (eg.
0.5.1+b1). The corresponding source package is "blub" (with eg. version
0.5.1):

#!/usr/bin/perl
use AptPkg::Cache;
use AptPkg::Source;

my $package = "foobar";

my $_cache = AptPkg::Cache->new();
my $_src = AptPkg::Source->new();

my $package = $_cache->{$package}{VersionList}[0];

# Now I have to search related source package, so I lookup source name
# using AptPkg::PkgRecords. But perhaps source package name is
# different in some versions so I have to assign AptPkg::Cache::VerFile
# object.
# Here I assume corresponding VerFile object is first element in
# FileList array:
my $pkgrecord = $_cache->packages->lookup($$package{FileList}[0]);
my $srcpkgname = $$pkgrecord{SourcePkg};
print "Sourcepackage: $srcpkgname\n";  # Sourcepackage: blub

# Now I can query related sourcepackage array @{$_src->{$srcpkgname}}
# but how to assign to binary package if versions can differ?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iQEcBAEBAgAGBQJPoBb7AAoJENONJ1Ky5PTzL60H/AoI3IbLYU9lS1bJZ4O5fsC+
eXXcEz2xDM8hyPQD/PqtVdtbStPYeN/osIfmmoW4ws8X5VOfVOcVDoy4LuWvPCC4
8xGdkEQJENyc5dr+RPWrvucpopVPT1sPOULTHbh3JPKW9tIM9HNWD3jU2kVYoEIp
IaX9xrbuW7FFHqYKZlzKIrWUhXVwYNLBU+uXBVdVU4g5n+yoAMq6g46rbm7fOGmU
w/e7I1c4Z4oN3/RYdHX5889D9vyD34Q+p8fqQ+bZN8dIwSvhv5iVwjSjP64zEZAr
g4BvkCm+it9ZDns/hy9NCdNtcBYX9Jwd2Pbw5irRBSURAfppspTdQMWDTtoRw4Y=
=A1L4
-----END PGP SIGNATURE-----


Reply to: