2013-08-27 15:14:44 +04:00
|
|
|
##@cooked comments # -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
|
|
|
## Gestion de la sélection d'une version de Java
|
|
|
|
##@cooked nocomments
|
|
|
|
##@require base
|
|
|
|
##@require sysinfos
|
|
|
|
uprovide java
|
|
|
|
urequire base sysinfos
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# versions installées sur le système
|
2020-10-06 03:46:31 +04:00
|
|
|
JAVA_VMS1_3=(); JAVA_HOMES1_3=()
|
|
|
|
JAVA_VMS1_4=(); JAVA_HOMES1_4=()
|
2013-08-27 15:14:44 +04:00
|
|
|
JAVA_VMS5=(); JAVA_HOMES5=()
|
|
|
|
JAVA_VMS6=(); JAVA_HOMES6=()
|
|
|
|
JAVA_VMS7=(); JAVA_HOMES7=()
|
2014-11-11 16:25:53 +04:00
|
|
|
JAVA_VMS8=(); JAVA_HOMES8=()
|
2020-10-06 03:46:31 +04:00
|
|
|
JAVA_VMS11=(); JAVA_HOMES11=()
|
2023-08-22 08:42:34 +04:00
|
|
|
JAVA_VMS17=(); JAVA_HOMES17=()
|
2013-08-27 15:14:44 +04:00
|
|
|
# versions locales 32 bits
|
2020-10-06 03:46:31 +04:00
|
|
|
JAVA32_VMS1_3=(); JAVA32_HOMES1_3=()
|
|
|
|
JAVA32_VMS1_4=(); JAVA32_HOMES1_4=()
|
2013-08-27 15:14:44 +04:00
|
|
|
JAVA32_VMS5=(); JAVA32_HOMES5=()
|
|
|
|
JAVA32_VMS6=(); JAVA32_HOMES6=()
|
|
|
|
JAVA32_VMS7=(); JAVA32_HOMES7=()
|
2014-11-11 16:25:53 +04:00
|
|
|
JAVA32_VMS8=(); JAVA32_HOMES8=()
|
2020-10-06 03:46:31 +04:00
|
|
|
JAVA32_VMS11=(); JAVA32_HOMES11=()
|
2023-08-22 08:42:34 +04:00
|
|
|
JAVA32_VMS17=(); JAVA32_HOMES17=()
|
2013-08-27 15:14:44 +04:00
|
|
|
# versions locales 64 bits
|
|
|
|
JAVA64_VMS5=(); JAVA64_HOMES5=()
|
|
|
|
JAVA64_VMS6=(); JAVA64_HOMES6=()
|
|
|
|
JAVA64_VMS7=(); JAVA64_HOMES7=()
|
2014-11-11 16:25:53 +04:00
|
|
|
JAVA64_VMS8=(); JAVA64_HOMES8=()
|
2020-10-06 03:46:31 +04:00
|
|
|
JAVA64_VMS11=(); JAVA64_HOMES11=()
|
2023-08-22 08:42:34 +04:00
|
|
|
JAVA64_VMS17=(); JAVA64_HOMES17=()
|
2013-08-27 15:14:44 +04:00
|
|
|
# version sélectionnée
|
|
|
|
SELECTED_JAVA_VM=; SELECTED_JAVA_HOME=
|
|
|
|
SELECTED_JAVA=; SELECTED_JAVAC=
|
|
|
|
|
|
|
|
function __java_add() {
|
|
|
|
# Ajouter la valeur $2 à la liste JAVA$3_$1
|
|
|
|
array_add "JAVA${3}_${1}" "$2"
|
|
|
|
}
|
|
|
|
|
|
|
|
function __java_compute_vms() {
|
|
|
|
# calculer la liste de VMs disponibles et initialiser les tableaux
|
2020-10-06 03:46:31 +04:00
|
|
|
# JAVA{,32,64}_{VMS,HOMES}{1_3,1_4,5,6,7,8}
|
2013-08-27 15:14:44 +04:00
|
|
|
[ -z "$__COMPUTED_JAVA_VMS" ] || return
|
|
|
|
|
|
|
|
local vms vm v
|
|
|
|
if check_sysinfos -s linux; then
|
|
|
|
# D'abord chercher dans les JVMs installées manuellement dans
|
|
|
|
# ~/opt/jvm{32,64}
|
|
|
|
array_from_lines vms "$(list_dirs "$HOME/opt/jvm32" "sun-jdk-*")"
|
|
|
|
for vm in "${vms[@]}"; do
|
|
|
|
v="${vm#sun-jdk-}"
|
|
|
|
if [ "$v" == 1.4 ]; then
|
2020-10-06 03:46:31 +04:00
|
|
|
__java_add VMS1_4 "$vm" 32
|
|
|
|
__java_add HOMES1_4 "$HOME/opt/jvm32/$vm" 32
|
2013-08-27 15:14:44 +04:00
|
|
|
elif [ "$v" == 1.5 ]; then
|
|
|
|
__java_add VMS5 "$vm" 32
|
|
|
|
__java_add HOMES5 "$HOME/opt/jvm32/$vm" 32
|
|
|
|
elif [ "$v" == 1.6 ]; then
|
|
|
|
__java_add VMS6 "$vm" 32
|
|
|
|
__java_add HOMES6 "$HOME/opt/jvm32/$vm" 32
|
|
|
|
elif [ "$v" == 1.7 ]; then
|
|
|
|
__java_add VMS7 "$vm" 32
|
|
|
|
__java_add HOMES7 "$HOME/opt/jvm32/$vm" 32
|
2014-11-11 16:25:53 +04:00
|
|
|
elif [ "$v" == 1.8 ]; then
|
|
|
|
__java_add VMS8 "$vm" 32
|
|
|
|
__java_add HOMES8 "$HOME/opt/jvm32/$vm" 32
|
2013-08-27 15:14:44 +04:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
array_from_lines vms "$(list_dirs "$HOME/opt/jvm32" "j2sdk1.4.2*" | LANG=C sort -r)"
|
|
|
|
for vm in "${vms[@]}"; do
|
2020-10-06 03:46:31 +04:00
|
|
|
__java_add VMS1_4 "$vm" 32
|
|
|
|
__java_add HOMES1_4 "$HOME/opt/jvm32/$vm" 32
|
2013-08-27 15:14:44 +04:00
|
|
|
done
|
|
|
|
array_from_lines vms "$(list_dirs "$HOME/opt/jvm32" "jdk1.5.*" | LANG=C sort -r)"
|
|
|
|
for vm in "${vms[@]}"; do
|
|
|
|
__java_add VMS5 "$vm" 32
|
|
|
|
__java_add HOMES5 "$HOME/opt/jvm32/$vm" 32
|
|
|
|
done
|
|
|
|
array_from_lines vms "$(list_dirs "$HOME/opt/jvm32" "jdk1.6.*" | LANG=C sort -r)"
|
|
|
|
for vm in "${vms[@]}"; do
|
|
|
|
__java_add VMS6 "$vm" 32
|
|
|
|
__java_add HOMES6 "$HOME/opt/jvm32/$vm" 32
|
|
|
|
done
|
|
|
|
array_from_lines vms "$(list_dirs "$HOME/opt/jvm32" "jdk1.7.*" | LANG=C sort -r)"
|
|
|
|
for vm in "${vms[@]}"; do
|
|
|
|
__java_add VMS7 "$vm" 32
|
|
|
|
__java_add HOMES7 "$HOME/opt/jvm32/$vm" 32
|
|
|
|
done
|
2014-11-11 16:25:53 +04:00
|
|
|
array_from_lines vms "$(list_dirs "$HOME/opt/jvm32" "jdk1.8.*" | LANG=C sort -r)"
|
|
|
|
for vm in "${vms[@]}"; do
|
|
|
|
__java_add VMS8 "$vm" 32
|
|
|
|
__java_add HOMES8 "$HOME/opt/jvm32/$vm" 32
|
|
|
|
done
|
2013-08-27 15:14:44 +04:00
|
|
|
array_from_lines vms "$(list_dirs "$HOME/opt/jvm64" "sun-jdk-*")"
|
|
|
|
for vm in "${vms[@]}"; do
|
|
|
|
v="${vm#sun-jdk-}"
|
|
|
|
if [ "$v" == 1.5 ]; then
|
|
|
|
__java_add VMS5 "$vm" 64
|
|
|
|
__java_add HOMES5 "$HOME/opt/jvm64/$vm" 64
|
|
|
|
elif [ "$v" == 1.6 ]; then
|
|
|
|
__java_add VMS6 "$vm" 64
|
|
|
|
__java_add HOMES6 "$HOME/opt/jvm64/$vm" 64
|
|
|
|
elif [ "$v" == 1.7 ]; then
|
|
|
|
__java_add VMS7 "$vm" 64
|
|
|
|
__java_add HOMES7 "$HOME/opt/jvm64/$vm" 64
|
2014-11-11 16:25:53 +04:00
|
|
|
elif [ "$v" == 1.8 ]; then
|
|
|
|
__java_add VMS8 "$vm" 64
|
|
|
|
__java_add HOMES8 "$HOME/opt/jvm64/$vm" 64
|
2013-08-27 15:14:44 +04:00
|
|
|
fi
|
|
|
|
done
|
2023-08-22 08:42:34 +04:00
|
|
|
array_from_lines vms "$(list_dirs "$HOME/opt/jvm64" jdk17)"
|
|
|
|
for vm in "${vms[@]}"; do
|
|
|
|
v="${vm#jdk}"
|
|
|
|
if [ "$v" == 17 ]; then
|
|
|
|
__java_add VMS17 "$vm" 64
|
|
|
|
__java_add HOMES17 "$HOME/opt/jvm64/$vm" 64
|
|
|
|
fi
|
|
|
|
done
|
2020-10-06 03:46:31 +04:00
|
|
|
array_from_lines vms "$(list_dirs "$HOME/opt/jvm64" jdk11)"
|
|
|
|
for vm in "${vms[@]}"; do
|
|
|
|
v="${vm#jdk}"
|
|
|
|
if [ "$v" == 11 ]; then
|
|
|
|
__java_add VMS11 "$vm" 64
|
|
|
|
__java_add HOMES11 "$HOME/opt/jvm64/$vm" 64
|
|
|
|
fi
|
|
|
|
done
|
2013-08-27 15:14:44 +04:00
|
|
|
array_from_lines vms "$(list_dirs "$HOME/opt/jvm64" "jdk1.5.*" | LANG=C sort -r)"
|
|
|
|
for vm in "${vms[@]}"; do
|
|
|
|
__java_add VMS5 "$vm" 64
|
|
|
|
__java_add HOMES5 "$HOME/opt/jvm64/$vm" 64
|
|
|
|
done
|
|
|
|
array_from_lines vms "$(list_dirs "$HOME/opt/jvm64" "jdk1.6.*" | LANG=C sort -r)"
|
|
|
|
for vm in "${vms[@]}"; do
|
|
|
|
__java_add VMS6 "$vm" 64
|
|
|
|
__java_add HOMES6 "$HOME/opt/jvm64/$vm" 64
|
|
|
|
done
|
|
|
|
array_from_lines vms "$(list_dirs "$HOME/opt/jvm64" "jdk1.7.*" | LANG=C sort -r)"
|
|
|
|
for vm in "${vms[@]}"; do
|
|
|
|
__java_add VMS7 "$vm" 64
|
|
|
|
__java_add HOMES7 "$HOME/opt/jvm64/$vm" 64
|
|
|
|
done
|
2014-11-11 16:25:53 +04:00
|
|
|
array_from_lines vms "$(list_dirs "$HOME/opt/jvm64" "jdk1.8.*" | LANG=C sort -r)"
|
|
|
|
for vm in "${vms[@]}"; do
|
|
|
|
__java_add VMS8 "$vm" 64
|
|
|
|
__java_add HOMES8 "$HOME/opt/jvm64/$vm" 64
|
|
|
|
done
|
2020-10-06 03:46:31 +04:00
|
|
|
array_from_lines vms "$(list_dirs "$HOME/opt/jvm64" "jdk-11.*" | LANG=C sort -r)"
|
|
|
|
for vm in "${vms[@]}"; do
|
|
|
|
__java_add VMS11 "$vm" 64
|
|
|
|
__java_add HOMES11 "$HOME/opt/jvm64/$vm" 64
|
|
|
|
done
|
2023-08-22 08:42:34 +04:00
|
|
|
array_from_lines vms "$(list_dirs "$HOME/opt/jvm64" "jdk-17.*" | LANG=C sort -r)"
|
|
|
|
for vm in "${vms[@]}"; do
|
|
|
|
__java_add VMS17 "$vm" 64
|
|
|
|
__java_add HOMES17 "$HOME/opt/jvm64/$vm" 64
|
|
|
|
done
|
2013-08-27 15:14:44 +04:00
|
|
|
# Puis chercher dans les JVMs installées manuellement dans ~/opt
|
|
|
|
array_from_lines vms "$(list_dirs "$HOME/opt" "sun-jdk-*")"
|
|
|
|
for vm in "${vms[@]}"; do
|
|
|
|
v="${vm#sun-jdk-}"
|
|
|
|
if [ "$v" == 1.4 ]; then
|
2020-10-06 03:46:31 +04:00
|
|
|
__java_add VMS1_4 "$vm"
|
|
|
|
__java_add HOMES1_4 "$HOME/opt/$vm"
|
2013-08-27 15:14:44 +04:00
|
|
|
elif [ "$v" == 1.5 ]; then
|
|
|
|
__java_add VMS5 "$vm"
|
|
|
|
__java_add HOMES5 "$HOME/opt/$vm"
|
|
|
|
elif [ "$v" == 1.6 ]; then
|
|
|
|
__java_add VMS6 "$vm"
|
|
|
|
__java_add HOMES6 "$HOME/opt/$vm"
|
|
|
|
elif [ "$v" == 1.7 ]; then
|
|
|
|
__java_add VMS7 "$vm"
|
|
|
|
__java_add HOMES7 "$HOME/opt/$vm"
|
2014-11-11 16:25:53 +04:00
|
|
|
elif [ "$v" == 1.8 ]; then
|
|
|
|
__java_add VMS8 "$vm"
|
|
|
|
__java_add HOMES8 "$HOME/opt/$vm"
|
2013-08-27 15:14:44 +04:00
|
|
|
fi
|
|
|
|
done
|
2020-10-06 03:46:31 +04:00
|
|
|
array_from_lines vms "$(list_dirs "$HOME/opt" jdk11)"
|
|
|
|
for vm in "${vms[@]}"; do
|
|
|
|
v="${vm#jdk}"
|
|
|
|
if [ "$v" == 11 ]; then
|
|
|
|
__java_add VMS11 "$vm"
|
|
|
|
__java_add HOMES11 "$HOME/opt/$vm"
|
|
|
|
fi
|
|
|
|
done
|
2023-08-22 08:42:34 +04:00
|
|
|
array_from_lines vms "$(list_dirs "$HOME/opt" jdk17)"
|
|
|
|
for vm in "${vms[@]}"; do
|
|
|
|
v="${vm#jdk}"
|
|
|
|
if [ "$v" == 17 ]; then
|
|
|
|
__java_add VMS17 "$vm"
|
|
|
|
__java_add HOMES17 "$HOME/opt/$vm"
|
|
|
|
fi
|
|
|
|
done
|
2013-08-27 15:14:44 +04:00
|
|
|
array_from_lines vms "$(list_dirs "$HOME/opt" "j2sdk1.4.2*" | LANG=C sort -r)"
|
|
|
|
for vm in "${vms[@]}"; do
|
2020-10-06 03:46:31 +04:00
|
|
|
__java_add VMS1_4 "$vm"
|
|
|
|
__java_add HOMES1_4 "$HOME/opt/$vm"
|
2013-08-27 15:14:44 +04:00
|
|
|
done
|
|
|
|
array_from_lines vms "$(list_dirs "$HOME/opt" "jdk1.5.*" | LANG=C sort -r)"
|
|
|
|
for vm in "${vms[@]}"; do
|
|
|
|
__java_add VMS5 "$vm"
|
|
|
|
__java_add HOMES5 "$HOME/opt/$vm"
|
|
|
|
done
|
|
|
|
array_from_lines vms "$(list_dirs "$HOME/opt" "jdk1.6.*" | LANG=C sort -r)"
|
|
|
|
for vm in "${vms[@]}"; do
|
|
|
|
__java_add VMS6 "$vm"
|
|
|
|
__java_add HOMES6 "$HOME/opt/$vm"
|
|
|
|
done
|
|
|
|
array_from_lines vms "$(list_dirs "$HOME/opt" "jdk1.7.*" | LANG=C sort -r)"
|
|
|
|
for vm in "${vms[@]}"; do
|
|
|
|
__java_add VMS7 "$vm"
|
|
|
|
__java_add HOMES7 "$HOME/opt/$vm"
|
|
|
|
done
|
2014-11-11 16:25:53 +04:00
|
|
|
array_from_lines vms "$(list_dirs "$HOME/opt" "jdk1.8.*" | LANG=C sort -r)"
|
|
|
|
for vm in "${vms[@]}"; do
|
|
|
|
__java_add VMS8 "$vm"
|
|
|
|
__java_add HOMES8 "$HOME/opt/$vm"
|
|
|
|
done
|
2020-10-06 03:46:31 +04:00
|
|
|
array_from_lines vms "$(list_dirs "$HOME/opt" "jdk-11.*" | LANG=C sort -r)"
|
|
|
|
for vm in "${vms[@]}"; do
|
|
|
|
__java_add VMS11 "$vm"
|
|
|
|
__java_add HOMES11 "$HOME/opt/$vm"
|
|
|
|
done
|
2023-08-22 08:42:34 +04:00
|
|
|
array_from_lines vms "$(list_dirs "$HOME/opt" "jdk-17.*" | LANG=C sort -r)"
|
|
|
|
for vm in "${vms[@]}"; do
|
|
|
|
__java_add VMS17 "$vm"
|
|
|
|
__java_add HOMES17 "$HOME/opt/$vm"
|
|
|
|
done
|
2013-08-27 15:14:44 +04:00
|
|
|
# Puis chercher dans les JVMs installées manuellement dans /opt
|
|
|
|
array_from_lines vms "$(list_dirs "/opt" "sun-jdk-*")"
|
|
|
|
for vm in "${vms[@]}"; do
|
|
|
|
v="${vm#sun-jdk-}"
|
|
|
|
if [ "$v" == 1.4 ]; then
|
2020-10-06 03:46:31 +04:00
|
|
|
__java_add VMS1_4 "$vm"
|
|
|
|
__java_add HOMES1_4 "/opt/$vm"
|
2013-08-27 15:14:44 +04:00
|
|
|
elif [ "$v" == 1.5 ]; then
|
|
|
|
__java_add VMS5 "$vm"
|
|
|
|
__java_add HOMES5 "/opt/$vm"
|
|
|
|
elif [ "$v" == 1.6 ]; then
|
|
|
|
__java_add VMS6 "$vm"
|
|
|
|
__java_add HOMES6 "/opt/$vm"
|
|
|
|
elif [ "$v" == 1.7 ]; then
|
|
|
|
__java_add VMS7 "$vm"
|
|
|
|
__java_add HOMES7 "/opt/$vm"
|
2014-11-11 16:25:53 +04:00
|
|
|
elif [ "$v" == 1.8 ]; then
|
|
|
|
__java_add VMS8 "$vm"
|
|
|
|
__java_add HOMES8 "/opt/$vm"
|
2013-08-27 15:14:44 +04:00
|
|
|
fi
|
|
|
|
done
|
2020-10-06 03:46:31 +04:00
|
|
|
array_from_lines vms "$(list_dirs "/opt" jdk11)"
|
|
|
|
for vm in "${vms[@]}"; do
|
|
|
|
v="${vm#jdk}"
|
|
|
|
if [ "$v" == 11 ]; then
|
|
|
|
__java_add VMS11 "$vm"
|
|
|
|
__java_add HOMES11 "/opt/$vm"
|
|
|
|
fi
|
|
|
|
done
|
2023-08-22 08:42:34 +04:00
|
|
|
array_from_lines vms "$(list_dirs "/opt" jdk17)"
|
|
|
|
for vm in "${vms[@]}"; do
|
|
|
|
v="${vm#jdk}"
|
|
|
|
if [ "$v" == 17 ]; then
|
|
|
|
__java_add VMS17 "$vm"
|
|
|
|
__java_add HOMES17 "/opt/$vm"
|
|
|
|
fi
|
|
|
|
done
|
2013-08-27 15:14:44 +04:00
|
|
|
array_from_lines vms "$(list_dirs "/opt" "j2sdk1.4.2*" | LANG=C sort -r)"
|
|
|
|
for vm in "${vms[@]}"; do
|
2020-10-06 03:46:31 +04:00
|
|
|
__java_add VMS1_4 "$vm"
|
|
|
|
__java_add HOMES1_4 "/opt/$vm"
|
2013-08-27 15:14:44 +04:00
|
|
|
done
|
|
|
|
array_from_lines vms "$(list_dirs "/opt" "jdk1.5.*" | LANG=C sort -r)"
|
|
|
|
for vm in "${vms[@]}"; do
|
|
|
|
__java_add VMS5 "$vm"
|
|
|
|
__java_add HOMES5 "/opt/$vm"
|
|
|
|
done
|
|
|
|
array_from_lines vms "$(list_dirs "/opt" "jdk1.6.*" | LANG=C sort -r)"
|
|
|
|
for vm in "${vms[@]}"; do
|
|
|
|
__java_add VMS6 "$vm"
|
|
|
|
__java_add HOMES6 "/opt/$vm"
|
|
|
|
done
|
|
|
|
array_from_lines vms "$(list_dirs "/opt" "jdk1.7.*" | LANG=C sort -r)"
|
|
|
|
for vm in "${vms[@]}"; do
|
|
|
|
__java_add VMS7 "$vm"
|
|
|
|
__java_add HOMES7 "/opt/$vm"
|
|
|
|
done
|
2014-11-11 16:25:53 +04:00
|
|
|
array_from_lines vms "$(list_dirs "/opt" "jdk1.8.*" | LANG=C sort -r)"
|
|
|
|
for vm in "${vms[@]}"; do
|
|
|
|
__java_add VMS8 "$vm"
|
|
|
|
__java_add HOMES8 "/opt/$vm"
|
|
|
|
done
|
2020-10-06 03:46:31 +04:00
|
|
|
array_from_lines vms "$(list_dirs "/opt" "jdk-11.*" | LANG=C sort -r)"
|
|
|
|
for vm in "${vms[@]}"; do
|
|
|
|
__java_add VMS11 "$vm"
|
|
|
|
__java_add HOMES11 "/opt/$vm"
|
|
|
|
done
|
2023-08-22 08:42:34 +04:00
|
|
|
array_from_lines vms "$(list_dirs "/opt" "jdk-17.*" | LANG=C sort -r)"
|
|
|
|
for vm in "${vms[@]}"; do
|
|
|
|
__java_add VMS17 "$vm"
|
|
|
|
__java_add HOMES17 "/opt/$vm"
|
|
|
|
done
|
2013-08-27 15:14:44 +04:00
|
|
|
# Puis chercher dans les JVMs installées par le système dans
|
|
|
|
# /usr/lib/jvm
|
|
|
|
if check_sysinfos -d gentoo; then
|
|
|
|
# sur gentoo
|
|
|
|
array_from_lines vms "$(list_dirs /usr/lib/jvm)"
|
|
|
|
for vm in "${vms[@]}"; do
|
|
|
|
v="${vm#sun-jdk-}"
|
|
|
|
if [ "$v" == 1.4 ]; then
|
2020-10-06 03:46:31 +04:00
|
|
|
__java_add VMS1_4 "$vm"
|
|
|
|
__java_add HOMES1_4 "/usr/lib/jvm/$vm"
|
2013-08-27 15:14:44 +04:00
|
|
|
elif [ "$v" == 1.5 ]; then
|
|
|
|
__java_add VMS5 "$vm"
|
|
|
|
__java_add HOMES5 "/usr/lib/jvm/$vm"
|
|
|
|
elif [ "$v" == 1.6 ]; then
|
|
|
|
__java_add VMS6 "$vm"
|
|
|
|
__java_add HOMES6 "/usr/lib/jvm/$vm"
|
|
|
|
elif [ "$v" == 1.7 ]; then
|
|
|
|
__java_add VMS7 "$vm"
|
|
|
|
__java_add HOMES7 "/usr/lib/jvm/$vm"
|
2014-11-11 16:25:53 +04:00
|
|
|
elif [ "$v" == 1.8 ]; then
|
|
|
|
__java_add VMS8 "$vm"
|
|
|
|
__java_add HOMES8 "/usr/lib/jvm/$vm"
|
2013-08-27 15:14:44 +04:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
elif check_sysinfos -d debianlike; then
|
|
|
|
# sur debian
|
|
|
|
array_from_lines vms "$(list_dirs /usr/lib/jvm)"
|
|
|
|
for vm in "${vms[@]}"; do
|
2020-10-06 04:40:55 +04:00
|
|
|
v="$vm"
|
|
|
|
v="${v%-sun}"
|
|
|
|
v="${v%-amd64}"
|
|
|
|
v="${v%-openjdk}"
|
2013-08-27 15:14:44 +04:00
|
|
|
v="${v#java-}"
|
|
|
|
v="${v#j2sdk}"
|
|
|
|
if [ "$v" == 1.4 ]; then
|
2020-10-06 03:46:31 +04:00
|
|
|
__java_add VMS1_4 "$vm"
|
|
|
|
__java_add HOMES1_4 "/usr/lib/jvm/$vm"
|
2013-08-27 15:14:44 +04:00
|
|
|
elif [ "$v" == 1.5 -o "$v" == 1.5.0 ]; then
|
|
|
|
__java_add VMS5 "$vm"
|
|
|
|
__java_add HOMES5 "/usr/lib/jvm/$vm"
|
|
|
|
elif [ "$v" == 6 -o "$v" == 1.6 ]; then
|
|
|
|
__java_add VMS6 "$vm"
|
|
|
|
__java_add HOMES6 "/usr/lib/jvm/$vm"
|
|
|
|
elif [ "$v" == 7 -o "$v" == 1.7 ]; then
|
|
|
|
__java_add VMS7 "$vm"
|
|
|
|
__java_add HOMES7 "/usr/lib/jvm/$vm"
|
2014-11-11 16:25:53 +04:00
|
|
|
elif [ "$v" == 8 -o "$v" == 1.8 ]; then
|
|
|
|
__java_add VMS8 "$vm"
|
|
|
|
__java_add HOMES8 "/usr/lib/jvm/$vm"
|
2020-10-06 03:46:31 +04:00
|
|
|
elif [ "$v" == 11 ]; then
|
|
|
|
__java_add VMS11 "$vm"
|
|
|
|
__java_add HOMES11 "/usr/lib/jvm/$vm"
|
2023-08-22 08:42:34 +04:00
|
|
|
elif [ "$v" == 17 ]; then
|
|
|
|
__java_add VMS17 "$vm"
|
|
|
|
__java_add HOMES17 "/usr/lib/jvm/$vm"
|
2013-08-27 15:14:44 +04:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
if [ -d /usr/lib/j2sdk1.4-sun ]; then
|
2020-10-06 03:46:31 +04:00
|
|
|
__java_add VMS1_4 j2sdk1.4-sun
|
|
|
|
__java_add HOMES1_4 /usr/lib/j2sdk1.4-sun
|
2013-08-27 15:14:44 +04:00
|
|
|
fi
|
|
|
|
elif check_sysinfos -d redhatlike; then
|
|
|
|
# XXX sur redhat
|
|
|
|
:
|
|
|
|
fi
|
|
|
|
elif check_sysinfos -s macosx; then
|
|
|
|
if [ -d "/System/Library/Frameworks/JavaVM.framework/Versions/1.3" ]; then
|
2020-10-06 03:46:31 +04:00
|
|
|
__java_add VMS1_3 "1.3"
|
|
|
|
__java_add HOMES1_3 "/System/Library/Frameworks/JavaVM.framework/Versions/1.3/Home"
|
2013-08-27 15:14:44 +04:00
|
|
|
fi
|
|
|
|
if [ -d "/System/Library/Frameworks/JavaVM.framework/Versions/1.4" ]; then
|
2020-10-06 03:46:31 +04:00
|
|
|
__java_add VMS1_4 "1.4"
|
|
|
|
__java_add HOMES1_4 "/System/Library/Frameworks/JavaVM.framework/Versions/1.4/Home"
|
2013-08-27 15:14:44 +04:00
|
|
|
fi
|
|
|
|
if [ -d "/System/Library/Frameworks/JavaVM.framework/Versions/1.5" ]; then
|
|
|
|
__java_add VMS5 "1.5"
|
|
|
|
__java_add HOMES5 "/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home"
|
|
|
|
fi
|
|
|
|
if [ -d "/System/Library/Frameworks/JavaVM.framework/Versions/1.6" ]; then
|
|
|
|
__java_add VMS6 "1.6"
|
|
|
|
__java_add HOMES6 "/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home"
|
|
|
|
fi
|
|
|
|
if [ -d "/System/Library/Frameworks/JavaVM.framework/Versions/1.7" ]; then
|
|
|
|
__java_add VMS7 "1.7"
|
|
|
|
__java_add HOMES7 "/System/Library/Frameworks/JavaVM.framework/Versions/1.7/Home"
|
|
|
|
fi
|
2014-11-11 16:25:53 +04:00
|
|
|
if [ -d "/System/Library/Frameworks/JavaVM.framework/Versions/1.8" ]; then
|
|
|
|
__java_add VMS8 "1.8"
|
|
|
|
__java_add HOMES8 "/System/Library/Frameworks/JavaVM.framework/Versions/1.8/Home"
|
|
|
|
fi
|
2013-08-27 15:14:44 +04:00
|
|
|
fi
|
|
|
|
__COMPUTED_JAVA_VMS=1
|
|
|
|
}
|
|
|
|
|
|
|
|
function __java_dump_vms() {
|
|
|
|
local v b i vms homes
|
2023-08-22 08:42:34 +04:00
|
|
|
for v in 1_3 1_4 5 6 7 8 11 17; do
|
2013-08-27 15:14:44 +04:00
|
|
|
for b in "" 32 64; do
|
|
|
|
vms="JAVA${b}_VMS${v}[@]"; vms=("${!vms}")
|
|
|
|
homes="JAVA${b}_HOMES${v}[@]"; homes=("${!homes}")
|
|
|
|
i=0
|
|
|
|
while [ $i -lt "${#vms[*]}" ]; do
|
|
|
|
echo "$v${b:+-$b}:${vms[$i]}:${homes[$i]}"
|
|
|
|
i=$(($i + 1))
|
|
|
|
done
|
|
|
|
done
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
function __java_select_vms() {
|
|
|
|
if [ -z "$2" ]; then
|
|
|
|
array_copy vms "JAVA_VMS$1"
|
|
|
|
if [ -n "${vms[*]}" ]; then
|
|
|
|
array_copy homes "JAVA_HOMES$1"
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
array_copy vms "JAVA${2}_VMS$1"
|
|
|
|
array_copy homes "JAVA${2}_HOMES$1"
|
|
|
|
custom=1
|
|
|
|
[ -n "${vms[*]}" ] && return 0 || return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function __java_select() {
|
2023-08-22 08:42:34 +04:00
|
|
|
# Sélectionner la version de java $1 (qui peut être 1_3, 1_4, 5, 6, 7, 8, 11, 17)
|
2013-08-27 15:14:44 +04:00
|
|
|
# Si $2 est défini, il peut s'agit de 32 ou 64 selon que l'on requière la
|
|
|
|
# version 32bits ou 64 bits. Sinon, la version sélectionnée peut être 32bits
|
|
|
|
# ou 64bits selon ce qui est disponible.
|
|
|
|
__java_compute_vms
|
|
|
|
|
|
|
|
local vms homes custom
|
|
|
|
if [ -z "$2" ]; then
|
|
|
|
__java_select_vms "$1" "$MYBITS" ||
|
|
|
|
__java_select_vms "$1" ||
|
|
|
|
__java_select_vms "$1" 32 ||
|
|
|
|
__java_select_vms "$1" 64
|
|
|
|
elif [ "$MYBITS" == "$2" ]; then
|
|
|
|
__java_select_vms "$1" "$2" ||
|
|
|
|
__java_select_vms "$1"
|
|
|
|
else
|
|
|
|
__java_select_vms "$1" "$2"
|
|
|
|
fi
|
|
|
|
if [ -n "${vms[*]}" ]; then
|
|
|
|
SELECTED_JAVA_VM="${vms[0]}"
|
|
|
|
SELECTED_JAVA_HOME="${homes[0]}"
|
|
|
|
SELECTED_JAVA="$SELECTED_JAVA_HOME/bin/java"
|
|
|
|
SELECTED_JAVAC="$SELECTED_JAVA_HOME/bin/javac"
|
|
|
|
if [ -z "$custom" -a "$LINUX_FLAVOUR" == "gentoo" ]; then
|
|
|
|
export GENTOO_VM="$SELECTED_JAVA_VM"
|
|
|
|
export JAVA=java
|
|
|
|
export JAVAC=javac
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
[ "$LINUX_FLAVOUR" == "gentoo" ] && unset GENTOO_VM
|
|
|
|
export JAVA_HOME="$SELECTED_JAVA_HOME"
|
|
|
|
export JAVA="$SELECTED_JAVA"
|
|
|
|
export JAVAC="$SELECTED_JAVAC"
|
2013-11-06 09:45:34 +04:00
|
|
|
udelpath "$JAVA_HOME/bin"
|
|
|
|
uinspath "$JAVA_HOME/bin"
|
|
|
|
export PATH
|
2013-08-27 15:14:44 +04:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
function __java_select_default() {
|
|
|
|
# Sélectionner la version de java par défaut. Si JAVA_HOME est défini,
|
2023-08-22 08:42:34 +04:00
|
|
|
# prendre cette valeur. Sinon, essayer dans l'ordre 5, 6, 7, 8, 11, 17 puis 1_4
|
2020-10-06 03:46:31 +04:00
|
|
|
# la version 1_3 n'est jamais sélectionnée automatiquement
|
2013-08-27 15:14:44 +04:00
|
|
|
if [ -n "$JAVA_HOME" ]; then
|
2013-11-06 09:45:34 +04:00
|
|
|
export JAVA_HOME # s'assurer que cette variable est exportée
|
2013-08-27 15:14:44 +04:00
|
|
|
export JAVA="$JAVA_HOME/bin/java"
|
|
|
|
export JAVAC="$JAVA_HOME/bin/java"
|
2013-11-06 09:45:34 +04:00
|
|
|
udelpath "$JAVA_HOME/bin"
|
|
|
|
uinspath "$JAVA_HOME/bin"
|
|
|
|
export PATH
|
2013-08-27 15:14:44 +04:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
local vm
|
2023-08-22 08:42:34 +04:00
|
|
|
for vm in 5 6 7 8 11 17 1_4; do
|
2013-08-27 15:14:44 +04:00
|
|
|
__java_select "$vm" && return 0
|
|
|
|
done
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
function select_java() {
|
|
|
|
# sélectionner la version *minimum* de java correspondant à $1
|
2023-08-22 08:42:34 +04:00
|
|
|
# $1 == 1.3|1.3+|1.4|1.4+|1.5|1.5+|1.6|1.6+|1.7|1.7+|1.8|1.8+|11|11+|17|17+
|
2013-08-27 15:14:44 +04:00
|
|
|
# Si $2 est défini, il peut s'agit de 32 ou 64 selon que l'on requière la
|
|
|
|
# version 32bits ou 64 bits
|
|
|
|
local v vms homes
|
|
|
|
|
|
|
|
case "$1" in
|
2020-10-06 03:46:31 +04:00
|
|
|
1.3|1.3+)
|
2023-11-07 09:21:15 +04:00
|
|
|
for v in 1_3 1_4 5 6 7 8; do
|
2013-08-27 15:14:44 +04:00
|
|
|
__java_select "$v" "$2" && return 0
|
|
|
|
done
|
|
|
|
;;
|
2020-10-06 03:46:31 +04:00
|
|
|
1.4|1.4+)
|
2023-11-07 09:21:15 +04:00
|
|
|
for v in 1_4 5 6 7 8; do
|
2013-08-27 15:14:44 +04:00
|
|
|
__java_select "$v" "$2" && return 0
|
|
|
|
done
|
|
|
|
;;
|
2013-11-06 09:45:34 +04:00
|
|
|
1.5|1.5+|5|5+)
|
2023-11-07 09:21:15 +04:00
|
|
|
for v in 5 6 7 8; do
|
2013-08-27 15:14:44 +04:00
|
|
|
__java_select "$v" "$2" && return 0
|
|
|
|
done
|
|
|
|
;;
|
2013-11-06 09:45:34 +04:00
|
|
|
1.6|1.6+|6|6+)
|
2023-11-07 09:21:15 +04:00
|
|
|
for v in 6 7 8; do
|
2013-08-27 15:14:44 +04:00
|
|
|
__java_select "$v" "$2" && return 0
|
|
|
|
done
|
|
|
|
;;
|
2013-11-06 09:45:34 +04:00
|
|
|
1.7|1.7+|7|7+)
|
2023-11-07 09:21:15 +04:00
|
|
|
for v in 7 8; do
|
2014-11-11 16:25:53 +04:00
|
|
|
__java_select "$v" "$2" && return 0
|
|
|
|
done
|
|
|
|
;;
|
|
|
|
1.8|1.8+|8|8+)
|
2023-11-07 09:21:15 +04:00
|
|
|
for v in 8; do
|
2020-10-06 03:46:31 +04:00
|
|
|
__java_select "$v" "$2" && return 0
|
|
|
|
done
|
|
|
|
;;
|
|
|
|
11|11+)
|
2023-11-07 09:21:15 +04:00
|
|
|
for v in 11 17; do
|
2013-08-27 15:14:44 +04:00
|
|
|
__java_select "$v" "$2" && return 0
|
|
|
|
done
|
|
|
|
;;
|
2023-08-22 08:42:34 +04:00
|
|
|
17|17+)
|
|
|
|
for v in 17; do
|
|
|
|
__java_select "$v" "$2" && return 0
|
|
|
|
done
|
|
|
|
;;
|
2013-08-27 15:14:44 +04:00
|
|
|
esac
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
function select_java_exact() {
|
2013-11-06 09:45:34 +04:00
|
|
|
# sélectionner la version *exacte* de java correspondant à $1
|
2023-08-22 08:42:34 +04:00
|
|
|
# $1 == 1.3|1.4|1.5|1.6|1.7|1.8|11|17 pour une correspondance exacte
|
|
|
|
# $1 == 1.3+|1.4+|1.5+|1.6+|1.7+|1.8+|11+|17+ pour une version minimum
|
2013-08-27 15:14:44 +04:00
|
|
|
# Si $2 est défini, il peut s'agit de 32 ou 64 selon que l'on requière la
|
|
|
|
# version 32bits ou 64 bits
|
|
|
|
local v vms homes
|
|
|
|
|
|
|
|
case "$1" in
|
2020-10-06 03:46:31 +04:00
|
|
|
1.3)
|
|
|
|
__java_select 1_3 && return 0
|
2013-08-27 15:14:44 +04:00
|
|
|
;;
|
2020-10-06 03:46:31 +04:00
|
|
|
1.3+)
|
2023-11-07 09:21:15 +04:00
|
|
|
for v in 1_3 1_4 5 6 7 8; do
|
2013-08-27 15:14:44 +04:00
|
|
|
__java_select "$v" "$2" && return 0
|
|
|
|
done
|
|
|
|
;;
|
2020-10-06 03:46:31 +04:00
|
|
|
1.4)
|
|
|
|
__java_select 1_4 && return 0
|
2013-08-27 15:14:44 +04:00
|
|
|
;;
|
2020-10-06 03:46:31 +04:00
|
|
|
1.4+)
|
2023-11-07 09:21:15 +04:00
|
|
|
for v in 1_4 5 6 7 8; do
|
2013-08-27 15:14:44 +04:00
|
|
|
__java_select "$v" "$2" && return 0
|
|
|
|
done
|
|
|
|
;;
|
2013-11-06 09:45:34 +04:00
|
|
|
1.5|5)
|
2013-08-27 15:14:44 +04:00
|
|
|
__java_select 5 "$2" && return 0
|
|
|
|
;;
|
2013-11-06 09:45:34 +04:00
|
|
|
1.5+|5+)
|
2023-11-07 09:21:15 +04:00
|
|
|
for v in 5 6 7 8; do
|
2013-08-27 15:14:44 +04:00
|
|
|
__java_select "$v" "$2" && return 0
|
|
|
|
done
|
|
|
|
;;
|
2013-11-06 09:45:34 +04:00
|
|
|
1.6|6)
|
2013-08-27 15:14:44 +04:00
|
|
|
__java_select 6 "$2" && return 0
|
|
|
|
;;
|
2013-11-06 09:45:34 +04:00
|
|
|
1.6+|6+)
|
2023-11-07 09:21:15 +04:00
|
|
|
for v in 6 7 8; do
|
2013-08-27 15:14:44 +04:00
|
|
|
__java_select "$v" "$2" && return 0
|
|
|
|
done
|
|
|
|
;;
|
2013-11-06 09:45:34 +04:00
|
|
|
1.7|7)
|
2013-08-27 15:14:44 +04:00
|
|
|
__java_select 7 "$2" && return 0
|
|
|
|
;;
|
2013-11-06 09:45:34 +04:00
|
|
|
1.7+|7+)
|
2023-11-07 09:21:15 +04:00
|
|
|
for v in 7 8; do
|
2014-11-11 16:25:53 +04:00
|
|
|
__java_select "$v" "$2" && return 0
|
|
|
|
done
|
|
|
|
;;
|
|
|
|
1.8|8)
|
|
|
|
__java_select 8 "$2" && return 0
|
|
|
|
;;
|
|
|
|
1.8+|8+)
|
2023-11-07 09:21:15 +04:00
|
|
|
for v in 8; do
|
2020-10-06 03:46:31 +04:00
|
|
|
__java_select "$v" "$2" && return 0
|
|
|
|
done
|
|
|
|
;;
|
|
|
|
11)
|
|
|
|
__java_select 11 "$2" && return 0
|
|
|
|
;;
|
|
|
|
11+)
|
2023-11-07 09:21:15 +04:00
|
|
|
for v in 11 17; do
|
2013-08-27 15:14:44 +04:00
|
|
|
__java_select "$v" "$2" && return 0
|
|
|
|
done
|
|
|
|
;;
|
2023-08-22 08:42:34 +04:00
|
|
|
17)
|
|
|
|
__java_select 17 "$2" && return 0
|
|
|
|
;;
|
|
|
|
17+)
|
|
|
|
for v in 17; do
|
|
|
|
__java_select "$v" "$2" && return 0
|
|
|
|
done
|
|
|
|
;;
|
2013-08-27 15:14:44 +04:00
|
|
|
esac
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2013-11-06 09:45:34 +04:00
|
|
|
function select_java_any() {
|
|
|
|
# Sélectionner la version exacte de java correspondant aux arguments, dans
|
|
|
|
# l'ordre, jusqu'à ce qu'un argument corresponde. DEFAULT correspond à la
|
|
|
|
# valeur actuelle de JAVA_HOME, si elle est définie.
|
2023-08-22 08:42:34 +04:00
|
|
|
# Si aucun argument n'est défini, on assume "DEFAULT 5 6 7 8 11 17 1.4"
|
2013-11-06 09:45:34 +04:00
|
|
|
local v
|
2023-08-22 08:42:34 +04:00
|
|
|
[ -n "$*" ] || set -- DEFAULT 5 6 7 8 11 17 1.4
|
2013-11-06 09:45:34 +04:00
|
|
|
for v in "$@"; do
|
|
|
|
if [ "$v" == DEFAULT ]; then
|
|
|
|
if [ -n "$JAVA_HOME" ]; then
|
|
|
|
__java_select_default && return 0
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
select_java_exact "$v" && return 0
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2016-04-28 10:40:13 +04:00
|
|
|
function get_java_version() {
|
|
|
|
# Afficher la version de java qui installée dans $1(=$JAVA_HOME)
|
|
|
|
# En cas d'erreur, ne rien afficher.
|
|
|
|
local java_home="$1"
|
|
|
|
[ -n "$java_home" ] || java_home="$JAVA_HOME"
|
|
|
|
[ -n "$java_home" ] || return 1
|
|
|
|
"$java_home/bin/java" -version 2>&1 >/dev/null |
|
|
|
|
awk '{ if (match($0, /".*"/) != 0) { print substr($0, RSTART + 1, RLENGTH - 2) }; exit }'
|
|
|
|
}
|
|
|
|
|
2013-08-27 15:14:44 +04:00
|
|
|
################################################################################
|
|
|
|
# Gestion des préfixes
|
|
|
|
|
|
|
|
function get_default_javahome_prefix() {
|
|
|
|
local GENTOO_VM JAVA_HOME JAVA JAVAC PATH="$PATH"
|
|
|
|
__java_select_default
|
|
|
|
[ -n "$JAVA_HOME" ] && echo "$JAVA_HOME"
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_javaextensions_prefix() {
|
|
|
|
local javaextensions
|
|
|
|
if check_sysinfos -s linux; then
|
|
|
|
if [ -n "$JAVA_HOME" ]; then
|
|
|
|
javaextensions="$JAVA_HOME/jre/lib/ext"
|
|
|
|
[ -d "$javaextensions" ] || javaextensions="$JAVA_HOME/lib/ext"
|
|
|
|
fi
|
|
|
|
elif check_sysinfos -s darwin; then
|
|
|
|
javaextensions=/Library/Java/Extensions
|
|
|
|
fi
|
|
|
|
|
|
|
|
[ -n "$javaextensions" -a -d "$javaextensions" ] && echo "$javaextensions"
|
|
|
|
}
|
|
|
|
|
|
|
|
__java_prefixes=
|
|
|
|
function __compute_java_prefixes() {
|
|
|
|
[ -n "$__java_prefixes" ] && return
|
|
|
|
[ -n "$JAVA_HOME" ] || JAVA_HOME="$(get_default_javahome_prefix)"
|
|
|
|
JAVAEXTENSIONS="${JAVAEXTENSIONS:-$(get_javaextensions_prefix)}"
|
|
|
|
__java_prefixes=1
|
|
|
|
}
|
|
|
|
|
2015-08-23 22:56:23 +04:00
|
|
|
JAVA_PREFIXES=(JAVA_HOME JAVAEXTENSIONS)
|
|
|
|
UTOOLS_PREFIXES=("${UTOOLS_PREFIXES[@]}" "${JAVA_PREFIXES[@]}")
|
2013-08-27 15:14:44 +04:00
|
|
|
|
|
|
|
function compute_java_prefixes() {
|
|
|
|
__compute_java_prefixes
|
|
|
|
}
|
|
|
|
|
|
|
|
function recompute_java_prefixes() {
|
2015-08-23 22:56:23 +04:00
|
|
|
local v
|
|
|
|
for v in "${JAVA_PREFIXES[@]}"; do
|
|
|
|
eval "$v="
|
|
|
|
done
|
2013-08-27 15:14:44 +04:00
|
|
|
__java_prefixes=
|
|
|
|
__compute_java_prefixes
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_JAVA_HOME_prefix() {
|
|
|
|
__compute_java_prefixes
|
|
|
|
echo "$JAVA_HOME"
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_JAVAEXTENSIONS_prefix() {
|
|
|
|
__compute_java_prefixes
|
|
|
|
echo "$JAVAEXTENSIONS"
|
|
|
|
}
|