apply patch to honor --revision argument
[sven/java-package.git] / lib / oracle-jdk.sh
1 # Detect product
2 j2se_detect_oracle_j2sdk=oracle_j2sdk_detect
3 oracle_j2sdk_detect() {
4   j2se_release=0
5
6   # Update or GA release (jdk-7u15-linux-i586.tar.gz)
7   if [[ $archive_name =~ jdk-([0-9]+)(u([0-9]+))?-linux-(i586|x64|amd64|arm-vfp-hflt)\.(bin|tar\.gz) ]]
8   then
9     j2se_release=${BASH_REMATCH[1]}
10     j2se_update=${BASH_REMATCH[3]}
11     j2se_arch=${BASH_REMATCH[4]}
12     if [[ $j2se_update != "" ]]
13     then
14       j2se_version_name="$j2se_release Update $j2se_update"
15       j2se_version=${j2se_release}u${j2se_update}${revision}
16     else
17       j2se_version_name="$j2se_release GA"
18       j2se_version=${j2se_release}${revision}
19     fi
20   fi
21
22   # Early Access Release (jdk-8-ea-bin-b103-linux-i586-15_aug_2013.tar.gz)
23   if [[ $archive_name =~ jdk-([0-9]+)(u([0-9]+))?-(ea|fcs)(-bin)?-(b[0-9]+)-linux-(i586|x64|amd64|arm-vfp-hflt).*\.(bin|tar\.gz) ]]
24   then
25     j2se_release=${BASH_REMATCH[1]}
26     j2se_update=${BASH_REMATCH[3]}
27     j2se_build=${BASH_REMATCH[6]}
28     j2se_arch=${BASH_REMATCH[7]}
29     if [[ $j2se_update != "" ]]
30     then
31       j2se_version_name="$j2se_release Update $j2se_update Early Access Release Build $j2se_build"
32       j2se_version=${j2se_release}u${j2se_update}~ea-build-${j2se_build}${revision}
33     else
34       j2se_version_name="$j2se_release Early Access Release Build $j2se_build"
35       j2se_version=${j2se_release}~ea-build-${j2se_build}${revision}
36     fi
37   fi
38
39   if [[ $j2se_release > 0 ]]
40   then
41     j2se_priority=$((310 + $j2se_release))
42     j2se_expected_min_size=130 #Mb
43
44     # check if the architecture matches
45     let compatible=1
46
47     case "${DEB_BUILD_ARCH:-$DEB_BUILD_GNU_TYPE}" in
48       i386|i486-linux-gnu)
49         if [[ "$j2se_arch" != "i586" ]]; then compatible=0; fi
50         ;;
51       amd64|x86_64-linux-gnu)
52         if [[ "$j2se_arch" != "x64" && "$j2se_arch" != "amd64" ]]; then compatible=0; fi
53         ;;
54       armhf|armel|arm-linux-gnueabihf|arm-linux-gnueabi)
55       case "$archive_name" in
56         "jdk-7u"[0-9]"-linux-arm-sfp.tar.gz") # SUPPORTED
57             j2se_version=1.7.0+update${archive_name:6:1}${revision}
58             j2se_expected_min_size=100 #Mb
59             j2se_priority=317
60             found=true
61             ;;
62         "jdk-7u"[0-9][0-9]"-linux-arm-sfp.tar.gz") # SUPPORTED
63             j2se_version=1.7.0+update${archive_name:6:2}${revision}
64             j2se_expected_min_size=60 #Mb
65             j2se_priority=317
66             found=true
67             ;;
68       esac
69       ;;
70     esac
71
72     if [[ $compatible == 0 ]]
73     then
74       echo "The archive $archive_name is not supported on the ${DEB_BUILD_ARCH} architecture"
75       return
76     fi
77     
78     
79     cat << EOF
80
81 Detected product:
82     Java(TM) Development Kit (JDK)
83     Standard Edition, Version $j2se_version_name
84     Oracle(TM)
85 EOF
86     if read_yn "Is this correct [Y/n]: "; then
87       j2se_found=true
88       j2se_required_space=$(( $j2se_expected_min_size * 2 + 20 ))
89       j2se_vendor="oracle"
90       j2se_title="Java™ Platform, Standard Edition $j2se_release Development Kit"
91
92       j2se_install=oracle_j2sdk_install
93       j2se_remove=oracle_j2sdk_remove
94       j2se_jinfo=oracle_j2sdk_jinfo
95       if [ "${DEB_BUILD_ARCH:0:3}" = "arm" ]; then
96         # javaws is not available for ARM
97         oracle_jre_bin_hl="java keytool orbd pack200 rmid rmiregistry servertool tnameserv unpack200 policytool"
98         oracle_jre_bin_jre="policytool"
99       else
100         oracle_jre_bin_hl="java javaws keytool orbd pack200 rmid rmiregistry servertool tnameserv unpack200 policytool"
101         oracle_jre_bin_jre="javaws policytool"
102       fi
103       if [ "${DEB_BUILD_ARCH:0:3}" != "arm" ]; then
104         oracle_no_man_jre_bin_jre="ControlPanel"
105       fi
106       oracle_jre_lib_hl="jexec"
107       oracle_bin_jdk="appletviewer extcheck idlj jar jarsigner javac javadoc javah javap jcmd jconsole jdb jdeps jhat jinfo jmap jps jrunscript jsadebugd jstack jstat jstatd native2ascii rmic schemagen serialver wsgen wsimport xjc"
108       j2sdk_run
109     fi
110   fi
111 }
112
113 oracle_j2sdk_install() {
114     cat << EOF
115 if [ ! -e "$jvm_base$j2se_name/debian/info" ]; then
116     exit 0
117 fi
118
119 install_alternatives $jvm_base$j2se_name/jre/bin $oracle_jre_bin_hl
120 install_alternatives $jvm_base$j2se_name/jre/bin $oracle_jre_bin_jre
121 if [ -n "$oracle_no_man_jre_bin_jre" ]; then
122     install_no_man_alternatives $jvm_base$j2se_name/jre/bin $oracle_no_man_jre_bin_jre
123 fi
124 install_no_man_alternatives $jvm_base$j2se_name/jre/lib $oracle_jre_lib_hl
125 install_alternatives $jvm_base$j2se_name/bin $oracle_bin_jdk
126
127 # No plugin for ARM architecture yet
128 if [ "${DEB_BUILD_ARCH:0:3}" != "arm" ]; then
129 plugin_dir="$jvm_base$j2se_name/jre/lib/$DEB_BUILD_ARCH"
130 for b in $browser_plugin_dirs;do
131     install_browser_plugin "/usr/lib/\$b/plugins" "libjavaplugin.so" "\$b-javaplugin.so" "\$plugin_dir/libnpjp2.so"
132 done
133 fi
134 EOF
135 }
136
137 oracle_j2sdk_remove() {
138     cat << EOF
139 if [ ! -e "$jvm_base$j2se_name/debian/info" ]; then
140     exit 0
141 fi
142
143 remove_alternatives $jvm_base$j2se_name/jre/bin $oracle_jre_bin_hl
144 remove_alternatives $jvm_base$j2se_name/jre/bin $oracle_jre_bin_jre
145 if [ -n "$oracle_no_man_jre_bin_jre" ]; then
146     remove_alternatives $jvm_base$j2se_name/jre/bin $oracle_no_man_jre_bin_jre
147 fi
148 remove_alternatives $jvm_base$j2se_name/jre/lib $oracle_jre_lib_hl
149 remove_alternatives $jvm_base$j2se_name/bin $oracle_bin_jdk
150
151 # No plugin for ARM architecture yet
152 if [ "${DEB_BUILD_ARCH:0:3}" != "arm" ]; then
153 plugin_dir="$jvm_base$j2se_name/jre/lib/$DEB_BUILD_ARCH"
154 for b in $browser_plugin_dirs;do
155     remove_browser_plugin "\$b-javaplugin.so" "\$plugin_dir/libnpjp2.so"
156 done
157 fi
158 EOF
159 }
160
161 oracle_j2sdk_jinfo() {
162     cat << EOF
163 name=$j2se_name
164 priority=$j2se_priority
165 section=main
166 EOF
167     jinfos "hl" $jvm_base$j2se_name/jre/bin/ $oracle_jre_bin_hl
168     jinfos "jre" $jvm_base$j2se_name/jre/bin/ $oracle_jre_bin_jre
169     if [ -n "$oracle_no_man_jre_bin_jre" ]; then
170         jinfos "jre" $jvm_base$j2se_name/jre/bin/ $oracle_no_man_jre_bin_jre
171     fi
172     jinfos "hl" $jvm_base$j2se_name/jre/lib/ $oracle_jre_lib_hl
173     jinfos "jdk" $jvm_base$j2se_name/bin/ $oracle_bin_jdk
174     if [ "${DEB_BUILD_ARCH:0:3}" != "arm" ]; then
175         for b in $browser_plugin_dirs;do
176             echo "plugin iceweasel-javaplugin.so $jvm_base$j2se_name/jre/lib/$DEB_BUILD_ARCH/libnpjp2.so"
177         done
178     fi
179 }