looking for rpm/yum database utility

Bryn M. Reeves bmr at redhat.com
Tue Jun 7 13:15:54 UTC 2011


On 06/04/2011 04:23 AM, suvayu ali wrote:
> On Fri, Jun 3, 2011 at 7:41 PM, Robert G. (Doc) Savage
> <dsavage at peaknet.net> wrote:
>> Sam & JD,
>>
>> I must apologize for asking this question to the wrong list. I knew the
>> Fedora version does this. What I'm actually looking for is that same
>> repo info for a RHEL5 system with some additional packages sourced from
>> RHN, EPEL, CentOS, RPMFusion, ElRepo, Adobe, and some other cats & dogs.
>> The RHEL5 version of yum simply tells me "installed".
> 
> Maybe you could parse the output of rpm -qi and get something useful out of it?
> 

Why parse things when you can just ask for the information from RPM in the
format you'd like it?

The rpm command allows you to list the available query tags (fields) and then
construct custom query formats on the command line:

$ rpm --querytags | wc -l
183
$ rpm --querytags | head
ARCH
ARCHIVESIZE
BASENAMES
BUGURL
BUILDARCHS
BUILDHOST
BUILDTIME
C
CHANGELOGNAME
CHANGELOGTEXT

Anyway, in this case I don't think it'll help directly as the package
installation repo is not stored in the database (rpm doesn't know anything about
yum or repositories) but is retrieved from the yum metadata.

I think that yum-utils and repoquery are available for RHEL5 (in EPEL iirc) so
maybe you can do something with that.

Failing that if you just want to differentiate the list of vendors above you can
probably do this via the RPM Vendor tag instead. Doing this on my f15 box I see:

$ rpm -qa --queryformat "%{VENDOR}\n" | sort | uniq
Fedora Project
(none)
Red Hat, Inc.
RPM Fusion

Then you can break that out by vendor by adding in the name and grepping:

$ rpm -qa --queryformat "%{NAME} %{VENDOR}\n" | grep '(none)'
gpg-pubkey (none)
bibble5 (none)
chromium-libs (none)
kmod-nvidia-2.6.38.6-26.rc1.fc15.x86_64 (none)
gpg-pubkey (none)
kmod-nvidia-2.6.38.3-18.fc15.x86_64 (none)
gpg-pubkey (none)
v8 (none)
gpg-pubkey (none)
chromium (none)
kmod-nvidia-2.6.38.5-22.fc15.x86_64 (none)
gpg-pubkey (none)

Not ideal I know but it may still be useful enough - e.g. all those
"gpg-pubkey"s are a bit annoying - the summary field reveals more than the other
headers in that case:

$ rpm -q gpg-pubkey | xargs rpm -q --queryformat '%{SUMMARY}\n'
gpg(Fedora (15) <fedora at fedoraproject.org>)
gpg(RPM Fusion nonfree repository for Fedora (14)
<rpmfusion-buildsys at lists.rpmfusion.org>)
gpg(RPM Fusion nonfree repository for Fedora (15)
<rpmfusion-buildsys at lists.rpmfusion.org>)
gpg(RPM Fusion free repository for Fedora (14)
<rpmfusion-buildsys at lists.rpmfusion.org>)
gpg(RPM Fusion free repository for Fedora (15)
<rpmfusion-buildsys at lists.rpmfusion.org>)

Regards,
Bryn.


More information about the users mailing list