Rpm spec file buildrequires with more than one criteria

rpmspecfile

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

Best Answer

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.

Related Topic