4f408ff3e68d7eedf82cfdaeca24b4bee37c54c5
[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 9 GA release (jre-9.0.1_linux-x64_bin.tar.gz)
7   if [[ $archive_name =~ ^jre-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   fi
15
16   # Update or GA release (jre-7u13-linux-x64.tar.gz)
17   if [[ $archive_name =~ ^jre-([0-9]+)(u([0-9]+))?-linux-(i586|x64|amd64)\.(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 (jre-8-ea-bin-b103-linux-x64-15_aug_2013.tar.gz)
33   if [[ $archive_name =~ ^jre-([0-9]+)(u([0-9]+))?-(ea|fcs)-bin-(b[0-9]+)-linux-(i586|x64|amd64).*\.(bin|tar\.gz) ]]
34   then
35     j2se_release=${BASH_REMATCH[1]}
36     j2se_update=${BASH_REMATCH[3]}
37     j2se_build=${BASH_REMATCH[5]}
38     j2se_arch=${BASH_REMATCH[6]}
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 - 1))
52     j2se_expected_min_size=85 #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     esac
65
66     if [[ $compatible == 0 ]]
67     then
68       echo "The archive $archive_name is not supported on the ${DEB_BUILD_ARCH} architecture"
69       return
70     fi
71
72
73     cat << EOF
74
75 Detected product:
76     Java(TM) Runtime Environment (JRE)
77     Standard Edition, Version $j2se_version_name
78     Oracle(TM)
79 EOF
80     if read_yn "Is this correct [Y/n]: "; then
81       j2se_found=true
82       j2se_required_space=$(( $j2se_expected_min_size * 2 + 20 ))
83       j2se_vendor="oracle"
84       j2se_title="Java Platform, Standard Edition $j2se_release Runtime Environment"
85
86       j2se_install=oracle_j2re_install
87       j2se_remove=oracle_j2re_remove
88       j2se_jinfo=oracle_j2re_jinfo
89       j2se_control=oracle_j2re_control
90       oracle_jre_bin_hl="java javaws keytool orbd pack200 rmid rmiregistry servertool tnameserv unpack200 policytool"
91       oracle_jre_bin_jre="javaws policytool"
92       oracle_no_man_jre_bin_jre="ControlPanel jcontrol"
93       oracle_jre_lib_hl="jexec"
94       j2se_package="$j2se_vendor-java$j2se_release-jre"
95       j2se_run
96     fi
97   fi
98 }
99
100 oracle_j2re_install() {
101     cat << EOF
102 if [ ! -e "$jvm_base$j2se_name/debian/info" ]; then
103     exit 0
104 fi
105
106 install_alternatives $jvm_base$j2se_name/bin $oracle_jre_bin_hl
107 install_alternatives $jvm_base$j2se_name/bin $oracle_jre_bin_jre
108 install_no_man_alternatives $jvm_base$j2se_name/bin $oracle_no_man_jre_bin_jre
109 install_no_man_alternatives $jvm_base$j2se_name/lib $oracle_jre_lib_hl
110
111 plugin_dir="$jvm_base$j2se_name/lib/$DEB_BUILD_ARCH"
112 for b in $browser_plugin_dirs;do
113     install_browser_plugin "/usr/lib/\$b/plugins" "libjavaplugin.so" "\$b-javaplugin.so" "\$plugin_dir/libnpjp2.so"
114 done
115 EOF
116 }
117
118 oracle_j2re_remove() {
119     cat << EOF
120 if [ ! -e "$jvm_base$j2se_name/debian/info" ]; then
121     exit 0
122 fi
123
124 remove_alternatives $jvm_base$j2se_name/bin $oracle_jre_bin_hl
125 remove_alternatives $jvm_base$j2se_name/bin $oracle_jre_bin_jre
126 remove_alternatives $jvm_base$j2se_name/bin $oracle_no_man_jre_bin_jre
127 remove_alternatives $jvm_base$j2se_name/lib $oracle_jre_lib_hl
128
129 plugin_dir="$jvm_base$j2se_name/lib/$DEB_BUILD_ARCH"
130 for b in $browser_plugin_dirs;do
131     remove_browser_plugin "\$b-javaplugin.so" "\$plugin_dir/libnpjp2.so"
132 done
133 EOF
134 }
135
136 oracle_j2re_jinfo() {
137     cat << EOF
138 name=$j2se_name
139 priority=${priority_override:-$j2se_priority}
140 section=main
141 EOF
142     jinfos "hl" $jvm_base$j2se_name/bin/ $oracle_jre_bin_hl
143     jinfos "jre" $jvm_base$j2se_name/bin/ $oracle_jre_bin_jre
144     jinfos "jre" $jvm_base$j2se_name/bin/ $oracle_no_man_jre_bin_jre
145     jinfos "hl" $jvm_base$j2se_name/lib/ $oracle_jre_lib_hl
146     for b in $browser_plugin_dirs;do
147         echo "plugin $b-javaplugin.so $jvm_base$j2se_name/lib/$DEB_BUILD_ARCH/libnpjp2.so"
148     done
149 }
150
151 oracle_j2re_control() {
152     j2se_control
153     if [ "$create_cert_softlinks" == "true" ]; then
154         depends="ca-certificates-java"
155     fi
156     for i in `seq 5 ${j2se_release}`;
157     do
158         provides_runtime="${provides_runtime} java${i}-runtime,"
159         provides_headless="${provides_headless} java${i}-runtime-headless,"
160     done
161     cat << EOF
162 Package: $j2se_package
163 Architecture: $j2se_debian_arch
164 Depends: \${misc:Depends}, \${shlibs:Depends}, java-common, $depends
165 Recommends: netbase
166 Provides: java-virtual-machine, java-runtime, java2-runtime, $provides_runtime java-runtime-headless, java2-runtime-headless, $provides_headless java-browser-plugin
167 Description: $j2se_title
168  The Java(TM) SE Runtime Environment contains the Java virtual machine,
169  runtime class libraries, and Java application launcher that are
170  necessary to run programs written in the Java programming language.
171  It is not a development environment and does not contain development
172  tools such as compilers or debuggers.  For development tools, see the
173  Java SE Development Kit (JDK).
174  .
175  This package has been automatically created with java-package ($version).
176 EOF
177 }