support sélection java 11
This commit is contained in:
parent
82a7952e2a
commit
51c4c3317c
174
lib/ulib/java
174
lib/ulib/java
|
@ -8,24 +8,27 @@ urequire base sysinfos
|
|||
|
||||
################################################################################
|
||||
# versions installées sur le système
|
||||
JAVA_VMS13=(); JAVA_HOMES13=()
|
||||
JAVA_VMS14=(); JAVA_HOMES14=()
|
||||
JAVA_VMS1_3=(); JAVA_HOMES1_3=()
|
||||
JAVA_VMS1_4=(); JAVA_HOMES1_4=()
|
||||
JAVA_VMS5=(); JAVA_HOMES5=()
|
||||
JAVA_VMS6=(); JAVA_HOMES6=()
|
||||
JAVA_VMS7=(); JAVA_HOMES7=()
|
||||
JAVA_VMS8=(); JAVA_HOMES8=()
|
||||
JAVA_VMS11=(); JAVA_HOMES11=()
|
||||
# versions locales 32 bits
|
||||
JAVA32_VMS13=(); JAVA32_HOMES13=()
|
||||
JAVA32_VMS14=(); JAVA32_HOMES14=()
|
||||
JAVA32_VMS1_3=(); JAVA32_HOMES1_3=()
|
||||
JAVA32_VMS1_4=(); JAVA32_HOMES1_4=()
|
||||
JAVA32_VMS5=(); JAVA32_HOMES5=()
|
||||
JAVA32_VMS6=(); JAVA32_HOMES6=()
|
||||
JAVA32_VMS7=(); JAVA32_HOMES7=()
|
||||
JAVA32_VMS8=(); JAVA32_HOMES8=()
|
||||
JAVA32_VMS11=(); JAVA32_HOMES11=()
|
||||
# versions locales 64 bits
|
||||
JAVA64_VMS5=(); JAVA64_HOMES5=()
|
||||
JAVA64_VMS6=(); JAVA64_HOMES6=()
|
||||
JAVA64_VMS7=(); JAVA64_HOMES7=()
|
||||
JAVA64_VMS8=(); JAVA64_HOMES8=()
|
||||
JAVA64_VMS11=(); JAVA64_HOMES11=()
|
||||
# version sélectionnée
|
||||
SELECTED_JAVA_VM=; SELECTED_JAVA_HOME=
|
||||
SELECTED_JAVA=; SELECTED_JAVAC=
|
||||
|
@ -37,7 +40,7 @@ function __java_add() {
|
|||
|
||||
function __java_compute_vms() {
|
||||
# calculer la liste de VMs disponibles et initialiser les tableaux
|
||||
# JAVA{,32,64}_{VMS,HOMES}{13,14,5,6,7,8}
|
||||
# JAVA{,32,64}_{VMS,HOMES}{1_3,1_4,5,6,7,8}
|
||||
[ -z "$__COMPUTED_JAVA_VMS" ] || return
|
||||
|
||||
local vms vm v
|
||||
|
@ -48,8 +51,8 @@ function __java_compute_vms() {
|
|||
for vm in "${vms[@]}"; do
|
||||
v="${vm#sun-jdk-}"
|
||||
if [ "$v" == 1.4 ]; then
|
||||
__java_add VMS14 "$vm" 32
|
||||
__java_add HOMES14 "$HOME/opt/jvm32/$vm" 32
|
||||
__java_add VMS1_4 "$vm" 32
|
||||
__java_add HOMES1_4 "$HOME/opt/jvm32/$vm" 32
|
||||
elif [ "$v" == 1.5 ]; then
|
||||
__java_add VMS5 "$vm" 32
|
||||
__java_add HOMES5 "$HOME/opt/jvm32/$vm" 32
|
||||
|
@ -66,8 +69,8 @@ function __java_compute_vms() {
|
|||
done
|
||||
array_from_lines vms "$(list_dirs "$HOME/opt/jvm32" "j2sdk1.4.2*" | LANG=C sort -r)"
|
||||
for vm in "${vms[@]}"; do
|
||||
__java_add VMS14 "$vm" 32
|
||||
__java_add HOMES14 "$HOME/opt/jvm32/$vm" 32
|
||||
__java_add VMS1_4 "$vm" 32
|
||||
__java_add HOMES1_4 "$HOME/opt/jvm32/$vm" 32
|
||||
done
|
||||
array_from_lines vms "$(list_dirs "$HOME/opt/jvm32" "jdk1.5.*" | LANG=C sort -r)"
|
||||
for vm in "${vms[@]}"; do
|
||||
|
@ -106,6 +109,14 @@ function __java_compute_vms() {
|
|||
__java_add HOMES8 "$HOME/opt/jvm64/$vm" 64
|
||||
fi
|
||||
done
|
||||
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
|
||||
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
|
||||
|
@ -126,13 +137,18 @@ function __java_compute_vms() {
|
|||
__java_add VMS8 "$vm" 64
|
||||
__java_add HOMES8 "$HOME/opt/jvm64/$vm" 64
|
||||
done
|
||||
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
|
||||
# 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
|
||||
__java_add VMS14 "$vm"
|
||||
__java_add HOMES14 "$HOME/opt/$vm"
|
||||
__java_add VMS1_4 "$vm"
|
||||
__java_add HOMES1_4 "$HOME/opt/$vm"
|
||||
elif [ "$v" == 1.5 ]; then
|
||||
__java_add VMS5 "$vm"
|
||||
__java_add HOMES5 "$HOME/opt/$vm"
|
||||
|
@ -147,10 +163,18 @@ function __java_compute_vms() {
|
|||
__java_add HOMES8 "$HOME/opt/$vm"
|
||||
fi
|
||||
done
|
||||
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
|
||||
array_from_lines vms "$(list_dirs "$HOME/opt" "j2sdk1.4.2*" | LANG=C sort -r)"
|
||||
for vm in "${vms[@]}"; do
|
||||
__java_add VMS14 "$vm"
|
||||
__java_add HOMES14 "$HOME/opt/$vm"
|
||||
__java_add VMS1_4 "$vm"
|
||||
__java_add HOMES1_4 "$HOME/opt/$vm"
|
||||
done
|
||||
array_from_lines vms "$(list_dirs "$HOME/opt" "jdk1.5.*" | LANG=C sort -r)"
|
||||
for vm in "${vms[@]}"; do
|
||||
|
@ -172,13 +196,18 @@ function __java_compute_vms() {
|
|||
__java_add VMS8 "$vm"
|
||||
__java_add HOMES8 "$HOME/opt/$vm"
|
||||
done
|
||||
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
|
||||
# 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
|
||||
__java_add VMS14 "$vm"
|
||||
__java_add HOMES14 "/opt/$vm"
|
||||
__java_add VMS1_4 "$vm"
|
||||
__java_add HOMES1_4 "/opt/$vm"
|
||||
elif [ "$v" == 1.5 ]; then
|
||||
__java_add VMS5 "$vm"
|
||||
__java_add HOMES5 "/opt/$vm"
|
||||
|
@ -193,10 +222,18 @@ function __java_compute_vms() {
|
|||
__java_add HOMES8 "/opt/$vm"
|
||||
fi
|
||||
done
|
||||
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
|
||||
array_from_lines vms "$(list_dirs "/opt" "j2sdk1.4.2*" | LANG=C sort -r)"
|
||||
for vm in "${vms[@]}"; do
|
||||
__java_add VMS14 "$vm"
|
||||
__java_add HOMES14 "/opt/$vm"
|
||||
__java_add VMS1_4 "$vm"
|
||||
__java_add HOMES1_4 "/opt/$vm"
|
||||
done
|
||||
array_from_lines vms "$(list_dirs "/opt" "jdk1.5.*" | LANG=C sort -r)"
|
||||
for vm in "${vms[@]}"; do
|
||||
|
@ -218,6 +255,11 @@ function __java_compute_vms() {
|
|||
__java_add VMS8 "$vm"
|
||||
__java_add HOMES8 "/opt/$vm"
|
||||
done
|
||||
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
|
||||
# Puis chercher dans les JVMs installées par le système dans
|
||||
# /usr/lib/jvm
|
||||
if check_sysinfos -d gentoo; then
|
||||
|
@ -226,8 +268,8 @@ function __java_compute_vms() {
|
|||
for vm in "${vms[@]}"; do
|
||||
v="${vm#sun-jdk-}"
|
||||
if [ "$v" == 1.4 ]; then
|
||||
__java_add VMS14 "$vm"
|
||||
__java_add HOMES14 "/usr/lib/jvm/$vm"
|
||||
__java_add VMS1_4 "$vm"
|
||||
__java_add HOMES1_4 "/usr/lib/jvm/$vm"
|
||||
elif [ "$v" == 1.5 ]; then
|
||||
__java_add VMS5 "$vm"
|
||||
__java_add HOMES5 "/usr/lib/jvm/$vm"
|
||||
|
@ -247,11 +289,13 @@ function __java_compute_vms() {
|
|||
array_from_lines vms "$(list_dirs /usr/lib/jvm)"
|
||||
for vm in "${vms[@]}"; do
|
||||
v="${vm%-sun}"
|
||||
v="${vm%-amd64}"
|
||||
v="${vm%-openjdk}"
|
||||
v="${v#java-}"
|
||||
v="${v#j2sdk}"
|
||||
if [ "$v" == 1.4 ]; then
|
||||
__java_add VMS14 "$vm"
|
||||
__java_add HOMES14 "/usr/lib/jvm/$vm"
|
||||
__java_add VMS1_4 "$vm"
|
||||
__java_add HOMES1_4 "/usr/lib/jvm/$vm"
|
||||
elif [ "$v" == 1.5 -o "$v" == 1.5.0 ]; then
|
||||
__java_add VMS5 "$vm"
|
||||
__java_add HOMES5 "/usr/lib/jvm/$vm"
|
||||
|
@ -264,11 +308,14 @@ function __java_compute_vms() {
|
|||
elif [ "$v" == 8 -o "$v" == 1.8 ]; then
|
||||
__java_add VMS8 "$vm"
|
||||
__java_add HOMES8 "/usr/lib/jvm/$vm"
|
||||
elif [ "$v" == 11 ]; then
|
||||
__java_add VMS11 "$vm"
|
||||
__java_add HOMES11 "/usr/lib/jvm/$vm"
|
||||
fi
|
||||
done
|
||||
if [ -d /usr/lib/j2sdk1.4-sun ]; then
|
||||
__java_add VMS14 j2sdk1.4-sun
|
||||
__java_add HOMES14 /usr/lib/j2sdk1.4-sun
|
||||
__java_add VMS1_4 j2sdk1.4-sun
|
||||
__java_add HOMES1_4 /usr/lib/j2sdk1.4-sun
|
||||
fi
|
||||
elif check_sysinfos -d redhatlike; then
|
||||
# XXX sur redhat
|
||||
|
@ -276,12 +323,12 @@ function __java_compute_vms() {
|
|||
fi
|
||||
elif check_sysinfos -s macosx; then
|
||||
if [ -d "/System/Library/Frameworks/JavaVM.framework/Versions/1.3" ]; then
|
||||
__java_add VMS13 "1.3"
|
||||
__java_add HOMES13 "/System/Library/Frameworks/JavaVM.framework/Versions/1.3/Home"
|
||||
__java_add VMS1_3 "1.3"
|
||||
__java_add HOMES1_3 "/System/Library/Frameworks/JavaVM.framework/Versions/1.3/Home"
|
||||
fi
|
||||
if [ -d "/System/Library/Frameworks/JavaVM.framework/Versions/1.4" ]; then
|
||||
__java_add VMS14 "1.4"
|
||||
__java_add HOMES14 "/System/Library/Frameworks/JavaVM.framework/Versions/1.4/Home"
|
||||
__java_add VMS1_4 "1.4"
|
||||
__java_add HOMES1_4 "/System/Library/Frameworks/JavaVM.framework/Versions/1.4/Home"
|
||||
fi
|
||||
if [ -d "/System/Library/Frameworks/JavaVM.framework/Versions/1.5" ]; then
|
||||
__java_add VMS5 "1.5"
|
||||
|
@ -305,7 +352,7 @@ function __java_compute_vms() {
|
|||
|
||||
function __java_dump_vms() {
|
||||
local v b i vms homes
|
||||
for v in 13 14 5 6 7 8; do
|
||||
for v in 1_3 1_4 5 6 7 8 11; do
|
||||
for b in "" 32 64; do
|
||||
vms="JAVA${b}_VMS${v}[@]"; vms=("${!vms}")
|
||||
homes="JAVA${b}_HOMES${v}[@]"; homes=("${!homes}")
|
||||
|
@ -336,7 +383,7 @@ function __java_select_vms() {
|
|||
}
|
||||
|
||||
function __java_select() {
|
||||
# Sélectionner la version de java $1 (qui peut être 13, 14, 5, 6, 7 ou 8)
|
||||
# Sélectionner la version de java $1 (qui peut être 1_3, 1_4, 5, 6, 7, 8 ou 11)
|
||||
# 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.
|
||||
|
@ -380,8 +427,8 @@ function __java_select() {
|
|||
|
||||
function __java_select_default() {
|
||||
# Sélectionner la version de java par défaut. Si JAVA_HOME est défini,
|
||||
# prendre cette valeur. Sinon, essayer dans l'ordre 5, 6, 7, 8, puis 14
|
||||
# la version 13 n'est jamais sélectionnée automatiquement
|
||||
# prendre cette valeur. Sinon, essayer dans l'ordre 5, 6, 7, 8, 11 puis 1_4
|
||||
# la version 1_3 n'est jamais sélectionnée automatiquement
|
||||
if [ -n "$JAVA_HOME" ]; then
|
||||
export JAVA_HOME # s'assurer que cette variable est exportée
|
||||
export JAVA="$JAVA_HOME/bin/java"
|
||||
|
@ -392,7 +439,7 @@ function __java_select_default() {
|
|||
return 0
|
||||
fi
|
||||
local vm
|
||||
for vm in 5 6 7 8 14; do
|
||||
for vm in 5 6 7 8 11 1_4; do
|
||||
__java_select "$vm" && return 0
|
||||
done
|
||||
return 1
|
||||
|
@ -400,39 +447,44 @@ function __java_select_default() {
|
|||
|
||||
function select_java() {
|
||||
# sélectionner la version *minimum* de java correspondant à $1
|
||||
# $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+
|
||||
# $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+
|
||||
# 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
|
||||
1.3|1.3+|13|13+)
|
||||
for v in 13 14 5 6 7 8; do
|
||||
1.3|1.3+)
|
||||
for v in 1_3 1_4 5 6 7 8 11; do
|
||||
__java_select "$v" "$2" && return 0
|
||||
done
|
||||
;;
|
||||
1.4|1.4+|14|14+)
|
||||
for v in 14 5 6 7 8; do
|
||||
1.4|1.4+)
|
||||
for v in 1_4 5 6 7 8 11; do
|
||||
__java_select "$v" "$2" && return 0
|
||||
done
|
||||
;;
|
||||
1.5|1.5+|5|5+)
|
||||
for v in 5 6 7 8; do
|
||||
for v in 5 6 7 8 11; do
|
||||
__java_select "$v" "$2" && return 0
|
||||
done
|
||||
;;
|
||||
1.6|1.6+|6|6+)
|
||||
for v in 6 7 8; do
|
||||
for v in 6 7 8 11; do
|
||||
__java_select "$v" "$2" && return 0
|
||||
done
|
||||
;;
|
||||
1.7|1.7+|7|7+)
|
||||
for v in 7 8; do
|
||||
for v in 7 8 11; do
|
||||
__java_select "$v" "$2" && return 0
|
||||
done
|
||||
;;
|
||||
1.8|1.8+|8|8+)
|
||||
for v in 8; do
|
||||
for v in 8 11; do
|
||||
__java_select "$v" "$2" && return 0
|
||||
done
|
||||
;;
|
||||
11|11+)
|
||||
for v in 11; do
|
||||
__java_select "$v" "$2" && return 0
|
||||
done
|
||||
;;
|
||||
|
@ -442,26 +494,26 @@ function select_java() {
|
|||
|
||||
function select_java_exact() {
|
||||
# sélectionner la version *exacte* de java correspondant à $1
|
||||
# $1== 1.3|1.4|1.5|1.6|1.7|1.8 pour une correspondance exacte
|
||||
# $1== 1.3+|1.4+|1.5+|1.6+|1.7+|1.8+ pour une version minimum
|
||||
# $1 == 1.3|1.4|1.5|1.6|1.7|1.8|11 pour une correspondance exacte
|
||||
# $1 == 1.3+|1.4+|1.5+|1.6+|1.7+|1.8+|11+ pour une version minimum
|
||||
# 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
|
||||
1.3|13)
|
||||
__java_select 13 && return 0
|
||||
1.3)
|
||||
__java_select 1_3 && return 0
|
||||
;;
|
||||
1.3+|13+)
|
||||
for v in 13 14 5 6 7 8; do
|
||||
1.3+)
|
||||
for v in 1_3 1_4 5 6 7 8 11; do
|
||||
__java_select "$v" "$2" && return 0
|
||||
done
|
||||
;;
|
||||
1.4|14)
|
||||
__java_select 14 && return 0
|
||||
1.4)
|
||||
__java_select 1_4 && return 0
|
||||
;;
|
||||
1.4+|14+)
|
||||
for v in 14 5 6 7 8; do
|
||||
1.4+)
|
||||
for v in 1_4 5 6 7 8 11; do
|
||||
__java_select "$v" "$2" && return 0
|
||||
done
|
||||
;;
|
||||
|
@ -469,7 +521,7 @@ function select_java_exact() {
|
|||
__java_select 5 "$2" && return 0
|
||||
;;
|
||||
1.5+|5+)
|
||||
for v in 5 6 7 8; do
|
||||
for v in 5 6 7 8 11; do
|
||||
__java_select "$v" "$2" && return 0
|
||||
done
|
||||
;;
|
||||
|
@ -477,7 +529,7 @@ function select_java_exact() {
|
|||
__java_select 6 "$2" && return 0
|
||||
;;
|
||||
1.6+|6+)
|
||||
for v in 6 7 8; do
|
||||
for v in 6 7 8 11; do
|
||||
__java_select "$v" "$2" && return 0
|
||||
done
|
||||
;;
|
||||
|
@ -485,7 +537,7 @@ function select_java_exact() {
|
|||
__java_select 7 "$2" && return 0
|
||||
;;
|
||||
1.7+|7+)
|
||||
for v in 7 8; do
|
||||
for v in 7 8 11; do
|
||||
__java_select "$v" "$2" && return 0
|
||||
done
|
||||
;;
|
||||
|
@ -493,7 +545,15 @@ function select_java_exact() {
|
|||
__java_select 8 "$2" && return 0
|
||||
;;
|
||||
1.8+|8+)
|
||||
for v in 8; do
|
||||
for v in 8 11; do
|
||||
__java_select "$v" "$2" && return 0
|
||||
done
|
||||
;;
|
||||
11)
|
||||
__java_select 11 "$2" && return 0
|
||||
;;
|
||||
11+)
|
||||
for v in 11; do
|
||||
__java_select "$v" "$2" && return 0
|
||||
done
|
||||
;;
|
||||
|
@ -505,9 +565,9 @@ 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.
|
||||
# Si aucun argument n'est défini, on assume "DEFAULT 5 6 7 8 1.4"
|
||||
# Si aucun argument n'est défini, on assume "DEFAULT 5 6 7 8 11 1.4"
|
||||
local v
|
||||
[ -n "$*" ] || set -- DEFAULT 5 6 7 8 1.4
|
||||
[ -n "$*" ] || set -- DEFAULT 5 6 7 8 11 1.4
|
||||
for v in "$@"; do
|
||||
if [ "$v" == DEFAULT ]; then
|
||||
if [ -n "$JAVA_HOME" ]; then
|
||||
|
|
Loading…
Reference in New Issue