File git-47-056fc66c699a8544c7692a03c905fca568f5390b.patch of Package aaa_base.33622
From 056fc66c699a8544c7692a03c905fca568f5390b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=BCdiger=20Oertel?= <ro@suse.de>
Date: Mon, 6 Nov 2023 12:01:16 +0100
Subject: [PATCH] patch alljava.sh and alljava.csh, use the links from update
alternatives
fix the issues from bsc#1107342 and bsc#1215434
diff --git a/files/etc/profile.d/alljava.csh b/files/etc/profile.d/alljava.csh
index 297303c..8c7601a 100644
--- a/files/etc/profile.d/alljava.csh
+++ b/files/etc/profile.d/alljava.csh
@@ -9,39 +9,18 @@
# JDK_HOME, SDK_HOME
#
-foreach JDIR ( "/usr/lib64/jvm" "/usr/lib/jvm" "/usr/java/latest" "/usr/java" )
+if ( -l /etc/alternatives/java && -e /etc/alternatives/java ) then
+ set ALTERNATIVES_JAVA_LINK=`realpath /etc/alternatives/java`
+ setenv JRE_HOME $ALTERNATIVES_JAVA_LINK:h:h
+ unset ALTERNATIVES_JAVA_LINK
+endif
+
+if ( -l /etc/alternatives/javac && -e /etc/alternatives/javac ) then
+ set ALTERNATIVES_JAVAC_LINK=`realpath /etc/alternatives/javac`
+ setenv JAVA_HOME $ALTERNATIVES_JAVAC_LINK:h:h
+ setenv JAVA_BINDIR $JAVA_HOME/bin
+ setenv JDK_HOME $JAVA_HOME
+ setenv SDK_HOME $JAVA_HOME
+ unset ALTERNATIVES_JAVAC_LINK
+endif
- if ( ! -d $JDIR ) continue
-
- foreach JPATH ( $JDIR $JDIR/java $JDIR/java-[a-z]* $JDIR/java-[0-9]* $JDIR/jre $JDIR/jre-[a-z]* $JDIR/jre-[0-9]* )
-
- if ( ! -d $JPATH ) continue
-
- if ( ! -x $JPATH/bin/java ) continue
-
- setenv JAVA_BINDIR $JPATH/bin
- setenv JAVA_ROOT $JPATH
- setenv JAVA_HOME $JPATH
- unset JDK_HOME
- unset SDK_HOME
-
- switch ( $JPATH )
- case *jre*:
- setenv JRE_HOME $JPATH
- breaksw
- default:
- if ( -x $JPATH/jre/bin/java ) then
- setenv JRE_HOME $JPATH/jre
- else
- setenv JRE_HOME $JPATH
- endif
- # it is development kit=20
- if ( -x $JPATH/bin/javac ) then
- setenv JDK_HOME $JPATH
- setenv SDK_HOME $JPATH
- endif
- endsw
- end
- unset JPATH
-end
-unset JDIR
diff --git a/files/etc/profile.d/alljava.sh b/files/etc/profile.d/alljava.sh
index 3ce34de..78fabee 100644
--- a/files/etc/profile.d/alljava.sh
+++ b/files/etc/profile.d/alljava.sh
@@ -9,51 +9,18 @@
# JDK_HOME, SDK_HOME
#
-for JDIR in /usr/lib64/jvm /usr/lib/jvm /usr/java/latest /usr/java; do
+if test -L /etc/alternatives/java -a -e /etc/alternatives/java; then
+ ALTERNATIVES_JAVA_LINK=`realpath /etc/alternatives/java 2> /dev/null`
+ export JRE_HOME=${ALTERNATIVES_JAVA_LINK%/bin/java}
+ unset ALTERNATIVES_JAVA_LINK
+fi
+
+if test -L /etc/alternatives/javac -a -e /etc/alternatives/javac; then
+ ALTERNATIVES_JAVAC_LINK=`realpath /etc/alternatives/javac 2> /dev/null`
+ export JAVA_HOME=${ALTERNATIVES_JAVAC_LINK%/bin/javac}
+ export JAVA_BINDIR=$JAVA_HOME/bin
+ export JDK_HOME=$JAVA_HOME
+ export SDK_HOME=$JAVA_HOME
+ unset ALTERNATIVES_JAVAC_LINK
+fi
- if ! test -d $JDIR; then
- continue
- fi
-
- for JPATH in $JDIR $JDIR/java $JDIR/java-[a-z]* $JDIR/java-[0-9]* $JDIR/jre $JDIR/jre-[a-z]* $JDIR/jre-[0-9]*; do
-
- if ! test -d $JPATH; then
- continue
- fi
-
- if ! test -x $JPATH/bin/java; then
- continue
- fi
-
- export JAVA_BINDIR=$JPATH/bin
- export JAVA_ROOT=$JPATH
- export JAVA_HOME=$JPATH
- unset JDK_HOME
- unset SDK_HOME
-
- case "$JPATH" in
- *jre*)
- [ -z "$JRE_HOME" ] && export JRE_HOME=$JPATH
- ;;
-
- *)
- if [ -x $JPATH/jre/bin/java ] ; then
- [ -z "$JRE_HOME" ] && export JRE_HOME=$JPATH/jre
- else
- [ -z "$JRE_HOME" ] && export JRE_HOME=$JPATH
- fi
- # it is development kit
- if [ -x $JPATH/bin/javac ] ; then
- export JDK_HOME=$JPATH
- export SDK_HOME=$JPATH
- unset JPATH
- break 2; # we found a JRE + SDK -- don't look any further
- fi
- ;;
- esac
-
- done
- unset JPATH
-
-done
-unset JDIR