adjust the expected min size for JDK 9 and prior releases
[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   # JDK 9 GA release (jdk-9.0.1_linux-x64_bin.tar.gz)
7   if [[ $archive_name =~ jdk-9(\.([0-9]+)\.([0-9]+))?_linux-x64_bin\.tar\.gz ]]
8   then
9       j2se_release=9
10       j2se_update=${BASH_REMATCH[1]:-.0.0}
11       j2se_arch=x64
12       j2se_version_name="${j2se_release} version ${j2se_release}${j2se_update}" 
13       j2se_version=${j2se_relase}${j2se_update}${revision}
14       j2se_expected_min_size=340 #Mb
15   fi
16
17   # Update or GA release (jdk-7u15-linux-i586.tar.gz)
18   if [[ $archive_name =~ jdk-([0-9]+)(u([0-9]+))?-linux-(i586|x64|amd64|arm-vfp-hflt)\.(bin|tar\.gz) ]]
19   then
20     j2se_release=${BASH_REMATCH[1]}
21     j2se_update=${BASH_REMATCH[3]}
22     j2se_arch=${BASH_REMATCH[4]}
23     if [[ $j2se_update != "" ]]
24     then
25       j2se_version_name="$j2se_release Update $j2se_update"
26       j2se_version=${j2se_release}u${j2se_update}${revision}
27     else
28       j2se_version_name="$j2se_release GA"
29       j2se_version=${j2se_release}${revision}
30     fi
31   fi
32
33   # Early Access Release (jdk-8-ea-bin-b103-linux-i586-15_aug_2013.tar.gz)
34   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) ]]
35   then
36     j2se_release=${BASH_REMATCH[1]}
37     j2se_update=${BASH_REMATCH[3]}
38     j2se_build=${BASH_REMATCH[6]}
39     j2se_arch=${BASH_REMATCH[7]}
40     if [[ $j2se_update != "" ]]
41     then
42       j2se_version_name="$j2se_release Update $j2se_update Early Access Release Build $j2se_build"
43       j2se_version=${j2se_release}u${j2se_update}~ea-build-${j2se_build}${revision}
44     else
45       j2se_version_name="$j2se_release Early Access Release Build $j2se_build"
46       j2se_version=${j2se_release}~ea-build-${j2se_build}${revision}
47     fi
48   fi
49
50   if [[ $j2se_release > 0 ]]
51   then
52     j2se_priority=$((310 + $j2se_release))
53     j2se_expected_min_size=${j2se_expected_min_size:-180} #Mb  
54
55     # check if the architecture matches
56     let compatible=1
57
58     case "${DEB_BUILD_ARCH:-$DEB_BUILD_GNU_TYPE}" in
59       i386|i486-linux-gnu)
60         if [[ "$j2se_arch" != "i586" ]]; then compatible=0; fi
61         ;;
62       amd64|x86_64-linux-gnu)
63         if [[ "$j2se_arch" != "x64" && "$j2se_arch" != "amd64" ]]; then compatible=0; fi
64         ;;
65       armhf|armel|arm-linux-gnueabihf|arm-linux-gnueabi)
66       case "$archive_name" in
67         "jdk-7u"[0-9]"-linux-arm-sfp.tar.gz") # SUPPORTED
68             j2se_version=1.7.0+update${archive_name:6:1}${revision}
69             j2se_expected_min_size=100 #Mb
70             j2se_priority=317
71             found=true
72             ;;
73         "jdk-7u"[0-9][0-9]"-linux-arm-sfp.tar.gz") # SUPPORTED
74             j2se_version=1.7.0+update${archive_name:6:2}${revision}
75             j2se_expected_min_size=60 #Mb
76             j2se_priority=317
77             found=true
78             ;;
79       esac
80       ;;
81     esac
82
83     if [[ $compatible == 0 ]]
84     then
85       echo "The archive $archive_name is not supported on the ${DEB_BUILD_ARCH} architecture"
86       return
87     fi
88
89
90     cat << EOF
91
92 Detected product:
93     Java(TM) Development Kit (JDK)
94     Standard Edition, Version $j2se_version_name
95     Oracle(TM)
96 EOF
97     if read_yn "Is this correct [Y/n]: "; then
98       j2se_found=true
99       j2se_required_space=$(( $j2se_expected_min_size * 2 + 20 ))
100       j2se_vendor="oracle"
101       j2se_title="Java Platform, Standard Edition $j2se_release Development Kit"
102
103       j2se_install=oracle_j2sdk_install
104       j2se_remove=oracle_j2sdk_remove
105       j2se_jinfo=oracle_j2sdk_jinfo
106       j2se_control=oracle_j2sdk_control
107       if [ "${DEB_BUILD_ARCH:0:3}" = "arm" ]; then
108         # javaws is not available for ARM
109         oracle_jre_bin_hl="java keytool orbd pack200 rmid rmiregistry servertool tnameserv unpack200 policytool"
110         oracle_jre_bin_jre="policytool"
111       else
112         oracle_jre_bin_hl="java javaws keytool orbd pack200 rmid rmiregistry servertool tnameserv unpack200 policytool"
113         oracle_jre_bin_jre="javaws policytool"
114       fi
115       if [ "${DEB_BUILD_ARCH:0:3}" != "arm" ]; then
116         oracle_no_man_jre_bin_jre="ControlPanel jcontrol"
117       fi
118       oracle_jre_lib_hl="jexec"
119       oracle_bin_jdk="appletviewer extcheck idlj jar jarsigner javac javadoc javah javap jcmd jconsole jdb jdeps jhat jinfo jmap jmc jps jrunscript jsadebugd jstack jstat jstatd jvisualvm native2ascii rmic schemagen serialver wsgen wsimport xjc"
120       j2se_package="$j2se_vendor-java$j2se_release-jdk"
121       j2se_run
122     fi
123   fi
124 }
125
126 oracle_j2sdk_install() {
127     cat << EOF
128 if [ ! -e "$jvm_base$j2se_name/debian/info" ]; then
129     exit 0
130 fi
131
132 install_alternatives $jvm_base$j2se_name/jre/bin $oracle_jre_bin_hl
133 install_alternatives $jvm_base$j2se_name/jre/bin $oracle_jre_bin_jre
134 if [ -n "$oracle_no_man_jre_bin_jre" ]; then
135     install_no_man_alternatives $jvm_base$j2se_name/jre/bin $oracle_no_man_jre_bin_jre
136 fi
137 install_no_man_alternatives $jvm_base$j2se_name/jre/lib $oracle_jre_lib_hl
138 install_alternatives $jvm_base$j2se_name/bin $oracle_bin_jdk
139
140 # No plugin for ARM architecture yet
141 if [ "${DEB_BUILD_ARCH:0:3}" != "arm" ]; then
142 plugin_dir="$jvm_base$j2se_name/jre/lib/$DEB_BUILD_ARCH"
143 for b in $browser_plugin_dirs;do
144     install_browser_plugin "/usr/lib/\$b/plugins" "libjavaplugin.so" "\$b-javaplugin.so" "\$plugin_dir/libnpjp2.so"
145 done
146 fi
147 EOF
148 }
149
150 oracle_j2sdk_remove() {
151     cat << EOF
152 if [ ! -e "$jvm_base$j2se_name/debian/info" ]; then
153     exit 0
154 fi
155
156 remove_alternatives $jvm_base$j2se_name/jre/bin $oracle_jre_bin_hl
157 remove_alternatives $jvm_base$j2se_name/jre/bin $oracle_jre_bin_jre
158 if [ -n "$oracle_no_man_jre_bin_jre" ]; then
159     remove_alternatives $jvm_base$j2se_name/jre/bin $oracle_no_man_jre_bin_jre
160 fi
161 remove_alternatives $jvm_base$j2se_name/jre/lib $oracle_jre_lib_hl
162 remove_alternatives $jvm_base$j2se_name/bin $oracle_bin_jdk
163
164 # No plugin for ARM architecture yet
165 if [ "${DEB_BUILD_ARCH:0:3}" != "arm" ]; then
166 plugin_dir="$jvm_base$j2se_name/jre/lib/$DEB_BUILD_ARCH"
167 for b in $browser_plugin_dirs;do
168     remove_browser_plugin "\$b-javaplugin.so" "\$plugin_dir/libnpjp2.so"
169 done
170 fi
171 EOF
172 }
173
174 oracle_j2sdk_jinfo() {
175     cat << EOF
176 name=$j2se_name
177 priority=${priority_override:-$j2se_priority}
178 section=main
179 EOF
180     jinfos "hl" $jvm_base$j2se_name/jre/bin/ $oracle_jre_bin_hl
181     jinfos "jre" $jvm_base$j2se_name/jre/bin/ $oracle_jre_bin_jre
182     if [ -n "$oracle_no_man_jre_bin_jre" ]; then
183         jinfos "jre" $jvm_base$j2se_name/jre/bin/ $oracle_no_man_jre_bin_jre
184     fi
185     jinfos "hl" $jvm_base$j2se_name/jre/lib/ $oracle_jre_lib_hl
186     jinfos "jdk" $jvm_base$j2se_name/bin/ $oracle_bin_jdk
187     if [ "${DEB_BUILD_ARCH:0:3}" != "arm" ]; then
188         for b in $browser_plugin_dirs;do
189             echo "plugin iceweasel-javaplugin.so $jvm_base$j2se_name/jre/lib/$DEB_BUILD_ARCH/libnpjp2.so"
190         done
191     fi
192 }
193
194 oracle_j2sdk_control() {
195     build_depends="libasound2, libgl1-mesa-glx, libgtk2.0-0, libxslt1.1, libxtst6, libxxf86vm1"
196     j2se_control
197     java_browser_plugin="java-browser-plugin, "
198     depends="\${shlibs:Depends}"
199     if [ "${DEB_BUILD_ARCH:0:3}" = "arm" -a "${j2se_arch}" != "arm-vfp-hflt" ]; then
200         # ARM is only softfloat ATM so if building on armhf
201         # force the dependencies to pickup cross platform fu
202         if [ "${DEB_BUILD_ARCH}" == "armhf" ]; then
203             depends="libc6-armel, libsfgcc1, libsfstdc++6"
204         fi
205         # No browser on ARM yet
206         java_browser_plugin=""
207     fi
208     if [ "$create_cert_softlinks" == "true" ]; then
209         depends="$depends, ca-certificates-java"
210     fi
211     for i in `seq 5 ${j2se_release}`;
212     do
213         provides_runtime="${provides_runtime} java${i}-runtime,"
214         provides_headless="${provides_headless} java${i}-runtime-headless,"
215         provides_sdk="${provides_sdk} java${i}-sdk,"
216     done
217     cat << EOF
218 Package: $j2se_package
219 Architecture: $j2se_debian_arch
220 Depends: \${misc:Depends}, java-common, $depends
221 Recommends: netbase
222 Provides: java-virtual-machine, java-runtime, java2-runtime, $provides_runtime $java_browser_plugin java-compiler, java2-compiler, java-runtime-headless, java2-runtime-headless, $provides_headless java-sdk, java2-sdk, $provides_sdk
223 Description: $j2se_title
224  The Java(TM) SE JDK is a development environment for building
225  applications, applets, and components that can be deployed on the
226  Java(TM) platform.
227  .
228  The Java(TM) SE JDK software includes tools useful for developing and
229  testing programs written in the Java programming language and running
230  on the Java platform. These tools are designed to be used from the
231  command line. Except for appletviewer, these tools do not provide a
232  graphical user interface.
233  .
234  This package has been automatically created with java-package ($version).
235 EOF
236 }