RPM: Set Required: somepackage >= 0.5.0 AND somepackage < 0.6.0

Yes, very easy to do so.

Just write:

Requires: somepackage >= 0.5.0, somepackage < 0.6.0

into your .spec file.

Adding Version Requirements

When a package has slightly more stringent needs, it’s possible to
require certain versions of a package. All that’s necessary is to add
the desired version number, preceded by one of the following
comparison operators:

  • Requires package with a version less than the specified version.

  • Requires package with a version less than or equal to the specified
    version.

  • Requires package with a version equal to the specified version.

  • Requires package with a version equal to or greater than the specified
    version.

  • Requires package with a version greater than the specified version.

Continuing with our example, let’s suppose that the required version
of package bar actually needs to be at least 2.7, and that the baz
package must be version 2.1 — no other version will do. Here’s what
the requires tag line would look like: requires: bar >= 2.7, baz = 2.1

Source: http://rpm.org/user_doc/more_dependencies.html

Beware of Virtual Capabilities / Provides

The system described above works for most packages; however, if the package you are wanting to require is provided as a [virtual capability][1] or is otherwise provided (i.e. “Provides: ” keyword) by packages of different names (that do not conflict with each other), then you may end up with two different packages installed, each of which individually satisfy one of your requirements. For example, if your spec file contains:

Requires: postgresql-server >= 8.4, postgresql-server < 9.0

May result in (if you have these packages available to yum) the installation of:

  • postgresql-server 8.1.23-6.el5_8 (postgresql-server < 9.0)
  • postgresql92-server 9.2.5-1PGDG.rhel5 (postgresql-server >= 8.4)

But will not install postgresql84-server, which is probably the package you would have expected to have installed.

(In this case the solution would simply be to require postgresql84-server; however, there are likely other examples that don’t have an easy solution.)

Leave a Comment