Add version matching code for JRE 9
[sven/java-package.git] / lib / oracle-server-jre.sh
1 # Detect product
2 j2se_detect_oracle_server_j2re=oracle_server_j2re_detect
3 oracle_server_j2re_detect() {
4   j2se_release=0
5
6   # Update or GA release (server-jre-8u74-linux-x64.tar.gz)
7   if [[ $archive_name =~ server-jre-([0-9]+)(u([0-9]+))?-linux-(i586|x64|amd64)\.(bin|tar\.gz) ]]
8   then
9     j2se_release=${BASH_REMATCH[1]}
10     j2se_update=${BASH_REMATCH[3]}
11     j2se_arch=${BASH_REMATCH[4]}
12     if [[ $j2se_update != "" ]]
13     then
14       j2se_version_name="$j2se_release Update $j2se_update"
15       j2se_version=${j2se_release}u${j2se_update}${revision}
16     else
17       j2se_version_name="$j2se_release GA"
18       j2se_version=${j2se_release}${revision}
19     fi
20   fi
21
22   # Early Access Release (jre-8-ea-bin-b103-linux-x64-15_aug_2013.tar.gz)
23   if [[ $archive_name =~ server-jre-([0-9]+)(u([0-9]+))?-(ea|fcs)-bin-(b[0-9]+)-linux-(i586|x64|amd64).*\.(bin|tar\.gz) ]]
24   then
25     j2se_release=${BASH_REMATCH[1]}
26     j2se_update=${BASH_REMATCH[3]}
27     j2se_build=${BASH_REMATCH[5]}
28     j2se_arch=${BASH_REMATCH[6]}
29     if [[ $j2se_update != "" ]]
30     then
31       j2se_version_name="$j2se_release Update $j2se_update Early Access Release Build $j2se_build"
32       j2se_version=${j2se_release}u${j2se_update}~ea-build-${j2se_build}${revision}
33     else
34       j2se_version_name="$j2se_release Early Access Release Build $j2se_build"
35       j2se_version=${j2se_release}~ea-build-${j2se_build}${revision}
36     fi
37   fi
38
39   if [[ $j2se_release > 0 ]]
40   then
41     j2se_priority=$((310 + $j2se_release - 1))
42     j2se_expected_min_size=85 #Mb
43
44     # check if the architecture matches
45     let compatible=1
46
47     case "${DEB_BUILD_ARCH:-$DEB_BUILD_GNU_TYPE}" in
48       i386|i486-linux-gnu)
49         if [[ "$j2se_arch" != "i586" ]]; then compatible=0; fi
50         ;;
51       amd64|x86_64-linux-gnu)
52         if [[ "$j2se_arch" != "x64" && "$j2se_arch" != "amd64" ]]; then compatible=0; fi
53         ;;
54     esac
55
56     if [[ $compatible == 0 ]]
57     then
58       echo "The archive $archive_name is not supported on the ${DEB_BUILD_ARCH} architecture"
59       return
60     fi
61
62
63     cat << EOF
64
65 Detected product:
66     Server Java(TM) Runtime Environment (JRE)
67     Standard Edition, Version $j2se_version_name
68     Oracle(TM)
69 EOF
70     if read_yn "Is this correct [Y/n]: "; then
71       j2se_found=true
72       j2se_required_space=$(( $j2se_expected_min_size * 2 + 20 ))
73       j2se_vendor="oracle"
74       j2se_title="Java Platform, Standard Edition $j2se_release Server Runtime Environment"
75
76       j2se_install=oracle_server_j2re_install
77       j2se_remove=oracle_server_j2re_remove
78       j2se_jinfo=oracle_server_j2re_jinfo
79       j2se_control=oracle_server_j2re_control
80       oracle_jre_bin_hl="java keytool orbd pack200 rmid rmiregistry servertool tnameserv unpack200 policytool"
81       oracle_jre_bin_jre="policytool"
82       oracle_jre_lib_hl="jexec"
83       j2se_package="$j2se_vendor-java$j2se_release-server-jre"
84       exlude_libs="appletviewer libawt_xawt.so libsplashscreen.so policytool"
85       j2se_run
86     fi
87   fi
88 }
89
90 oracle_server_j2re_install() {
91     cat << EOF
92 if [ ! -e "$jvm_base$j2se_name/debian/info" ]; then
93     exit 0
94 fi
95
96 install_alternatives $jvm_base$j2se_name/bin $oracle_jre_bin_hl
97 install_alternatives $jvm_base$j2se_name/bin $oracle_jre_bin_jre
98 install_no_man_alternatives $jvm_base$j2se_name/lib $oracle_jre_lib_hl
99 EOF
100 }
101
102 oracle_server_j2re_remove() {
103     cat << EOF
104 if [ ! -e "$jvm_base$j2se_name/debian/info" ]; then
105     exit 0
106 fi
107
108 remove_alternatives $jvm_base$j2se_name/bin $oracle_jre_bin_hl
109 remove_alternatives $jvm_base$j2se_name/bin $oracle_jre_bin_jre
110 remove_alternatives $jvm_base$j2se_name/lib $oracle_jre_lib_hl
111 EOF
112 }
113
114 oracle_server_j2re_jinfo() {
115     cat << EOF
116 name=$j2se_name
117 priority=${priority_override:-$j2se_priority}
118 section=main
119 EOF
120     jinfos "hl" $jvm_base$j2se_name/bin/ $oracle_jre_bin_hl
121     jinfos "jre" $jvm_base$j2se_name/bin/ $oracle_jre_bin_jre
122     jinfos "hl" $jvm_base$j2se_name/lib/ $oracle_jre_lib_hl
123 }
124
125 oracle_server_j2re_control() {
126     j2se_control
127     if [ "$create_cert_softlinks" == "true" ]; then
128         depends="ca-certificates-java"
129     fi
130     for i in `seq 5 ${j2se_release}`;
131     do
132         provides_headless="${provides_headless} java${i}-runtime-headless,"
133     done
134     cat << EOF
135 Package: $j2se_package
136 Architecture: $j2se_debian_arch
137 Depends: \${misc:Depends}, \${shlibs:Depends}, java-common, $depends
138 Recommends: netbase
139 Provides: java-runtime-headless, java2-runtime-headless, $provides_headless
140 Description: $j2se_title
141  The Java(TM) SE Server Runtime Environment contains the Java virtual machine,
142  runtime class libraries, and Java application launcher that are necessary to
143  run programs written in the Java programming language. It includes tools for
144  JVM monitoring and tools commonly required for server applications, but does
145  not include browser integration (the Java plug-in), auto-update, nor an
146  installer.
147  .
148  This package has been automatically created with java-package ($version).
149 EOF
150 }