fommil
fommil

Reputation: 5875

how to define OR logic for an RPM dependency

I'm creating an RPM and I need to check that a version of Java 8 is installed on the machine.

The problem is that Oracle provides version-tied RPMs with names like jdk1.8.0_45 and Redhat provides RPMs with names like java-oracle-8. I don't really care which one is installed, as long as one of them is installed, so how can I define OR condition logic on a Java 8? (Note this is for a RHEL5 or RHEL6 target, so new fangled features can't be used)

Upvotes: 2

Views: 343

Answers (2)

msuchy
msuchy

Reputation: 5427

FYI - boolean logic in dependecy is called "Rich dependency" and is currently being introduce into RPM and will probably land in Fedora 24. See http://lists.rpm.org/pipermail/rpm-maint/2014-February/003666.html

Upvotes: 2

Etan Reisner
Etan Reisner

Reputation: 80931

As far as I'm aware RPM has no such functionality. You cannot declare a requirement like this.

That being said what RPM does have, and which is used as a rough equivalent to this, is the concept of "Provides".

Any package can Provide: some_capability and then other packages can Require: some_capability the same way they can Require: <some_package>.

You can also Require: /some/file/path if absolutely necessary (though avoid this whenever possible).

So, you need to compare the provided capabilities of the RPMs you care about and look for any common capability that you can depend on instead. Hopefully there's something in common there you can use. If there isn't then you are left with no choice other than to drop the requirement in your RPM and hope they have it and detect it at runtime (with a startup script perhaps).

(Technically you could also do a check during %pre and exit with a failure if you can't find java somewhere but I strongly recommend not doing that.)

Upvotes: 3

Related Questions