Improved the detection of the JRE/JDK version (supports 2 digits Java 7 updates)...
[sven/java-package.git] / lib / oracle-j2re.sh
1 # Detect product
2 j2se_detect_oracle_j2re=oracle_j2re_detect
3 oracle_j2re_detect() {
4
5   if [[ $archive_name =~ jre-([0-9]+)u([0-9]+)-linux-(i586|x64)\.(bin|tar\.gz) ]]
6   then
7     j2se_release=${BASH_REMATCH[1]}
8     j2se_update=${BASH_REMATCH[2]}
9     j2se_arch=${BASH_REMATCH[3]}
10     j2se_version=$j2se_release.$j2se_update
11     j2se_priority=$((310 + $j2se_release - 1))
12     j2se_expected_min_size=95 #Mb
13
14     # check if the architecture matches
15     let compatible=1
16   
17     case "${DEB_BUILD_ARCH:-$DEB_BUILD_GNU_TYPE}" in
18       i386|i486-linux-gnu)
19         if [[ "$j2se_arch" != "i586" ]]; then compatible=0; fi
20         ;;
21       amd64|x86_64-linux-gnu)
22         if [[ "$j2se_arch" != "x64" ]]; then compatible=0; fi
23         ;;
24     esac
25
26     if [[ $compatible == 0 ]]
27     then
28       echo "The archive $archive_name is not supported on the ${DEB_BUILD_ARCH} architecture"
29       return
30     fi
31
32
33         cat << EOF
34
35 Detected product:
36     Java(TM) Runtime Environment (JRE)
37     Standard Edition, Version $j2se_release Update $j2se_update
38     Oracle(TM)
39 EOF
40         if read_yn "Is this correct [Y/n]: "; then
41             j2se_found=true
42             j2se_required_space=$(( $j2se_expected_min_size * 2 + 20 ))
43             j2se_vendor="oracle"
44             j2se_title="Java(TM) JRE, Standard Edition, Oracle(TM)"
45
46             j2se_install=oracle_j2re_install
47             j2se_remove=oracle_j2re_remove
48             j2se_jinfo=oracle_j2re_jinfo
49             oracle_jre_bin_hl="java javaws keytool orbd pack200 rmid rmiregistry servertool tnameserv unpack200 policytool"
50             oracle_jre_bin_jre="javaws policytool"
51             oracle_no_man_jre_bin_jre="ControlPanel"
52             oracle_jre_lib_hl="jexec"
53             j2re_run
54         fi
55   fi
56 }
57
58 oracle_j2re_install() {
59         cat << EOF
60 if [ ! -e "$jvm_base$j2se_name/debian/info" ]; then
61     exit 0
62 fi
63
64 install_alternatives $jvm_base$j2se_name/bin $oracle_jre_bin_hl
65 install_alternatives $jvm_base$j2se_name/bin $oracle_jre_bin_jre
66 install_no_man_alternatives $jvm_base$j2se_name/bin $oracle_no_man_jre_bin_jre
67 install_no_man_alternatives $jvm_base$j2se_name/lib $oracle_jre_lib_hl
68
69 plugin_dir="$jvm_base$j2se_name/lib/$DEB_BUILD_ARCH"
70 install_browser_plugin "/usr/lib/iceweasel/plugins" "libjavaplugin.so" "iceweasel-javaplugin.so" "\$plugin_dir/libnpjp2.so"
71 install_browser_plugin "/usr/lib/chromium/plugins" "libjavaplugin.so" "chromium-javaplugin.so" "\$plugin_dir/libnpjp2.so"
72 EOF
73 }
74
75 oracle_j2re_remove() {
76         cat << EOF
77 if [ ! -e "$jvm_base$j2se_name/debian/info" ]; then
78     exit 0
79 fi
80
81 remove_alternatives $jvm_base$j2se_name/bin $oracle_jre_bin_hl
82 remove_alternatives $jvm_base$j2se_name/bin $oracle_jre_bin_jre
83 remove_alternatives $jvm_base$j2se_name/bin $oracle_no_man_jre_bin_jre
84 remove_alternatives $jvm_base$j2se_name/lib $oracle_jre_lib_hl
85
86 plugin_dir="$jvm_base$j2se_name/lib/$DEB_BUILD_ARCH"
87 remove_browser_plugin "iceweasel-javaplugin.so" "\$plugin_dir/libnpjp2.so"
88 remove_browser_plugin "chromium-javaplugin.so" "\$plugin_dir/libnpjp2.so"
89 EOF
90 }
91
92 oracle_j2re_jinfo() {
93     cat << EOF
94 name=$j2se_name
95 priority=$j2se_priority
96 section=main
97 EOF
98     jinfos "hl" $jvm_base$j2se_name/bin/ $oracle_jre_bin_hl
99     jinfos "jre" $jvm_base$j2se_name/bin/ $oracle_jre_bin_jre
100     jinfos "jre" $jvm_base$j2se_name/bin/ $oracle_no_man_jre_bin_jre
101     jinfos "hl" $jvm_base$j2se_name/lib/ $oracle_jre_lib_hl
102     echo "plugin iceweasel-javaplugin.so $jvm_base$j2se_name/lib/$DEB_BUILD_ARCH/libnpjp2.so"
103     echo "plugin chromium-javaplugin.so $jvm_base$j2se_name/lib/$DEB_BUILD_ARCH/libnpjp2.so"
104 }
105