This repository has been archived on 2024-11-03. You can view files and clone it, but cannot push or open issues or pull requests.
evolution-packages/srcpkgs/xbps-triggers/files/openjdk-profile

40 lines
626 B
Plaintext
Raw Normal View History

2023-08-05 21:19:04 +01:00
#!/bin/sh
#
# Adds an entry to /etc/profile.d for setting $JAVA_HOME.
#
# Arguments: $ACTION = [run/targets]
# $TARGET = [post-install/pre-remove]
# $PKGNAME
# $VERSION
# $UPDATE = [yes/no]
#
ACTION="$1"
TARGET="$2"
PKGNAME="$3"
VERSION="$4"
UPDATE="$5"
jdkprofile=etc/profile.d/openjdk.sh
case "$ACTION" in
targets)
echo "post-install"
;;
run)
[ -f "$jdkprofile" ] && exit 0
cat > "$jdkprofile" <<'EOF'
if _java_bin=$(readlink -e /usr/bin/java); then
_java_bin="${_java_bin%/bin/java}"
[ -d "${_java_bin}" ] && export JAVA_HOME="${JAVA_HOME:=${_java_bin}}"
fi
unset _java_bin
EOF
;;
*)
exit 1
;;
esac
exit 0