RPM Community Forums

Mailing List Message of <rpm-users>

Re: Perl: Query with RPM-Perl in 5.x for a package?

From: Michael Jennings <mej@kainx.org>
Date: Wed 13 Aug 2008 - 08:41:19 CEST
Message-ID: <20080813064119.GD21315@kainx.org>
On Wednesday, 13 August 2008, at 00:42:42 (+0200),
Robert Scheck wrote:

> I know, that the rpm-perl part was completely rewritten with the 5.x
> release series and I'm now trying to port my old rpm-perl 4.5
> script.  I already read the man pages, but it seems just to confuse
> me and I am not getting a usable result - note that, the man pages
> seem to be incomplete ... ;-)
> All I'm trying to do is: "rpm -q --qf '%{version}-%{release}\n' rpm"
> using the perl interface. Old-style rpm-perl 4.5 was this:
>   my $rpmdb = RPM->open_rpm_db();
>   my $query = $rpmdb->find_by_name_iter("rpm");
>   my $result = $query->next;
>   print $result->as_nvre;
> Any suggestions and ideas for the new rpm perl interface?

# perl -MRPM::PackageIterator -e '$iter = RPM::PackageIterator->new("NAME", "rpm"); while ($pkg = $iter->next()) {print $pkg->as_nvre(), "\n";}'


Michael Jennings (a.k.a. KainX)  http://www.kainx.org/  <mej@kainx.org>
Linux Server/Cluster Admin, LBL.gov       Author, Eterm (www.eterm.org)
 "And every time you speak her name does she know how you told me
  you'd hold me until you died?  But you're still alive."
                              -- Alanis Morrissette, "You Oughta Know"
Received on Wed Aug 13 08:49:27 2008
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.