문제

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

다른 팁

 rpm -qip foo.rpm

shows version number :

Version     : 1.3.4
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top