Bug 2008192

Summary: reinstalling openjdk packages removes alternatives links [rhel-8, openjdk-11]
Product: Red Hat Enterprise Linux 8 Reporter: Andrew John Hughes <ahughes>
Component: java-11-openjdkAssignee: jiri vanek <jvanek>
Status: CLOSED ERRATA QA Contact: OpenJDK QA <java-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 8.4CC: jandrlik
Target Milestone: betaKeywords: Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: java-11-openjdk-11.0.14.1.1-4.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-05-10 13:40:18 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Andrew John Hughes 2021-09-27 14:48:08 UTC
This bug was initially created as a copy of Bug #1976053

I am copying this bug because: 

Sync with change to OpenJDK 8 RPM.

Description of problem:

If you reinstall one of the following packages it causes the alternatives links to be removed from the system:
java-1.8.0-openjdk-headless
java-1.8.0-openjdk-devel
java-11-openjdk-headless
java-11-openjdk-devel

How reproducible:

Always

Steps to Reproduce:
1. dnf install java-1.8.0-openjdk-headless
2. ls -lh /usr/bin/java
3. dnf reinstall java-1.8.0-openjdk-headless
4. ls -lh /usr/bin/java

Actual results:

[root@rhel8 ~]# dnf install java-1.8.0-openjdk-headless
...
Installed:
  copy-jdk-configs-3.7-4.el8.noarch     java-1.8.0-openjdk-headless-1:1.8.0.292.b10-1.el8_4.x86_64     javapackages-filesystem-5.3.0-1.module+el8+2447+6f56d9a6.noarch     libjpeg-turbo-1.5.3-10.el8.x86_64    
  lksctp-tools-1.0.18-3.el8.x86_64      lua-5.3.4-11.el8.x86_64                                        tzdata-java-2021a-1.el8.noarch                                     

Complete!
[root@rhel8 ~]# ls -lh /usr/bin/java
lrwxrwxrwx. 1 root root 22 Jun 25 15:41 /usr/bin/java -> /etc/alternatives/java
[root@rhel8 ~]# dnf reinstall java-1.8.0-openjdk-headless
...
Reinstalled:
  java-1.8.0-openjdk-headless-1:1.8.0.292.b10-1.el8_4.x86_64                                                                                                                                                       

Complete!
[root@rhel8 ~]# ls -lh /usr/bin/java
ls: cannot access '/usr/bin/java': No such file or directory

Expected results:

The link should still be there after the reinstall.

Additional info:

This bug seems to affect all the openjdk packages that install alternatives links.  I have verified it with the packages listed above.

The alternatives --removes commands in the postinstall scriptlets should be wrapped in `if [ "$1" = 0 ]; then ... fi` which will result in the removal only happening on an actual uninstall, and not an update or reinstall.

Comment 8 errata-xmlrpc 2022-05-10 13:40:18 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (java-11-openjdk bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:1799