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