aports/community/java-common/java-common.trigger
Willow Barraco e1cd3a1d10 community/java-common: fix missing symlink when the jvm is empty
In case a jvm is uninstalled, its folder keep some empty folders. This
can trick the trigger script to link it as "default-jvm", and produce
no /usr/bin/java symlink at the end.

Checking that the bin/java file is there seems enough to be sure the jvm
folder is sane enough.
2025-08-25 19:14:19 +02:00

29 lines
705 B
Bash

#!/bin/sh
# create symlink for the active jvm
cd /usr/lib/jvm
# the link "forced-jvm" is created by an user to explicitly use a specific jvm
if [ -x forced-jvm ]; then
ln -sfn forced-jvm default-jvm
else
# if no "forced-jvm" is present, then the latest installed version is taken
LATEST=`ls -d java-*/bin/java | sort -Vr | head -1 | cut -d/ -f1`
if [ "$LATEST" ]; then
ln -sfn $LATEST default-jvm
fi
fi
# clean up dangling symlinks
for link in $(find -L /usr/bin -type l -print); do
case "$(readlink $link)" in ../lib/jvm/*)
rm "$link"
;;
esac
done
# create program links for the currently active jre
cd /usr/bin
find ../lib/jvm/default-jvm/bin -mindepth 1 -type f -exec ln -sfn {} . \;