As an answer to your original question - Yes this is possible, but what you can implement depends what you want to use as a condition, and those are written to the package during build-time of the package, not during installation. You could easily do something in the .spec like
%if some_condition_is_true
Requires: foo
%else
Requires: bar
%endif
Question is, how much sense does that make, and what is your particular use case?
For what you described, that is not possible in that way, as you cannot change the package during install-time. You have a few options for your scenario:
- create two versions of your package, one for bonding, one for hosts without
- separate the part that is necessary for bonding hosts in a
subpackage, and only install that on the hosts that need it
- put the logic for the bonding hosts in a
%pre/%post
script, so that it only runs conditionally.
- use some virtual requires, which are fulfilled by multiple packages, and then add some config on the host which gives priority to the package you need, the one for bonding or for no bonding. But that is highly distro-specific ...
For more details on conditional/dynamic macros which are mostly available since rpm.org v4.12 see https://web.archive.org/web/20160513021804/http://rpm.org/wiki/DynamicDependencies
For more details on the %pre/%post
and other scriptlets see e.g. https://fedoraproject.org/wiki/Packaging:ScriptletSnippets