I need to get the version number of an rpm file like "foo-[RELEASE].rpm
"
I tried these commands
rpm -q --queryformat '%{VERSION}' foo-[RELEASE].rpm
package foo-[RELEASE].rpm is not installed
rpm -qp --queryformat "[%{VERSION}\n]" foo-[RELEASE].rpm
I need to replace the [RELEASE] placeholder with the version number.
Taking an example of sbt.rpm
, here is how you may want to extract the information. Note that the package filename itself doesn't show the version and release information.
Get full package name:
$ rpm -qp sbt.rpm
sbt-0.12.2-1.noarch
Get NAME, VERSION, RELEASE and ARCHITECTURE separately:
$ rpm -qp --queryformat '%{NAME}' sbt.rpm
sbt
$ rpm -qp --queryformat '%{VERSION}' sbt.rpm
0.12.2
$ rpm -qp --queryformat '%{RELEASE}' sbt.rpm
1
$ rpm -qp --queryformat '%{ARCH}' sbt.rpm
noarch
Get NAME, VERSION, RELEASE and ARCHITECTURE combined:
$ rpm -qp --queryformat '%{NAME}-%{VERSION}-%{RELEASE}-%{ARCH}' sbt.rpm
sbt-0.12.2-1-noarch
Get only NAME, VERSION:
$ rpm -qp --queryformat '%{NAME}-%{VERSION}' sbt.rpm
sbt-0.12.2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With