@@ -1,273 +0,0 @@
1−#!/bin/bash
2−# construct.sh
3−# example construction of JRE and JDK directories from the DLJ bundles
4−#
5−# Copyright � 2006 Sun Microsystems, Inc.
6−#
7−# Permission is hereby granted, free of charge, to any person obtaining
8−# a copy of this software and associated documentation files (the
9−# "Software"), to deal in the Software without restriction, including
10−# without limitation the rights to use, copy, modify, merge, publish,
11−# distribute, sublicense, and/or sell copies of the Software, and to
12−# permit persons to whom the Software is furnished to do so, subject to
13−# the following conditions:
14−#
15−# The above copyright notice and this permission notice shall be
16−# included in all copies or substantial portions of the Software.
17−#
18−# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19−# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20−# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21−# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22−# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23−# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24−# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25−#
26−# Sun, Sun Microsystems, the Sun logo and Java, Java HotSpot,
27−# and JVM trademarks or registered trademarks of Sun Microsystems,
28−# Inc. in the U.S. and other countries.
29−
30−
31−program=`basename $0`
32−
33−usage () {
34− echo "usage: ${program} path/to/unbundle-jdk path/to/linux-jdk path/to/linux-jre"
35−}
36−
37−getargs() {
38− undir=$1
39− jdkdir=$2
40− jredir=$3
41− if [ ! -d $undir ]; then
42− echo "${program}: unbundle directory not found: $undir"
43− exit 2
44− fi
45− # make sure javahome is the JDK
46− javahome=`echo $undir/*/db/demo`
47− if [ ! -d $javahome ]; then
48− echo "${program}: unbundle directory incorrect: $undir"
49− echo " expecting $undir/jdk1.5.0_xx"
50− exit 2
51− else
52− javahome=$(dirname $(dirname $javahome))
53− fi
54− # verify JDK dir
55− jdkdirp=`dirname $jdkdir`
56− jdkbase=`basename $jdkdir`
57− if [ ! -d $jdkdirp ]; then
58− echo "${program}: parent directory for JDK does not exist: $jdkdirp"
59− exit 2
60− fi
61− savedir=`pwd`
62− cd $jdkdirp
63− jdkdirp=`pwd`
64− cd $savedir
65− jdkdir=$jdkdirp/$jdkbase
66− # verify JRE dir
67− jredirp=`dirname $jredir`
68− jrebase=`basename $jredir`
69− if [ ! -d $jredirp ]; then
70− echo "${program}: parent directory for JRE does not exist: $jredirp"
71− exit 2
72− fi
73− savedir=`pwd`
74− cd $jredirp
75− jredirp=`pwd`
76− cd $savedir
77− jredir=$jredirp/$jrebase
78−}
79−
80−checkfiles() {
81− if [ -r $jdkdir ]; then
82− echo "${program}: directory for JDK already exists: $jdkdir"
83− exit 2
84− fi
85− if [ -r $jredir ]; then
86− echo "${program}: directory for JRE already exists: $jredir"
87− exit 2
88− fi
89−}
90−
91−copytree() {
92− echo "copying over the JDK tree..."
93− cp -a $javahome $jdkdir
94−}
95−
96−linkrel() {
97− target=$1
98− link=$2
99− # make a softlink from the $link to the $target
100− # make this a relative link
101− targetb=(`echo $target | tr '/' ' '`)
102− linkb=(`echo $link | tr '/' ' '`)
103− (( n = ${#targetb[*]} ))
104− (( m = ${#linkb[*]} ))
105− c=$n # common length
106− if [ $m -lt $c ]; then
107− (( c = m ))
108− fi
109− for (( i = 0 ; i < c ; i++ )); do
110− if [ ${targetb[$i]} != ${linkb[$i]} ]; then
111− # echo components differ, stopping
112− break
113− fi
114− done
115− rel=""
116− for (( j = i + 1; j < m ; j++ )); do
117− if [ -z $rel ]; then
118− rel=".."
119− else
120− rel="$rel/.."
121− fi
122− done
123− for (( j = i; j < n ; j++ )); do
124− if [ -z $rel ]; then
125− rel=${targetb[$j]}
126− else
127− rel="$rel/${targetb[$j]}"
128− fi
129− done
130− ln -s $rel $link
131−}
132−
133−createjre() {
134− echo "creating JRE directory..."
135− # absolute link
136− # ln -s $jdkdir/jre $jredir
137− # relative link
138− linkrel $jdkdir/jre $jredir
139−}
140−
141−unpackjars() {
142− echo "unpacking jars..."
143− unpack200=$jdkdir/bin/unpack200
144− if [ ! -x $unpack200 ]; then
145− echo "${program}: file missing $unpack200"
146− exit 1
147− fi
148− cd $jdkdir
149− PACKED_JARS=`find . -name '*.pack'`
150− for i in $PACKED_JARS; do
151− # echo $i
152− jdir=`dirname $i`
153− jbase=`basename $i .pack`
154− if ! $unpack200 $jdkdir/$jdir/$jbase.pack $jdkdir/$jdir/$jbase.jar; then
155− echo "${program}: error unpacking $jdkdir/$jdir/$jbase.jar"
156− fi
157− if [ ! -r $jdkdir/$jdir/$jbase.jar ]; then
158− echo "${program}: missing $jdkdir/$jdir/$jbase.jar"
159− else
160− echo " $jdir/$jbase.jar"
161− # remove pack file
162− rm $jdkdir/$jdir/$jbase.pack
163− fi
164− done
165−}
166−
167−preparecds() {
168− # if this is a client installation...
169− compiler="`$jdkdir/bin/java -client -version 2>&1 | tail -n +3 | cut -d' ' -f1-4`"
170− if [ "X$compiler" = "XJava HotSpot(TM) Client VM" ]; then
171− # create the CDS archive
172− echo "creating the class data sharing archive..."
173− if ! $jdkdir/bin/java -client -Xshare:dump > /dev/null 2>&1; then
174− echo "returned error code $?"
175− fi
176− fi
177−}
178−
179−jreman () {
180− echo "setting up the JRE man pages..."
181− # note this list is slightly different for OpenSolaris bundles
182− jreman=/tmp/jre.man.txt
183−cat <<EOF > $jreman
184−man/ja_JP.eucJP/man1/java.1
185−man/ja_JP.eucJP/man1/javaws.1
186−man/ja_JP.eucJP/man1/keytool.1
187−man/ja_JP.eucJP/man1/orbd.1
188−man/ja_JP.eucJP/man1/pack200.1
189−man/ja_JP.eucJP/man1/policytool.1
190−man/ja_JP.eucJP/man1/rmid.1
191−man/ja_JP.eucJP/man1/rmiregistry.1
192−man/ja_JP.eucJP/man1/servertool.1
193−man/ja_JP.eucJP/man1/tnameserv.1
194−man/ja_JP.eucJP/man1/unpack200.1
195−man/man1/java.1
196−man/man1/javaws.1
197−man/man1/keytool.1
198−man/man1/orbd.1
199−man/man1/pack200.1
200−man/man1/policytool.1
201−man/man1/rmid.1
202−man/man1/rmiregistry.1
203−man/man1/servertool.1
204−man/man1/tnameserv.1
205−man/man1/unpack200.1
206−EOF
207− # create jre/man directory
208− # mkdir $jdkdir/jre/man
209− # move the real JRE man pages to jre/man
210− # link the JDK JRE man pages to jre/man
211− # real JDK man pages stay where they are
212− for m in `cat $jreman`; do
213− manpath=`dirname $jdkdir/jre/$m`
214− mkdir -p $manpath
215− mv $jdkdir/$m $jdkdir/jre/$m
216− linkrel $jdkdir/jre/$m $jdkdir/$m
217− done
218− # link in Japanese man pages
219− ln -s ja_JP.eucJP $jdkdir/jre/man/ja
220− rm $jreman
221−}
222−
223−elimdups() {
224− echo "eliminating duplication between the JDK and JDK/jre..."
225− jdkcomm=/tmp/jdk.bin.comm.txt
226−cat <<EOF > $jdkcomm
227−bin/ControlPanel
228−bin/java
229−bin/javaws
230−bin/keytool
231−bin/orbd
232−bin/pack200
233−bin/policytool
234−bin/rmid
235−bin/rmiregistry
236−bin/servertool
237−bin/tnameserv
238−bin/unpack200
239−EOF
240− # note there is little point in linking these common files
241− # COPYRIGHT
242− # LICENSE
243− # THIRDPARTYLICENSEREADME.txt
244− # And this file is unique to the JDK
245− # README.html
246− # And these files are unique to the JDK/jre/
247− # CHANGES
248− # README
249− # Welcome.html
250− for p in `cat $jdkcomm`; do
251− rm $jdkdir/$p
252− # this is a relative link
253− ln -s ../jre/$p $jdkdir/$p
254− done
255− rm $jdkcomm
256−}
257−
258−if [ $# -eq 3 ] ; then
259− getargs $1 $2 $3
260− checkfiles
261− copytree
262− createjre
263− unpackjars
264− preparecds
265− jreman
266− elimdups
267−else
268− usage
269− exit 1
270−fi
271−
272−exit 0
273−