Replaced tabs with spaces
[sven/java-package.git] / lib / oracle-j2sdk.sh
1 # Detect product
2 j2se_detect_oracle_j2sdk=oracle_j2sdk_detect
3 oracle_j2sdk_detect() {
4
5   if [[ $archive_name =~ jdk-([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))
12     j2se_expected_min_size=130 #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) Development Kit (JDK)
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) JDK, Standard Edition, Oracle(TM)"
45
46       j2se_install=oracle_j2sdk_install
47       j2se_remove=oracle_j2sdk_remove
48       j2se_jinfo=oracle_j2sdk_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       oracle_bin_jdk="appletviewer extcheck idlj jar jarsigner javac javadoc javah javap jconsole jdb jinfo jmap jps jsadebugd jstack jstat jstatd native2ascii rmic serialver"
54       j2sdk_run
55     fi
56   fi
57 }
58
59 oracle_j2sdk_install() {
60     cat << EOF
61 if [ ! -e "$jvm_base$j2se_name/debian/info" ]; then
62     exit 0
63 fi
64
65 install_alternatives $jvm_base$j2se_name/jre/bin $oracle_jre_bin_hl
66 install_alternatives $jvm_base$j2se_name/jre/bin $oracle_jre_bin_jre
67 install_no_man_alternatives $jvm_base$j2se_name/jre/bin $oracle_no_man_jre_bin_jre
68 install_no_man_alternatives $jvm_base$j2se_name/jre/lib $oracle_jre_lib_hl
69 install_alternatives $jvm_base$j2se_name/bin $oracle_bin_jdk
70
71 plugin_dir="$jvm_base$j2se_name/jre/lib/$DEB_BUILD_ARCH"
72 install_browser_plugin "/usr/lib/iceweasel/plugins" "libjavaplugin.so" "iceweasel-javaplugin.so" "\$plugin_dir/libnpjp2.so"
73 install_browser_plugin "/usr/lib/chromium/plugins" "libjavaplugin.so" "chromium-javaplugin.so" "\$plugin_dir/libnpjp2.so"
74 EOF
75 }
76
77 oracle_j2sdk_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/jre/bin $oracle_jre_bin_hl
84 remove_alternatives $jvm_base$j2se_name/jre/bin $oracle_jre_bin_jre
85 remove_alternatives $jvm_base$j2se_name/jre/bin $oracle_no_man_jre_bin_jre
86 remove_alternatives $jvm_base$j2se_name/jre/lib $oracle_jre_lib_hl
87 remove_alternatives $jvm_base$j2se_name/bin $oracle_bin_jdk
88
89 plugin_dir="$jvm_base$j2se_name/jre/lib/$DEB_BUILD_ARCH"
90 remove_browser_plugin "iceweasel-javaplugin.so" "\$plugin_dir/libnpjp2.so"
91 remove_browser_plugin "chromium-javaplugin.so" "\$plugin_dir/libnpjp2.so"
92 EOF
93 }
94
95 oracle_j2sdk_jinfo() {
96     cat << EOF
97 name=$j2se_name
98 priority=$j2se_priority
99 section=main
100 EOF
101     jinfos "hl" $jvm_base$j2se_name/jre/bin/ $oracle_jre_bin_hl
102     jinfos "jre" $jvm_base$j2se_name/jre/bin/ $oracle_jre_bin_jre
103     jinfos "jre" $jvm_base$j2se_name/jre/bin/ $oracle_no_man_jre_bin_jre
104     jinfos "hl" $jvm_base$j2se_name/jre/lib/ $oracle_jre_lib_hl
105     jinfos "jdk" $jvm_base$j2se_name/bin/ $oracle_bin_jdk
106     echo "plugin iceweasel-javaplugin.so $jvm_base$j2se_name/jre/lib/$DEB_BUILD_ARCH/libnpjp2.so"
107     echo "plugin chromium-javaplugin.so $jvm_base$j2se_name/jre/lib/$DEB_BUILD_ARCH/libnpjp2.so"
108 }