Add {mozilla,firefox}-javaplugin.so for update-java-alternatives.
[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|amd64)\.(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=85 #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" && "$j2se_arch" != "amd64" ]]; 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 install_browser_plugin "/usr/lib/mozilla/plugins" "libjavaplugin.so" "mozilla-javaplugin.so" "\$plugin_dir/libnpjp2.so"
73 install_browser_plugin "/usr/lib/firefox/plugins" "libjavaplugin.so" "firefox-javaplugin.so" "\$plugin_dir/libnpjp2.so"
74 EOF
75 }
76
77 oracle_j2re_remove() {
78     cat << EOF
79 if [ ! -e "$jvm_base$j2se_name/debian/info" ]; then
80     exit 0
81 fi
82
83 remove_alternatives $jvm_base$j2se_name/bin $oracle_jre_bin_hl
84 remove_alternatives $jvm_base$j2se_name/bin $oracle_jre_bin_jre
85 remove_alternatives $jvm_base$j2se_name/bin $oracle_no_man_jre_bin_jre
86 remove_alternatives $jvm_base$j2se_name/lib $oracle_jre_lib_hl
87
88 plugin_dir="$jvm_base$j2se_name/lib/$DEB_BUILD_ARCH"
89 remove_browser_plugin "iceweasel-javaplugin.so" "\$plugin_dir/libnpjp2.so"
90 remove_browser_plugin "chromium-javaplugin.so" "\$plugin_dir/libnpjp2.so"
91 remove_browser_plugin "mozilla-javaplugin.so" "\$plugin_dir/libnpjp2.so"
92 remove_browser_plugin "firefox-javaplugin.so" "\$plugin_dir/libnpjp2.so"
93 EOF
94 }
95
96 oracle_j2re_jinfo() {
97     cat << EOF
98 name=$j2se_name
99 priority=$j2se_priority
100 section=main
101 EOF
102     jinfos "hl" $jvm_base$j2se_name/bin/ $oracle_jre_bin_hl
103     jinfos "jre" $jvm_base$j2se_name/bin/ $oracle_jre_bin_jre
104     jinfos "jre" $jvm_base$j2se_name/bin/ $oracle_no_man_jre_bin_jre
105     jinfos "hl" $jvm_base$j2se_name/lib/ $oracle_jre_lib_hl
106     echo "plugin iceweasel-javaplugin.so $jvm_base$j2se_name/lib/$DEB_BUILD_ARCH/libnpjp2.so"
107     echo "plugin chromium-javaplugin.so $jvm_base$j2se_name/lib/$DEB_BUILD_ARCH/libnpjp2.so"
108     echo "plugin mozilla-javaplugin.so $jvm_base$j2se_name/lib/$DEB_BUILD_ARCH/libnpjp2.so"
109     echo "plugin firefox-javaplugin.so $jvm_base$j2se_name/lib/$DEB_BUILD_ARCH/libnpjp2.so"
110 }
111