2

Is it possible to specify in a rpm spec file that to be able to build you need a version of a package greater than and at the same time lower than something?

For example I would like to specify python >= 2.7 and < 3.0.

Can it be done with buildrequires and if it is possible what would be the syntax?

As I have not seen any example like that I was thinking of:

BuildRequires: python >= 2.7
BuildRequires: python < 3.0
paulsm25
  • 61
  • 5
  • Python > 3.0 is a completely different package called `"python3"`, not `"python"`. – jordanm Sep 19 '15 at 14:27
  • Ok thanks. So in that case of python `BuildRequires: python >= 2.7` would be enough. But what if you wanted python `>= 2.6` and `< 2.7`. I'm interested on knowing if there is a syntax. Or if the one I show in the question would be correct. – paulsm25 Sep 19 '15 at 14:36

1 Answers1

3

You have put correct example in your question, this:

BuildRequires: python >= 2.7
BuildRequires: python < 3.0

is the correct way to do it.

Though, you have to be careful if you use the same schema for classic Requires section. If you put:

Requires: python >= 2.7
Requires: python < 3.0

in your spec file, and package python-3.0 enters one of your yum repos, yum will offer it as an update, which will cause dependency problems in your 'yum update' run. Run would abort with an error, and only way to avoid it would be either to put:

exclude=python-3*

to your repo section, or to run it with:

yum update --exclude=python

If you only use this approach for BuildRequires, you won't have problems unless package python-3.0 is installed before you run yum-builddep. In that case you'll need to remove it first.

Jakov Sosic
  • 5,157
  • 3
  • 22
  • 33
  • But it is only a requirement to build the rpm. It is not a requirement on a system that installs the builded rpm. Unless I don't understand BuildRequires correctly. So it should not interfere with yum update. – paulsm25 Sep 19 '15 at 18:35
  • That's correct, I'll edit my answer. – Jakov Sosic Sep 19 '15 at 18:44