#124 alternatives are now created in posttran instead of in postinst
Closed 2 years ago by jvanek. Opened 2 years ago by jvanek.
Unknown source reinstallAlternatives  into  rawhide

file modified
+27 -17
@@ -77,7 +77,7 @@

  # in alternatives those are slaves and master, very often triplicated by man pages

  # in files all masters and slaves are ghosted

  # the ghosts are here to allow installation via query like `dnf install /usr/bin/java`

- # you can list those files, with appropriate sections: cat *.spec | grep -e --install -e --slave -e post_ 

+ # you can list those files, with appropriate sections: cat *.spec | grep -e --install -e --slave -e post_ -e alternatives

  # TODO - fix those hardcoded lists via single list

  # Those files must *NOT* be ghosted for *slowdebug* packages

  # FIXME - if you are moving jshell or jlink or similar, always modify all three sections
@@ -466,12 +466,7 @@

  exit 0

  }

  

- 

- %define post_headless() %{expand:

- %ifarch %{share_arches}

- %{jrebindir -- %{?1}}/java -Xshare:dump >/dev/null 2>/dev/null

- %endif

- 

+ %define alternatives_java_install() %{expand:

  PRIORITY=%{priority}

  if [ "%{?1}" == %{debug_suffix} ]; then

    let PRIORITY=PRIORITY-1
@@ -509,8 +504,13 @@

    alternatives --install %{_jvmdir}/jre-"$X" jre_"$X" %{_jvmdir}/%{sdkdir -- %{?1}} $PRIORITY --family %{name}.%{_arch}

  done

  

- update-alternatives --install %{_jvmdir}/jre-%{javaver}-%{origin} jre_%{javaver}_%{origin} %{_jvmdir}/%{jrelnk -- %{?1}} $PRIORITY  --family %{name}.%{_arch}

+ alternatives --install %{_jvmdir}/jre-%{javaver}-%{origin} jre_%{javaver}_%{origin} %{_jvmdir}/%{jrelnk -- %{?1}} $PRIORITY  --family %{name}.%{_arch}

+ }

  

+ %define post_headless() %{expand:

+ %ifarch %{share_arches}

+ %{jrebindir -- %{?1}}/java -Xshare:dump >/dev/null 2>/dev/null

+ %endif

  

  update-desktop-database %{_datadir}/applications &> /dev/null || :

  /bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :
@@ -547,8 +547,8 @@

  %{update_desktop_icons}

  }

  

- %define post_devel() %{expand:

  

+ %define alternatives_javac_install() %{expand:

  PRIORITY=%{priority}

  if [ "%{?1}" == %{debug_suffix} ]; then

    let PRIORITY=PRIORITY-1
@@ -630,7 +630,9 @@

  done

  

  update-alternatives --install %{_jvmdir}/java-%{javaver}-%{origin} java_sdk_%{javaver}_%{origin} %{_jvmdir}/%{sdkdir -- %{?1}} $PRIORITY  --family %{name}.%{_arch}

+ }

  

+ %define post_devel() %{expand:

  update-desktop-database %{_datadir}/applications &> /dev/null || :

  /bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :

  
@@ -653,11 +655,11 @@

  }

  

  %define posttrans_devel() %{expand:

+ %{alternatives_javac_install --  %{?1}}

  %{update_desktop_icons}

  }

  

- %define post_javadoc() %{expand:

- 

+ %define alternatives_javadoc_install() %{expand:

  PRIORITY=%{priority}

  if [ "%{?1}" == %{debug_suffix} ]; then

    let PRIORITY=PRIORITY-1
@@ -674,8 +676,7 @@

  exit 0

  }

  

- %define post_javadoc_zip() %{expand:

- 

+ %define alternatives_javadoczip_install() %{expand:

  PRIORITY=%{priority}

  if [ "%{?1}" == %{debug_suffix} ]; then

    let PRIORITY=PRIORITY-1
@@ -2150,6 +2151,9 @@

  %posttrans

  %{posttrans_script %{nil}}

  

+ %posttrans headless

+ %{alternatives_java_install %{nil}}

+ 

  %post devel

  %{post_devel %{nil}}

  
@@ -2159,14 +2163,14 @@

  %posttrans  devel

  %{posttrans_devel %{nil}}

  

- %post javadoc

- %{post_javadoc %{nil}}

+ %posttrans javadoc

+ %{alternatives_javadoc_install %{nil}}

  

  %postun javadoc

  %{postun_javadoc %{nil}}

  

- %post javadoc-zip

- %{post_javadoc_zip %{nil}}

+ %posttrans javadoc-zip

+ %{alternatives_javadoczip_install %{nil}}

  

  %postun javadoc-zip

  %{postun_javadoc_zip %{nil}}
@@ -2179,6 +2183,9 @@

  %post headless-slowdebug

  %{post_headless -- %{debug_suffix_unquoted}}

  

+ %posttrans headless-slowdebug

+ %{alternatives_java_install -- %{debug_suffix_unquoted}}

+ 

  %postun slowdebug

  %{postun_script -- %{debug_suffix_unquoted}}

  
@@ -2214,6 +2221,9 @@

  %posttrans fastdebug

  %{posttrans_script -- %{fastdebug_suffix_unquoted}}

  

+ %posttrans headless-fastdebug

+ %{alternatives_java_install -- %{fastdebug_suffix_unquoted}}

+ 

  %post devel-fastdebug

  %{post_devel -- %{fastdebug_suffix_unquoted}}

  

This is initial implementation of idea from https://bugzilla.redhat.com/show_bug.cgi?id=1200302 to install alternatives in posttrans instead of post.
install:
- no removal runs, alternatives are installed posttrans
upgrade/downgrade
- alternatives are removed in postun of old package, posstrans of old pkg do not run according to https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/
- alternatives of new package are installe din posttrans
- reinstall
alternatives are remove in postun, but restored in posttrans

The patch is not easily readable. There were three cases
- posun was there only for alternatives (javadocs)
- posttrans was already declared and postun had more meanings (devel)
- posttrans was not there - headless

I had extracted all four alternatives sections - java/javac/javadoc/javadoczip
- had removed postun of javadocs and added posstrans for them calling javadocs' alternatives macros (no fast/slow debugs it seems)
- in the posttrans of devel, is now call to setup of javac alternatives (and slow/fast debugs)
- created posttrans for headless and it is calling the java's alternatives creation

Code review heavily welcommed.

I had intentionally not created any check on existence of alternatives before attempt to set it up as it seems that there is noreason for it.
If there will be reason, then something like if ! alternatives | grep %{unique_dir} ; then alternatives --isntall should do

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci

Only thing that confuses me is why the post_headless is being moved. That seems to have no bearing on the rest.

Obviously needs a ChangeLog and release bump.

It is an illusion! You may see I created new section

 + %define alternatives_java_install() %{expand: a

with part of the content of post_headless, and this is how diff shows that.

Pull-Request has been closed by jvanek

2 years ago
Metadata