diff --git a/java-21-openjdk.spec b/java-21-openjdk.spec index 0dbd6bb..4e70b5d 100644 --- a/java-21-openjdk.spec +++ b/java-21-openjdk.spec @@ -2167,6 +2167,25 @@ done %post %{post_script %{nil}} +# Allow upgrades from packages that have /usr/lib/jvm/java-21-openjdk +# as an alternatives symlink, without running into the known RPM +# limitation when changing to a directory a symlink to a directory. +# See also javadoc and javadoc-zip subpackages for +# /usr/share/javadoc/java-21-openjdk, which was a symlink before. +# /etc/java/java-21-openjdk is OK because it was always a directory. +# Reference: +# https://docs.fedoraproject.org/en-US/packaging-guidelines/Directory_Replacement/ +%define lua_delete_old_link() %{expand: +path = "%{1}" +st = posix.stat(path) +if st and st.type == "link" then + os.remove(path) +end +} + +%pretrans headless -p +%{lua_delete_old_link -- %{_jvmdir}/%{sdkdir -- %{?1}}} + %post headless %{post_headless %{nil}} @@ -2191,12 +2210,20 @@ done %posttrans devel %{posttrans_devel %{nil}} +%pretrans javadoc -p +%{lua_delete_old_link -- %{_jvmdir}/%{sdkdir -- %{?1}}} +%{lua_delete_old_link -- %{_javadocdir}/%{uniquejavadocdir -- %{?1}}} + %post javadoc %{alternatives_javadoc_install %{nil}} %preun javadoc %{preun_javadoc %{nil}} +%pretrans javadoc-zip -p +%{lua_delete_old_link -- %{_jvmdir}/%{sdkdir -- %{?1}}} +%{lua_delete_old_link -- %{_javadocdir}/%{uniquejavadocdir -- %{?1}}} + %post javadoc-zip %{alternatives_javadoczip_install %{nil}} @@ -2380,6 +2407,7 @@ done - Take ownership of versioned jvmdir in javadoc, javadoc-zip subpackages - Make headless own /usr/share/doc/java-21-openjdk - Make javadoc-zip own /usr/share/javadoc/java-21-openjdk +- Delete old conflicting links in pretrans for headless, javadoc and javadoc-zip - Resolves: RHEL-71920 - Resolves: RHEL-71954 - Resolves: RHEL-69321