Basic support for Java 10
[sven/java-package.git] / lib / oracle-jre.sh
1 # Detect product
2 j2se_detect_oracle_j2re=oracle_j2re_detect
3 oracle_j2re_detect() {
4   j2se_release=0
5
6   # JRE 10 release candidate (oracle-java10-jre_10+46_amd64.deb)
7   if [[ $archive_name =~ ^jre-10(\.([0-9]+)\.([0-9]+)|\+[0-9]+)?_linux-x64_bin\.tar\.gz ]]
8   then
9       j2se_release=10
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       oracle_no_man_jre_bin_jre="appletviewer idlj java javaws jcontrol jjs jrunscript jweblauncher keytool orbd pack200 rmid rmiregistry servertool tnameserv unpack200"
15       oracle_jre_bin_hl=" "
16       oracle_jre_bin_jre=" "
17       oracle_jre_lib_hl=" "
18   fi
19
20   # JRE 9 GA release (jre-9.0.1_linux-x64_bin.tar.gz)
21   if [[ $archive_name =~ ^jre-9(\.([0-9]+)\.([0-9]+))?_linux-x64_bin\.tar\.gz ]]
22   then
23       j2se_release=9
24       j2se_update=${BASH_REMATCH[1]:-.0.0}
25       j2se_arch=x64
26       j2se_version_name="${j2se_release} version ${j2se_release}${j2se_update}"
27       j2se_version=${j2se_release}${j2se_update}${revision}
28   fi
29
30   # Update or GA release (jre-7u13-linux-x64.tar.gz)
31   if [[ $archive_name =~ ^jre-([0-8]+)(u([0-9]+))?-linux-(i586|x64|amd64)\.(bin|tar\.gz) ]]
32   then
33     j2se_release=${BASH_REMATCH[1]}
34     j2se_update=${BASH_REMATCH[3]}
35     j2se_arch=${BASH_REMATCH[4]}
36     if [[ $j2se_update != "" ]]
37     then
38       j2se_version_name="$j2se_release Update $j2se_update"
39       j2se_version=${j2se_release}u${j2se_update}${revision}
40     else
41       j2se_version_name="$j2se_release GA"
42       j2se_version=${j2se_release}${revision}
43     fi
44   fi
45
46   # Early Access Release (jre-8-ea-bin-b103-linux-x64-15_aug_2013.tar.gz)
47   if [[ $archive_name =~ ^jre-([0-8]+)(u([0-9]+))?-(ea|fcs)-bin-(b[0-9]+)-linux-(i586|x64|amd64).*\.(bin|tar\.gz) ]]
48   then
49     j2se_release=${BASH_REMATCH[1]}
50     j2se_update=${BASH_REMATCH[3]}
51     j2se_build=${BASH_REMATCH[5]}
52     j2se_arch=${BASH_REMATCH[6]}
53     if [[ $j2se_update != "" ]]
54     then
55       j2se_version_name="$j2se_release Update $j2se_update Early Access Release Build $j2se_build"
56       j2se_version=${j2se_release}u${j2se_update}~ea-build-${j2se_build}${revision}
57     else
58       j2se_version_name="$j2se_release Early Access Release Build $j2se_build"
59       j2se_version=${j2se_release}~ea-build-${j2se_build}${revision}
60     fi
61   fi
62
63   if [[ $j2se_release > 0 ]]
64   then
65     j2se_priority=$((310 + $j2se_release - 1))
66     j2se_expected_min_size=85 #Mb
67
68     # check if the architecture matches
69     let compatible=1
70
71     case "${DEB_BUILD_ARCH:-$DEB_BUILD_GNU_TYPE}" in
72       i386|i486-linux-gnu)
73         if [[ "$j2se_arch" != "i586" ]]; then compatible=0; fi
74         ;;
75       amd64|x86_64-linux-gnu)
76         if [[ "$j2se_arch" != "x64" && "$j2se_arch" != "amd64" ]]; then compatible=0; fi
77         ;;
78     esac
79
80     if [[ $compatible == 0 ]]
81     then
82       echo "The archive $archive_name is not supported on the ${DEB_BUILD_ARCH} architecture"
83       return
84     fi
85
86
87     cat << EOF
88
89 Detected product:
90     Java(TM) Runtime Environment (JRE)
91     Standard Edition, Version $j2se_version_name
92     Oracle(TM)
93 EOF
94     if read_yn "Is this correct [Y/n]: "; then
95       j2se_found=true
96       j2se_required_space=$(( $j2se_expected_min_size * 2 + 20 ))
97       j2se_vendor="oracle"
98       j2se_title="Java Platform, Standard Edition $j2se_release Runtime Environment"
99
100       j2se_install=oracle_j2re_install
101       j2se_remove=oracle_j2re_remove
102       j2se_jinfo=oracle_j2re_jinfo
103       j2se_control=oracle_j2re_control
104       oracle_jre_bin_hl="${oracle_jre_bin_hl:-java javaws keytool orbd pack200 rmid rmiregistry servertool tnameserv unpack200 policytool}"
105       oracle_jre_bin_jre="${oracle_jre_bin_jre:-javaws policytool}"
106       oracle_no_man_jre_bin_jre="${oracle_no_man_jre_bin_jre:-ControlPanel jcontrol}"
107       oracle_jre_lib_hl="${oracle_jre_lib_hl:-jexec}"
108       j2se_package="$j2se_vendor-java$j2se_release-jre"
109       j2se_run
110     fi
111   fi
112 }
113
114 oracle_j2re_install() {
115     cat << EOF
116 if [ ! -e "$jvm_base$j2se_name/debian/info" ]; then
117     exit 0
118 fi
119
120 install_alternatives $jvm_base$j2se_name/bin $oracle_jre_bin_hl
121 install_alternatives $jvm_base$j2se_name/bin $oracle_jre_bin_jre
122 install_no_man_alternatives $jvm_base$j2se_name/bin $oracle_no_man_jre_bin_jre
123 install_no_man_alternatives $jvm_base$j2se_name/lib $oracle_jre_lib_hl
124
125 if [[ "${j2se_release}" -lt "10" ]]; then
126     plugin_dir="$jvm_base$j2se_name/lib/$DEB_BUILD_ARCH"
127     for b in $browser_plugin_dirs;do
128         install_browser_plugin "/usr/lib/\$b/plugins" "libjavaplugin.so" "\$b-javaplugin.so" "\$plugin_dir/libnpjp2.so"
129     done
130 fi
131 EOF
132 }
133
134 oracle_j2re_remove() {
135     cat << EOF
136 if [ ! -e "$jvm_base$j2se_name/debian/info" ]; then
137     exit 0
138 fi
139
140 remove_alternatives $jvm_base$j2se_name/bin $oracle_jre_bin_hl
141 remove_alternatives $jvm_base$j2se_name/bin $oracle_jre_bin_jre
142 remove_alternatives $jvm_base$j2se_name/bin $oracle_no_man_jre_bin_jre
143 remove_alternatives $jvm_base$j2se_name/lib $oracle_jre_lib_hl
144
145 if [[ "${j2se_release}" -lt "10" ]]; then
146     plugin_dir="$jvm_base$j2se_name/lib/$DEB_BUILD_ARCH"
147     for b in $browser_plugin_dirs;do
148         remove_browser_plugin "\$b-javaplugin.so" "\$plugin_dir/libnpjp2.so"
149     done
150 fi
151 EOF
152 }
153
154 oracle_j2re_jinfo() {
155     cat << EOF
156 name=$j2se_name
157 priority=${priority_override:-$j2se_priority}
158 section=main
159 EOF
160     jinfos "hl" $jvm_base$j2se_name/bin/ $oracle_jre_bin_hl
161     jinfos "jre" $jvm_base$j2se_name/bin/ $oracle_jre_bin_jre
162     jinfos "jre" $jvm_base$j2se_name/bin/ $oracle_no_man_jre_bin_jre
163     jinfos "hl" $jvm_base$j2se_name/lib/ $oracle_jre_lib_hl
164     for b in $browser_plugin_dirs;do
165         echo "plugin $b-javaplugin.so $jvm_base$j2se_name/lib/$DEB_BUILD_ARCH/libnpjp2.so"
166     done
167 }
168
169 oracle_j2re_control() {
170     j2se_control
171     if [ "$create_cert_softlinks" == "true" ]; then
172         depends="ca-certificates-java"
173     fi
174     for i in `seq 5 ${j2se_release}`;
175     do
176         provides_runtime="${provides_runtime} java${i}-runtime,"
177         provides_headless="${provides_headless} java${i}-runtime-headless,"
178     done
179     cat << EOF
180 Package: $j2se_package
181 Architecture: $j2se_debian_arch
182 Depends: \${misc:Depends}, \${shlibs:Depends}, java-common, $depends
183 Recommends: netbase
184 Provides: java-virtual-machine, java-runtime, java2-runtime, $provides_runtime java-runtime-headless, java2-runtime-headless, $provides_headless java-browser-plugin
185 Description: $j2se_title
186  The Java(TM) SE Runtime Environment contains the Java virtual machine,
187  runtime class libraries, and Java application launcher that are
188  necessary to run programs written in the Java programming language.
189  It is not a development environment and does not contain development
190  tools such as compilers or debuggers.  For development tools, see the
191  Java SE Development Kit (JDK).
192  .
193  This package has been automatically created with java-package ($version).
194 EOF
195 }