source: oracle-java9-installer/trunk/fuentes/debian/oracle-java9-installer.postinst @ 6532

Last change on this file since 6532 was 6532, checked in by mabarracus, 3 years ago

Update to 9.0.1 x64 version

  • Property svn:executable set to *
File size: 8.9 KB
Line 
1#!/bin/sh
2#jinstall - Command line script to easily add new java directories to
3#'alternatives'. This sets the java as default, and you can switch your
4#default java with update-java-alternatives
5#
6#Copyright 2014 Bruce.Ingalls at gmail & Alin Andrei <webupd8@gmail.com>
7#GPL v3 Affero license at http://www.gnu.org/
8#Downloads & discussion at http://www.webupd8.org/
9#Tested on Ubuntu Oneiric; should require few changes for other modern Unix systems
10#Currently tested only with JDK, not JRE.
11# Not fully internationalized, including japanese man pages
12
13set -e
14
15VER='0.6alpha'
16
17case $(dpkg --print-architecture) in
18'i386'|'i586'|'i686') arch=i386; dld=x86;
19  SHA256SUM_TGZ="6715edf6528612c859ac0ce81fa13eb147ea10b00bc9256840431954e0d0779a" #must be modified for each release
20  ;; 
21'amd64'  ) arch=amd64; dld=x64;
22  SHA256SUM_TGZ="2cdaf0ff92d0829b510edd883a4ac8322c02f2fc1beae95d048b6716076bc014" #must be modified for each release
23  ;; 
24*         )
25    echo "Please report to author unsupported platform '`uname -m`'.";
26    echo "Proceeding without web browser plugin support";
27    arch='';
28esac
29
30
31
32if [ ! $arch = "amd64" ]; then
33    J_DIR=jdk-9 #must be modified for each release
34    JAVA_VERSION_MAJOR=9 #
35    JAVA_VERSION_MINOR=125 #must be modified for each release
36    #FILENAME=jdk-${JAVA_VERSION_MAJOR}-ea+${JAVA_VERSION_MINOR}_linux-${dld}_bin.tar.gz
37    FILENAME=jdk-9-linux-${dld}.tar.gz
38else
39    J_DIR=jdk-9.0.1
40    JAVA_VERSION_MAJOR=9.0.1 #
41    JAVA_VERSION_MINOR=11 #must be modified for each release
42    FILENAME=jdk-9-linux-${dld}.tar.gz
43fi
44
45
46J_INSTALL_DIR=/usr/lib/jvm/java-9-oracle
47
48########Create dirs
49mkdir -p /var/cache/oracle-jdk9-installer
50mkdir -p /usr/lib/jvm
51mkdir -p /usr/lib/oracle-jdk9-installer-unpackdir
52#without this, an error is displayed if the folder doesn't exist:
53mkdir -p /usr/lib/mozilla/plugins
54#############
55
56
57
58. /usr/share/debconf/confmodule
59
60fp_exit_with_error() {
61        echo $1
62        echo "Oracle JDK 9 is NOT installed."
63        db_fset oracle-java9-installer/local seen false
64        exit 1
65}
66
67OLDDIR=/usr/lib/oracle-jdk9-installer-unpackdir
68NEWDIR=/var/cache/oracle-jdk9-installer
69
70safe_move() {
71        [ ! -f $OLDDIR/$1 ] || [ -f $NEWDIR/$1 ] || mv $OLDDIR/$1 $NEWDIR/$1 2> /dev/null || true
72        [ ! -f $OLDDIR/$1 ] || [ ! -f $NEWDIR/$1 ] || rm -f $OLDDIR/$1 2> /dev/null || true
73}
74
75ORACLE_DIR=/var/cache/oracle-jdk9-installer
76cd $ORACLE_DIR
77tar xzf $FILENAME || fp_exit_with_error "cannot unpack jdk9"
78# FIN Lliurex -------------------------------05/11/2013
79
80# Copy JDK to the right dir
81mv $J_DIR java-9-oracle
82rm -rf /usr/lib/jvm/java-9-oracle
83cp -rf java-9-oracle /usr/lib/jvm/
84
85# There's no javaws on arm
86if [ ! $arch = "arm" ]; then
87        # Install javaws-wrapper.sh
88        mv $J_INSTALL_DIR/bin/javaws $J_INSTALL_DIR/bin/javaws.real
89        install -m 755 javaws-wrapper.sh $J_INSTALL_DIR/bin/javaws
90fi
91
92# Install jar.binfmt
93install -m 755 jar.binfmt $J_INSTALL_DIR/lib/jar.binfmt
94
95# Install OpenJDK's font config
96install -m 755 fontconfig.Ubuntu.properties $J_INSTALL_DIR/lib/
97
98# Clean up
99rm -rf java-9-oracle
100
101# To add when an older version exists:
102# safe_move jdk-7u2-linux-x64.tar.gz #must be modified for each release
103# safe_move jdk-7u2-linux-i586.tar.gz #must be modified for each release
104rmdir $OLDDIR 2> /dev/null || true
105#remove previous versions, if they exist
106
107
108db_fset oracle-java9-installer/local seen false
109
110# This step is optional, recommended, and affects code below.
111ls $J_INSTALL_DIR/man/man1/*.1 >/dev/null 2>&1 && \
112  gzip -9 $J_INSTALL_DIR/man/man1/*.1 >/dev/null 2>&1
113
114#Increment highest version by 1.
115#Also assumes all Java helper programs (javaws, jcontrol, etc) at same version as java.
116#These helpers should be slaves, or in the same path as java; thus, a reasonable assumption.
117
118LATEST=1
119LATEST=$((`LANG=C update-alternatives --display java | grep ^/ | sed -e 's/.* //g' | sort -n | tail -1`+1))
120
121#create .java-9-oracle.jinfo file header:
122if [ -e /usr/lib/jvm/.java-9-oracle.jinfo ]; then
123   rm -f /usr/lib/jvm/.java-9-oracle.jinfo
124fi
125echo "name=java-9-oracle
126alias=java-9-oracle
127priority=$LATEST
128section=non-free
129" > /usr/lib/jvm/.java-9-oracle.jinfo
130
131
132#link JDK files
133for f in $J_INSTALL_DIR/bin/*; do
134    name=`basename $f`;
135    if [ ! -f "/usr/bin/$name" -o -L "/usr/bin/$name" ]; then  #some files, like jvisualvm might not be links
136        if [ -f "$J_INSTALL_DIR/man/man1/$name.1.gz" ]; then
137                                        if [ ! $arch = "arm" ]; then
138            update-alternatives --install /usr/bin/$name $name $J_INSTALL_DIR/bin/$name $LATEST --slave /usr/share/man/man1/$name.1.gz $name.1.gz $J_INSTALL_DIR/man/man1/$name.1.gz
139            echo "jdk $name $J_INSTALL_DIR/bin/$name" >> /usr/lib/jvm/.java-9-oracle.jinfo
140                                        else
141                                                # There's no javaws, jvisualvm or jmc on arm
142                                                [ ! $name = "javaws" ] && [ ! $name = "jvisualvm" ] && [ ! $name = "jmc" ] && update-alternatives --install /usr/bin/$name $name $J_INSTALL_DIR/bin/$name $LATEST --slave /usr/share/man/man1/$name.1.gz $name.1.gz $J_INSTALL_DIR/man/man1/$name.1.gz
143                                                [ ! $name = "javaws" ] && [ ! $name = "jvisualvm" ] && [ ! $name = "jmc" ] && echo "jdk $name $J_INSTALL_DIR/bin/$name" >> /usr/lib/jvm/.java-9-oracle.jinfo
144                                        fi
145         else #no man pages available
146            # [ ! $name = "javaws.real" ] = skip javaws.real     
147            [ ! $name = "javaws.real" ] && update-alternatives --install /usr/bin/$name $name $J_INSTALL_DIR/bin/$name $LATEST
148            [ ! $name = "javaws.real" ] && echo "jdk $name $J_INSTALL_DIR/bin/$name" >> /usr/lib/jvm/.java-9-oracle.jinfo
149         fi
150    fi
151done
152
153
154#link JDK not in /bin
155[ -f $J_INSTALL_DIR/lib/jexec ]    && update-alternatives --install /usr/bin/jexec    jexec    $J_INSTALL_DIR/lib/jexec    $LATEST --slave /usr/share/binfmts/jar jexec-binfmt $J_INSTALL_DIR/lib/jar.binfmt && echo "jdk jexec $J_INSTALL_DIR/lib/jexec" >> /usr/lib/jvm/.java-9-oracle.jinfo
156
157#This will issue ignorable warnings for alternatives that are not part of a group
158#Link JDK files with/without man pages
159if [ -d "$J_INSTALL_DIR/man/man1" ];then
160    for f in $J_INSTALL_DIR/man/man1/*; do
161        name=`basename $f .1.gz`;
162        #some files, like jvisualvm might not be links. Further assume this for corresponding man page
163        if [ ! -f "/usr/bin/$name" -o -L "/usr/bin/$name" ]; then
164            if [ ! -f "$J_INSTALL_DIR/man/man1/$name.1.gz" ]; then
165                name=`basename $f .1`;          #handle any legacy uncompressed pages
166            fi
167                        if [ ! -e $J_INSTALL_DIR/jre/bin/$name ]; then #don't link already linked JRE files
168                                                                if [ ! $arch = "arm" ]; then
169                        update-alternatives --install /usr/bin/$name $name $J_INSTALL_DIR/bin/$name $LATEST --slave /usr/share/man/man1/$name.1.gz $name.1.gz $J_INSTALL_DIR/man/man1/$name.1.gz
170                        echo "jdk $name $J_INSTALL_DIR/bin/$name" >> /usr/lib/jvm/.java-9-oracle.jinfo
171                                                                else
172                                                                        # There's no javaws, jvisualvm or jmc on arm
173                                                                        [ ! $name = "javaws" ] && [ ! $name = "jvisualvm" ] && [ ! $name = "jmc" ] && update-alternatives --install /usr/bin/$name $name $J_INSTALL_DIR/bin/$name $LATEST --slave /usr/share/man/man1/$name.1.gz $name.1.gz $J_INSTALL_DIR/man/man1/$name.1.gz
174                                                                        [ ! $name = "javaws" ] && [ ! $name = "jvisualvm" ] && [ ! $name = "jmc" ] && echo "jdk $name $J_INSTALL_DIR/bin/$name" >> /usr/lib/jvm/.java-9-oracle.jinfo
175                                                                fi
176                        fi
177        fi
178    done
179
180else  #no man pages available
181    for f in $J_INSTALL_DIR/bin/*; do
182        name=`basename $f`;
183        if [ ! -f "/usr/bin/$name" -o -L "/usr/bin/$name" ]; then  #some files, like jvisualvm might not be links
184            if [ ! -e $J_INSTALL_DIR/jre/bin/$name ]; then #don't link already linked JRE files
185                update-alternatives --install /usr/bin/$name $name $J_INSTALL_DIR/bin/$name $LATEST
186                echo "jdk $name $J_INSTALL_DIR/bin/$name" >> /usr/lib/jvm/.java-9-oracle.jinfo
187            fi
188        fi
189    done
190fi
191
192# Hide javaws and jvisualvm desktop files on arm since these files don't exist on this architecture
193if [ $arch = "arm" ]; then
194echo "NoDisplay=true" >> /usr/share/applications/JB-javaws-jdk9.desktop
195echo "NoDisplay=true" >> /usr/share/applications/JB-jvisualvm-jdk9.desktop
196fi
197
198# Use cacerts form ca-certificates-java if it's installed:
199if [ -e /etc/ssl/certs/java/cacerts ]; then
200  cd /usr/lib/jvm/java-9-oracle/lib/security
201  mv cacerts cacerts.original
202  ln -s /etc/ssl/certs/java/cacerts .
203fi
204
205# register binfmt; ignore errors, the alternative may already be
206# registered by another JRE.
207if which update-binfmts >/dev/null && [ -r /usr/share/binfmts/jar ]; then
208    update-binfmts --package oracle-java9 --import jar || true
209fi
210
211echo "Oracle JDK 9 installed"
212
213# Install Firefox (and compatible) plugin. $arch will be empty for unknown platform
214# No plugin for arm architecture yet
215[ -f $J_INSTALL_DIR/lib/$arch/libnpjp2.so ] && \
216        update-alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so mozilla-javaplugin.so $J_INSTALL_DIR/lib/$arch/libnpjp2.so $LATEST && \
217        echo "plugin mozilla-javaplugin.so $J_INSTALL_DIR/lib/$arch/libnpjp2.so" >> /usr/lib/jvm/.java-9-oracle.jinfo && \
218echo "Oracle Java 9 browser plugin installed"
219
220#DEBHELPER#
221
222exit 0
223
224# vim: ts=2 sw=2
Note: See TracBrowser for help on using the repository browser.