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