Bug 2008206

Summary: reinstalling openjdk packages removes alternatives links [rhel-9, openjdk-17]
Product: Red Hat Enterprise Linux 9 Reporter: Andrew John Hughes <ahughes>
Component: java-17-openjdkAssignee: jiri vanek <jvanek>
Status: CLOSED ERRATA QA Contact: OpenJDK QA <java-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 9.0CC: jandrlik
Target Milestone: rcKeywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: java-17-openjdk-17.0.2.0.8-10.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-05-17 14:06:28 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 15:14:13 UTC
This bug was initially created as a copy of Bug #1976053

I am copying this bug because: 

Sync with RHEL 8 RPMs

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 14 errata-xmlrpc 2022-05-17 14:06:28 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 (new packages: java-17-openjdk), 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:2647