Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is it possible to set dependecy version requirements like this:

Required: somepackage >= 0.5.0 AND somepackage < 0.6.0

So only somepackage 0.5.x will be automaticly installed.

share|improve this question

2 Answers 2

It's not clear for me if you are trying to build a package or install a package and "limit" its dependencies.

I don't see a way to make the second one case without rebuild the package.

You can retrieve the SRPM and edit spec file and to add/modify entry Requires (you want somepackage 0.5.x , don't you ?) to something like this:

Requires: somepackage = 0.5.0

and then rebuild with

rpmbuild -bb -v yourpackage.spec

If you never did it, it appear intimidating but it solves your problem. Bear in mind that if are creating a public package for a distro, you may want to read its guideliness because set dependency this ways is generally not recommended.

share|improve this answer
1  
I can't really speak for the OP, but sometimes you want the most recent update in a specific version series, not just a specific version. For instance, you may know you want Apache 2.2.x because 2.4.x won't work properly with your package. Specifically requiring 2.2.23 would not allow future updates in 2.2.x be installed. –  Alan Krueger Jan 29 '13 at 17:03

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://www.rpm.org/max-rpm/s1-rpm-depend-manual-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.)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.