I think you can always use the rpm command:
$ rpm --query --all --qf "%-30{NAME} - %{VERSION}\n"
Then you can use this in various ways:
use autodie; open my $RPM_FH, "-|", qq(rpm --query --all --qf "%-30{NAME} - %{VERSION}\n"); my @rpmLines = <$RPM_FH>; close $RPM_FH;
Or:
my @rpmLines = qx(rpm --query --all --qf "%-30{NAME} - %{VERSION}\n");
I also found an RPM :: Database that would be a more Perlish way of doing things. This package associates the RPM database with a hash:
use RPM::Database; tie %RPM, "RPM::Database" or die "$RPM::err"; for (sort keys %RPM) { ... }
I never used it, so I'm not sure exactly how it will work. For example, I assume that the value of each hash record is a kind of database object. For example, I would suggest that it would be important to know the version number and files in your RPM package, and there should be some information that can be pulled out, but I did not see anything in RPM::Database or in RPM :: HEADER . Play with him. You can use Data :: Dumper to help examine the returned objects.
WARNING Use Data::Dumper to help examine information in objects and classes. Do not use it to figure out how to infer information directly from objects. Use the correct methods and classes.
source share