Using the rpm “queryformat” option to display package architecture

Here's one from the "learned something new today" files. When installing Oracle products on 64-bit versions of Linux, it's a common requirement to have both 32- and 64-bit versions of certain packages installed (that's not the "learned something new" part). The default output for the rpm query command, rpm -q, doesn't show the architecture of the queried package (that's not new, either). For example, installing Oracle RDBMS 11gR1 on RHEL4 or OEL4 requires both 32- and 64-bit versions of the libaio and glibc-devel (not the full list of package requirements; I'm just trying to keep the example short). A typical rpm query would show the following output:

[jpiwowar@testsrv ~]$ rpm -q libaio glibc-devel
libaio-0.3.105-2
glibc-devel-2.3.4-2.39
glibc-devel-2.3.4-2.39

It's probably safe to assume that those two glibc-devel entries cover the 32- and 64-bit versions, but where's the second libaio? The easy answer is to append the architecture string to the name of the package, but that results in a pretty quiet failure for the package that's not installed:

[jpiwowar@testsrv ~]$ rpm -q libaio.x86_64
libaio-0.3.105-2
[jpiwowar@testsrv ~]$ echo $?
0
[jpiwowar@testsrv ~]$ rpm -q libaio.i386
[jpiwowar@testsrv ~]$ echo $?
0

My new favorite trick (finally, the "learned something new" part!) is to use the --queryformat (or --qf) option to display the architecture of an installed package:

[jpiwowar@testsrv ~]$ rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE} %{ARCH}\n' libaio glibc-devel
libaio-0.3.105-2 x86_64
glibc-devel-2.3.4-2.39 i386
glibc-devel-2.3.4-2.39 x86_64

It's not perfect, but it makes it a bit easier to spot which version of a package (32-bit libaio, in this case) is missing in a long list of required packages. I'm a bit embarrassed to admit that I didn't know about this option until recently, but if it's new to me, maybe it's new to you too. :-)

References

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*