Semi-OT: Neat Trick regarding RPM query format

From: Taylor, Chris David <ChrisDavid.Taylor_at_ingrambarge.com>
Date: Mon, 2 Jul 2012 11:03:20 -0500
Message-ID: <C5533BD628A9524496D63801704AE56D75B2BA0845_at_SPOBMEXC14.adprod.directory>



(Just sending this out there in case anyone is interested. If you have a better way, pass it on...)

rpm can provide you with the name and architecture when querying the installed rpms.

Typically rpm -q filename will only tell you it is installed, but not which architecture(s).

[root_at_rac2 /etc]$ rpm -qa glibc

glibc-2.5-81
glibc-2.5-81

To get the ARCH you can use --queryformat '%{NAME}-%{VERSION}-%{RELEASE}-%{ARCH}\n'

[root_at_rac2 /etc]$ rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE} %{ARCH}\n' glibc
glibc-2.5-81 x86_64
glibc-2.5-81 i686

To make this simpler, you can create (or add) an alias to /etc/popt, or ~/.popt:

rpm     exec -q                 rpmq -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE} %{ARCH}\n'

Take a look at /usr/lib/rpm/rpmopt-{version} to see a horde of aliases that rpm uses to get an idea what's available.

Chris Taylor

"Quality is never an accident; it is always the result of intelligent effort." -- John Ruskin (English Writer 1819-1900)

Any views and/or opinions expressed herein are my own and do not necessarily reflect the views of Ingram Industries, its affiliates, its subsidiaries or its employees.

--
http://www.freelists.org/webpage/oracle-l
Received on Mon Jul 02 2012 - 11:03:20 CDT

Original text of this message