updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / bin32-jdk-java5 / construct.sh
blob5f6ff7f0f161559f8ead0cea584e03054015e4f8
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:
15 # The above copyright notice and this permission notice shall be
16 # included in all copies or substantial portions of the Software.
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.
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.
31 program=`basename $0`
33 usage () {
34 echo "usage: ${program} path/to/unbundle-jdk path/to/linux-jdk path/to/linux-jre"
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
45 # make sure javahome is the JDK
46 javahome=`echo $undir/*/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 $javahome`
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
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
73 savedir=`pwd`
74 cd $jredirp
75 jredirp=`pwd`
76 cd $savedir
77 jredir=$jredirp/$jrebase
80 checkfiles() {
81 if [ -r $jdkdir ]; then
82 echo "${program}: directory for JDK already exists: $jdkdir"
83 exit 2
85 if [ -r $jredir ]; then
86 echo "${program}: directory for JRE already exists: $jredir"
87 exit 2
91 copytree() {
92 echo "copying over the JDK tree..."
93 cp -a $javahome $jdkdir
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 ))
109 for (( i = 0 ; i < c ; i++ )); do
110 if [ ${targetb[$i]} != ${linkb[$i]} ]; then
111 # echo components differ, stopping
112 break
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/.."
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]}"
129 done
130 ln -s $rel $link
133 createjre() {
134 echo "creating JRE directory..."
135 # absolute link
136 # ln -s $jdkdir/jre $jredir
137 # relative link
138 linkrel $jdkdir/jre $jredir
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
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"
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
164 done
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 $?"
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/kinit.1
188 man/ja_JP.eucJP/man1/klist.1
189 man/ja_JP.eucJP/man1/ktab.1
190 man/ja_JP.eucJP/man1/orbd.1
191 man/ja_JP.eucJP/man1/pack200.1
192 man/ja_JP.eucJP/man1/policytool.1
193 man/ja_JP.eucJP/man1/rmid.1
194 man/ja_JP.eucJP/man1/rmiregistry.1
195 man/ja_JP.eucJP/man1/servertool.1
196 man/ja_JP.eucJP/man1/tnameserv.1
197 man/ja_JP.eucJP/man1/unpack200.1
198 man/man1/java.1
199 man/man1/javaws.1
200 man/man1/keytool.1
201 man/man1/kinit.1
202 man/man1/klist.1
203 man/man1/ktab.1
204 man/man1/orbd.1
205 man/man1/pack200.1
206 man/man1/policytool.1
207 man/man1/rmid.1
208 man/man1/rmiregistry.1
209 man/man1/servertool.1
210 man/man1/tnameserv.1
211 man/man1/unpack200.1
213 # create jre/man directory
214 # mkdir $jdkdir/jre/man
215 # move the real JRE man pages to jre/man
216 # link the JDK JRE man pages to jre/man
217 # real JDK man pages stay where they are
218 for m in `cat $jreman`; do
219 manpath=`dirname $jdkdir/jre/$m`
220 mkdir -p $manpath
221 mv $jdkdir/$m $jdkdir/jre/$m
222 linkrel $jdkdir/jre/$m $jdkdir/$m
223 done
224 # link in Japanese man pages
225 ln -s ja_JP.eucJP $jdkdir/jre/man/ja
226 rm $jreman
229 elimdups() {
230 echo "eliminating duplication between the JDK and JDK/jre..."
231 jdkcomm=/tmp/jdk.bin.comm.txt
232 cat <<EOF > $jdkcomm
233 bin/ControlPanel
234 bin/java
235 bin/javaws
236 bin/keytool
237 bin/kinit
238 bin/klist
239 bin/ktab
240 bin/orbd
241 bin/pack200
242 bin/policytool
243 bin/rmid
244 bin/rmiregistry
245 bin/servertool
246 bin/tnameserv
247 bin/unpack200
249 # note there is little point in linking these common files
250 # COPYRIGHT
251 # LICENSE
252 # THIRDPARTYLICENSEREADME.txt
253 # And this file is unique to the JDK
254 # README.html
255 # And these files are unique to the JDK/jre/
256 # CHANGES
257 # README
258 # Welcome.html
259 for p in `cat $jdkcomm`; do
260 rm $jdkdir/$p
261 # this is a relative link
262 ln -s ../jre/$p $jdkdir/$p
263 done
264 rm $jdkcomm
267 if [ $# -eq 3 ] ; then
268 getargs $1 $2 $3
269 checkfiles
270 copytree
271 createjre
272 unpackjars
273 preparecds
274 jreman
275 elimdups
276 else
277 usage
278 exit 1
281 exit 0