source: oracle-java8-installer/trunk/fuentes/debian/oracle-java8-installer.postinst @ 6493

Last change on this file since 6493 was 6493, checked in by mabarracus, 22 months ago

Package Java 8u151

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