I'm trying to package an RPM that requires any Java version above Java 8. The RPM works fine if there's no Java installed, or if JRE/JDK for 8 is installed. HOWEVER if I install OpenJDK 11, when I install my RPM it will try to install Java 8 again.
How do I get my RPM to detect that there's already a Java 11 installation which should be compatible with my package? I don't want my package to install Java 8 if I have Java 11 already!
I'm running Red Hat 7.5, but this also reproduces in CentOS7. I was able to reproduce this with a simple hello world package:
Name: hello-world
Version: 1
Release: 1
Summary: Most simple RPM package
License: FIXME
Requires: jre-headless >= 1.8
%description
%prep
%build
cat > hello-world.sh <<EOF
#!/usr/bin/bash
echo Hello world
EOF
%install
mkdir -p %{buildroot}/usr/bin/
install -m 755 hello-world.sh %{buildroot}/usr/bin/hello-world.sh
%files
/usr/bin/hello-world.sh
%changelog
Build with:
rpmdev-setuptree
rpmbuild -ba hello-world.spec
Then install OpenJDK11: sudo yum -y install java-11-openjdk
Finally test my package: rpm -i --test <FILE>.rpm gives:
error: Failed dependencies:
jre-headless >= 1.8 is needed by hello-world-1-1.x86_64
sudo yum localinstall <FILE>.rpm also tries to install Java8.
sudo yum deplist <FILE>.rpm suggests that java-11-openjdk should provide what I need:
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.heanet.ie
* extras: ftp.heanet.ie
* updates: ftp.heanet.ie
package: hello-world.x86_64 1-1
dependency: /usr/bin/bash
provider: bash.x86_64 4.2.46-31.el7
dependency: jre-headless >= 1.8
provider: java-11-openjdk-headless.x86_64 1:11.0.ea.28-7.el7
provider: java-11-openjdk-headless.i686 1:11.0.ea.28-7.el7
provider: java-1.8.0-openjdk-headless.x86_64 1:1.8.0.201.b09-2.el7_6
provider: java-1.8.0-openjdk-headless.i686 1:1.8.0.191.b12-1.el7_6
provider: java-1.7.0-openjdk-headless.x86_64 1:1.7.0.211-2.6.17.1.el7_6
(Not sure why Java 7 is a provider of Java 8 either).
I tried setting requires to jre or java but no luck. Also I tried pre-installing java-11-openjdk-headless specifically, but it made no difference.
It seems like boolean dependencies might fix this, but sadly I can't guarantee my end-users have a recent enough version of rpm installed.
I'm not sure what I could be doing wrong?
How do I set a RPM package to require Java 8 or higher, whose dependencies are satisfied by Java 11?