Posts Tagged ‘rpm’

Useful Yum Commands: Installing by Path

25 May 2012

Every once in a while I find myself trying to install something, but not knowing what package contains it.

# yum install g++
Setting up Install Process
No package g++ available.
Error: Nothing to do

But if you’re using a modern version of yum (i.e. that of RHEL 6 or Fedora) then you can simply tell it to install the program you’re looking for.

# yum install /usr/bin/g++
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package gcc-c++.x86_64 0:4.4.6-3.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

Comparing Versions in RPM Conditionals

10 Apr 2012

It’s easy to check a distribution’s version in a spec file since it is usually an integer:

%if 0%{?fedora} > 16

But this scheme doesn’t usually work for comparing program versions because they typically contain periods, which blow rpmbuild’s little mind. But if you have rpm 4.7 or later, you can use a bit of inline Lua to do it:

%if %{lua:rpm.vercmp('%{version}', '2.0.2')} > 0