Product SiteDocumentation Site

Querying the RPM Database

In addition to querying RPM files, you can script the commands you use to query the RPM database. This is most useful for the long commands with query formats, especially if you have a hard time remembering all the formats.

Querying for all packages installed at the same time

If you want to list all the packages that were installed with the same transaction ID as a particular package, for example, you can use a script like rpmtran, in Listing 15-4.
Listing 15-4: rpmtran
tid=`rpm -q --qf "%{INSTALLTID}\n" $*`
rpm -q --tid $tid
This script uses the query format to get the transaction ID, or tid, for a particular package. It then passes this transaction ID to the rpm command to query for all packages installed with the same transaction ID.
For example:
$ ./rpmtran tcl