Some RPMs (e.g. jpackage.org’s tomcat7-7.0.39-1.jpp6.noarch.rpm
) express their dependency upon Java by requiring a RPM that provides capability java
(as opposed to, for example, depending on the existence of a file /usr/bin/java
). On CentOS, this capability is normally provided by the java-*-openjdk RPM
. Therefore, if you execute # yum install tomcat7
on a clean install of CentOS, yum will install OpenJDK in addition to Tomcat 7.
Some people prefer to run the Oracle JRE/JDK instead of OpenJDK. Oracle provides RPMs named jre-<em>version</em>-linux-x64.rpm
and jdk-<em>version</em>-linux-x64.rpm
to make installing them easier. Unfortunately, these RPMs do not provide the capability java
. This means that if you already have the Oracle JRE installed, and you install a RPM which requires the capability java
, the OpenJDK will be unnecessarily installed (and might even become the default!).
I solved this dilemma by creating a ‘virtual’ RPM package which provides the capability java
by depending on the Oracle JRE. I named this package virtual-java
.
Creating this package is quite easy. First I created a Makefile
to make building the RPM easier and deal with rpmbuild’s nonsense regarding _topdir
:
|
|
Note how the Makefile
defines VERSION
and RELEASE
, and provides them to the .spec file. This is done because the Makefile
needs to know the name of the generated RPM file, which depends on VERSION
and RELEASE
.
Here is virtual-java.spec
:
|
|