-
Notifications
You must be signed in to change notification settings - Fork 2
/
dobuild
executable file
·1011 lines (963 loc) · 23.9 KB
/
dobuild
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/sh
#
# SPDX-License-Identifier: CDDL-1.0
#
# {{{ CDDL HEADER
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
# }}}
#
# Copyright 2024 Peter Tribble
#
#
# this is the SunOS jdk builder
#
# it will attempt to download, patch, and build any jdk tag, and do so for
# SPARC and x86, and for illumos and Solaris 11.4
#
# will also function on SPARC/Linux (specifically debian-sparc) to
# validate the SPARC port on a regularly supported OS, although this
# script need to be called explicitly via bash, as the default sh of
# dash won't work
#
# it is dependent on the "jdk-sunos-patches" repository, which holds
# all the patches for each tag
#
#
# this is where the repositories are rooted
#
THOME=${THOME:-/packages/localsrc/Tribblix}
#
# this is where the work area is rooted
# note that if you have a separate pool, /var/tmp is probably a bad idea
#
BUILDROOT=${BUILDROOT:-/packages/localsrc/tmp}
#
# the is where the patches live
#
JPATCHDIR=${THOME}/jdk-sunos-patches
#
# this is where jdk tarballs are cached
# the 2nd is an oddity for my personal build host
#
JCACHEDIR=${THOME}/tarballs
JCACHEDIR2=${THOME}/large-tarballs
#
# this is where the build takes place
#
JBUILD=${BUILDROOT}/ud
#
# this is where it will look for bootstrap copies of the jdk
# (in addition to /usr/jdk/instances)
#
JINSTANCES=${BUILDROOT}/jdk/instances
#
# this is where exported tarballs will be placed
#
JEXPORTDIR=${BUILDROOT}/exports
#
# this is where extra components needed for testing will be placed
#
TESTROOT=${BUILDROOT}/test
#
# need gtar gpatch sed/gsed
#
TAR="/usr/bin/gtar"
GPATCH="/usr/bin/gpatch"
SED="/usr/bin/sed"
#
# Usage: dobuild [flags] tag
#
# valid flags are:
# -d [download]
# -p [patch]
# -P [patch, remove existing copy first]
# -b [build]
# -B [build, remove existing copy first]
# -t [enable tests]
# -T type [build type - release, fastdebug, slowdebug, optimized]
# -C flags [extra flags to pass to configure]
# -c cpu [override cpu (sparc or x86)]
# -o os [override os (illumos or Solaris)]
# -f feature [enable given patch feature]
# -i [install]
# -e [export]
#
# previous steps will be executed if necessary, but the expected workflow
# is to first download, then repeat the patch step until clean, then run
# the build step until that's clean
#
DODOWNLOAD=""
DOPATCH=""
DOBUILD=""
DOINSTALL=""
DOCLEAN=""
JFEATURE=""
JEXTRACONF=""
JTYPECONF=""
JBUILDTYPE=""
#
# variables
#
# JARCH - sparc or i386
# JOS - Solaris or illumos or GNU/Linux
#
# there are additional patches applied dependent on these
#
JARCH=$(uname -p)
case $(uname -o) in
illumos)
JOS="illumos"
;;
Solaris)
JOS="solaris"
SED="/usr/gnu/bin/sed"
;;
GNU/Linux)
JOS="linux"
TAR="/usr/bin/tar"
SED="/usr/bin/sed"
GPATCH="/usr/bin/patch"
JARCH=$(uname -m)
case $JARCH in
sparc64)
JARCH="sparc"
;;
*)
echo "Linux only supported on sparc64"
exit 1
;;
esac
;;
*)
echo "Unknown OS, unable to continue"
exit 1
;;
esac
dohelp() {
cat <<EOF
Usage: $0 [-t] [-T build_type] [-b | -B | -c cpu | -C conf_flags | -d | -f feature | -h | -o os | -p | -P] jdk-version
$0 -i jdk-version|/path/to/jdk
$0 -e jdk-version
Download, patch, and build a copy of the specified jdk.
Flags:
-h show this help
-d just download
-p unpack and patch, download if necessary
-P like -p, remove existing copy and start over
-b build, unpack, patch, and download if necessary
-B like -b, remove existing copy and start over
-t enable and run tests
-T type build type, release (default), fastdebug, slowdebug, optimized
-c cpu override cpu (sparc or x86)
-o os override os (illumos or Solaris)
-C flags extra flags to pass to configure
-f feature enable given patch feature
-i link the given jdk into the list of available instances
-e export the given built jdk to a tarball
EOF
exit 1
}
#
# parse any arguments
#
while getopts "bBdhpPtT:ieC:c:o:f:" opt; do
case $opt in
b)
DOBUILD="yes"
;;
B)
DOBUILD="yes"
DOCLEAN="yes"
;;
d)
DODOWNLOAD="yes"
;;
h)
dohelp
;;
p)
DOPATCH="yes"
;;
P)
DOPATCH="yes"
DOCLEAN="yes"
;;
t)
DOTEST="yes"
;;
T)
JBUILDTYPE="$OPTARG"
;;
i)
DOINSTALL="yes"
;;
e)
DOEXPORT="yes"
;;
C)
JEXTRACONF="$OPTARG"
;;
c)
JARCH="$OPTARG"
;;
o)
JOS="$OPTARG"
;;
f)
JFEATURE="$OPTARG"
;;
*)
echo "ERROR: invalid option $opt"
exit 1
;;
esac
done
shift $((OPTIND-1))
#
# we should have the jdk version and nothing else
#
case $# in
0)
echo "ERROR: no input, expecting a jdk to build"
dohelp
;;
1)
JDKVER="$1"
;;
*)
echo "ERROR: extra input, only expecting a jdk to build"
dohelp
;;
esac
#
# exit with a message
#
bail() {
echo "ERROR: $1"
exit 1
}
#
# download and install gtest and jtreg, as needed to run the test
# suite(s)
#
initialize_test() {
if [ ! -d "${TESTROOT}" ]; then
mkdir -p "${TESTROOT}"
fi
if [ ! -d "${TESTROOT}" ]; then
bail "Unable to create directory ${TESTROOT}"
fi
cd "${TESTROOT}" || bail "Unable to cd to ${TESTROOT}"
if [ ! -d googletest ]; then
git clone https://github.com/google/googletest googletest
if [ ! -d googletest ]; then
bail "Checkout of googletest failed"
fi
#
# different versions of the jdk need different versions of
# googletest, so check out all the branches we might need
#
git clone -b v1.14.0 googletest googletest-1.14.0
git clone -b v1.13.0 googletest googletest-1.13.0
git clone -b release-1.12.1 googletest googletest-1.12.1
git clone -b release-1.12.0 googletest googletest-1.12.0
git clone -b release-1.11.0 googletest googletest-1.11.0
git clone -b release-1.10.0 googletest googletest-1.10.0
git clone -b release-1.8.1 googletest googletest-1.8.1
fi
#
# normally we expect a minimum version of jtreg, so can use the same
# copy for everything
#
# there isn't a convenient download, so use the version packaged for
# Tribblix (a zap file is an SVR4 package in filesystem format wrapped
# up inside a zip file that we can just unzip)
#
# this won't work for jdk8, as the current jtreg needs to use jdk11
# or later
#
JTVER=7.4.0
if [ ! -d jtreg ]; then
wget -O "${JCACHEDIR}/TRIBjtreg.${JTVER}.zap" https://pkgs.tribblix.org/tribblix-m35/TRIBjtreg.${JTVER}.zap
if [ ! -f "${JCACHEDIR}/TRIBjtreg.${JTVER}.zap" ]; then
bail "Unable to download jtreg"
fi
unzip "${JCACHEDIR}/TRIBjtreg.${JTVER}.zap"
if [ ! -d TRIBjtreg/reloc/usr/versions/jtreg ]; then
bail "Unpack of jtreg failed"
fi
mv TRIBjtreg/reloc/usr/versions/jtreg .
rm -fr TRIBjtreg
fi
if [ ! -d jtreg ]; then
bail "Installation of jtreg failed"
fi
}
#
# extract the jdk version, the string will either start jdk-jdk for mainline
# or jdkXX for the initial release, or jdkXXu for when it's in an update
# train
#
# for mainline, we have to pull the version from the remainder of the string
# which will look like jdk-jdk-XX-Y or jdk-jdk-XX+Y
#
major_java_version() {
jstr=$1
jver=${jstr%%-*}
case $jver in
jdk*u)
jver=${jver//u}
;;
jdk)
case $jstr in
jdk*+*)
iver=${jstr%+*}
;;
*)
iver=${jstr%-*}
;;
esac
iver=${iver##*-}
jver=jdk$iver
;;
jdk*)
:
;;
*)
jver=INVALID
;;
esac
echo "$jver"
}
#
# return the name of the tarball, if there is one
# github tarballs are all gz
# if there's a bz2 tarball it's the old style from the hg repo
# (which needs to be downloaded manually)
#
find_tarball() {
JDKVER="$1"
if [ -f "${JCACHEDIR}/${JDKVER}.tar.bz2" ]; then
echo "${JCACHEDIR}/${JDKVER}.tar.bz2"
elif [ -f "${JCACHEDIR2}/${JDKVER}.tar.bz2" ]; then
echo "${JCACHEDIR2}/${JDKVER}.tar.bz2"
elif [ -f "${JCACHEDIR}/${JDKVER}.tar.gz" ]; then
echo "${JCACHEDIR}/${JDKVER}.tar.gz"
elif [ -f "${JCACHEDIR2}/${JDKVER}.tar.gz" ]; then
echo "${JCACHEDIR2}/${JDKVER}.tar.gz"
fi
}
#
# download from github
#
# the repo is named after the version
# note that if it is mainline then it will be the jdk repo
# also the url doesn't have the repo prefix, but the download gets that added
# note also that the tag is jdk-xx+yy, but the download is jdk-xx-yy
#
do_download() {
JDKVER="$1"
# jver corresponds to the repo in use
jver=${JDKVER%%-*}
# jdl is the tag, which has the repo name pulled off
jdl=${JDKVER#$jver-}
case $jdl in
*-ga)
:
;;
*)
# replace the last - with +, by first replacing all
# and then putting the first - back
jdl=${jdl//-/+}
jdl=${jdl/+/-}
;;
esac
jurl="https://github.com/openjdk/${jver}/archive/refs/tags/${jdl}.tar.gz"
echo "Download: wget -O ${JCACHEDIR}/${JDKVER}.tar.gz $jurl"
wget -O "${JCACHEDIR}/${JDKVER}.tar.gz" "$jurl"
}
#
# unpack and apply patches
# assumes we're in the target location already
#
# if we find per-os or per-architecture or feature patch lists apply those too
#
do_unpack() {
JDKVER="$1"
mver=$(major_java_version "$JDKVER")
tball="$2"
$TAR xf "$tball"
cd "$JDKVER" || bail "unpack failed"
cat "${JPATCHDIR}/${mver}/${JDKALIAS}.pls" | while read patcharg patchfile
do
${GPATCH} ${patcharg/+/ } -i "${JPATCHDIR}/${mver}/${patchfile}"
done
if [ -f "${JPATCHDIR}/${mver}/${JDKALIAS}.pls.${JARCH}" ]; then
echo "Applying extra patches for cpu ${JARCH}"
cat "${JPATCHDIR}/${mver}/${JDKALIAS}.pls.${JARCH}" | while read patcharg patchfile
do
${GPATCH} ${patcharg/+/ } -i "${JPATCHDIR}/${mver}/${patchfile}"
done
fi
if [ -f "${JPATCHDIR}/${mver}/${JDKALIAS}.pls.${JOS}" ]; then
echo "Applying extra patches for os ${JOS}"
cat "${JPATCHDIR}/${mver}/${JDKALIAS}.pls.${JOS}" | while read patcharg patchfile
do
${GPATCH} ${patcharg/+/ } -i "${JPATCHDIR}/${mver}/${patchfile}"
done
fi
if [ -f "${JPATCHDIR}/${mver}/${JDKALIAS}.pls.${JFEATURE}" ]; then
echo "Applying extra patches for feature ${JFEATURE}"
cat "${JPATCHDIR}/${mver}/${JDKALIAS}.pls.${JFEATURE}" | while read patcharg patchfile
do
${GPATCH} ${patcharg/+/ } -i "${JPATCHDIR}/${mver}/${patchfile}"
done
fi
}
#
# we need to make sure we have a boot jdk
# we're passed a build script, and parse it for the --with-boot-jdk=
# entry
#
find_boot_jdk() {
sfile="$1"
if [ ! -f "${sfile}" ]; then
echo "ERROR: missing build script $sfile"
exit 1
fi
boot_jdk=""
for foo in $(<${sfile})
do
case $foo in
--with-boot-jdk*)
boot_jdk=${foo#*=}
;;
esac
done
if [ -z "${boot_jdk}" ]; then
echo "ERROR: no boot jdk specified"
exit 1
fi
#
# if it's not in the normal place, try looking at our alternate
# build area?
#
# this would have to be manually created
#
cboot_jdk=${boot_jdk}
if [ ! -d "${boot_jdk}" ]; then
boot_jdk=${boot_jdk/\/usr\/jdk\/instances/${JINSTANCES}}
#
# error if we still can't find it
#
echo "Trying alternate boot jdk"
if [ ! -d "${boot_jdk}" ]; then
echo "ERROR: boot jdk ${cboot_jdk} not found"
exit 1
fi
#
# we found it; rewrite the build script
# need to used gsed for Solaris
#
${SED} -i s:${cboot_jdk}:${boot_jdk}: "${sfile}"
fi
echo "${boot_jdk}"
}
#
# enable gtest on older releases, where it's normally disabled
# because it's tied to Studio on Solaris
#
enable_gtest_old() {
jmver="$1"
sfile="$2"
if [ ! -f "${sfile}" ]; then
echo "ERROR: missing build script $sfile"
exit 1
fi
#
# rewrite the build script to remove the --disable-hotspot-gtest
# piece, which is normally on a line with --disable-dtrace
# need to used gsed for Solaris
#
${SED} -i "s:--disable-hotspot-gtest::" "${sfile}"
#
# we also need to fix the make so it doesn't run half a Studio
# build and complain about missing stlport
#
${SED} -i '/stlport4/d' make/hotspot/lib/CompileGtest.gmk
}
#
# enable gtest at configure time on newer releases where it's external
#
enable_gtest_new() {
jmver="$1"
sfile="$2"
if [ ! -f "${sfile}" ]; then
echo "ERROR: missing build script $sfile"
exit 1
fi
#
# different versions of the jdk need different gtest versions
# but there's a large element of guesswork in this
#
case $jmver in
jdk22|jdk23|jdk24|jdk25)
gver="1.14.0"
;;
jdk21)
gver="1.13.0"
;;
*)
gver="1.8.1"
;;
esac
#
# some versions encode the requirement, so use that if we can
#
if [ -f make/autoconf/lib-tests.m4 ]; then
ngver=$(grep GTEST_MINIMUM_VERSION= make/autoconf/lib-tests.m4|awk -F= '{print $2}')
if [ -n "${ngver}" ]; then
if [ -d "${TESTROOT}/googletest-${ngver}" ]; then
gver="${ngver}"
else
bail "This jdk version requires gtest ${ngver}"
fi
fi
fi
#
# rewrite the build script
# there should be a --with-boot-jdk piece, expand that
# (if there isn't, we fail in find_boot_jdk, so no need to check here)
# need to used gsed for Solaris
#
${SED} -i "s:--with-boot-jdk:--with-gtest=${TESTROOT}/googletest-${gver} --with-boot-jdk:" "${sfile}"
}
#
# enable gtest, selecting the appropriate method to do so depending on
# which release we're configuring
#
enable_gtest() {
jmver="$1"
sfile="$2"
if [ ! -f "${sfile}" ]; then
echo "ERROR: missing build script $sfile"
exit 1
fi
#
# different versions of the jdk need different customization techniques
# it switched at the time of removal, so need to check jdk15 dynamically
#
case $jmver in
jdk8|jdk9|jdk10|jdk11|jdk12|jdk13|jdk14)
enable_gtest_old "$jmver" "$sfile"
;;
jdk15)
checkstring=$(grep disable-hotspot-gtest "${sfile}")
if [ -n "${checkstring}" ]; then
enable_gtest_old "$jmver" "$sfile"
else
enable_gtest_new "$jmver" "$sfile"
fi
;;
*)
enable_gtest_new "$jmver" "$sfile"
;;
esac
}
#
# pass extra flags to configure
#
enable_configure_flags() {
sfile="$1"
extra_flags="$2"
if [ ! -f "${sfile}" ]; then
echo "ERROR: missing build script $sfile"
exit 1
fi
#
# rewrite the build script
# there should be a --with-boot-jdk piece, expand that
# (if there isn't, we fail in find_boot_jdk, so no need to check here)
# need to used gsed for Solaris
#
${SED} -i "s:--with-boot-jdk:${extra_flags} --with-boot-jdk:" "${sfile}"
}
#
# any other modifications to the build script
#
fixup_build_script() {
sfile="$1"
if [ ! -f "${sfile}" ]; then
echo "ERROR: missing build script $sfile"
exit 1
fi
#
# need to used gsed for Solaris
#
# on Solaris, gstrip has the g-prefixed name even in /usr/gnu
#
if [ -x /usr/gnu/bin/gstrip ]; then
${SED} -i "s:/usr/gnu/bin/strip:/usr/gnu/bin/gstrip:" "${sfile}"
fi
}
#
# install a copy of the jdk into the alternate area
#
# the argument can be either a tag, like a normal build, or
# an absolute path, presumably to a bootstrap kit you've
# unpacked somewhere else
#
do_install() {
JDKVER=$1
case $JDKVER in
/*)
if [ ! -x "${JDKVER}/bin/java" ]; then
bail "unable to find java in ${JDKVER}"
fi
# now we need to work out what version it is
# there's no easy way to do this
# my builds might appear as openjdkXX or jdkXX
# Liberica is eg jdk-11.0.18
NVER=$(basename "${JDKVER}")
case $NVER in
jdk11*|openjdk11*|jdk-11*|openjdk-11*)
mver=jdk11
;;
jdk12*|openjdk12*|jdk-12*|openjdk-12*)
mver=jdk12
;;
jdk13*|openjdk13*|jdk-13*|openjdk-13*)
mver=jdk13
;;
jdk14*|openjdk14*|jdk-14*|openjdk-14*)
mver=jdk14
;;
jdk15*|openjdk15*|jdk-15*|openjdk-15*)
mver=jdk15
;;
jdk16*|openjdk16*|jdk-16*|openjdk-16*)
mver=jdk16
;;
jdk17*|openjdk17*|jdk-17*|openjdk-17*)
mver=jdk17
;;
jdk18*|openjdk18*|jdk-18*|openjdk-18*)
mver=jdk18
;;
jdk19*|openjdk19*|jdk-19*|openjdk-19*)
mver=jdk19
;;
jdk20*|openjdk20*|jdk-20*|openjdk-20*)
mver=jdk20
;;
jdk21*|openjdk21*|jdk-21*|openjdk-21*)
mver=jdk21
;;
jdk22*|openjdk22*|jdk-22*|openjdk-22*)
mver=jdk22
;;
jdk23*|openjdk23*|jdk-23*|openjdk-23*)
mver=jdk23
;;
*)
bail "unrecognised version"
;;
esac
# looks like a successful build
rm -f "${JINSTANCES}/${mver}"
if [ ! -d "${JINSTANCES}" ]; then
mkdir -p "${JINSTANCES}"
fi
if [ ! -d "${JINSTANCES}" ]; then
bail "unable to create $JINSTANCES"
fi
ln -s "${JDKVER}" "${JINSTANCES}/${mver}"
echo "Successfully installed:"
${JINSTANCES}/${mver}/bin/java -version
;;
*)
mver=$(major_java_version "$JDKVER")
if [ ! -d "${JBUILD}/${JDKVER}" ]; then
bail "no built tag $JDKVER"
fi
NJDIR=$(echo ${JBUILD}/${JDKVER}/build/*/images/jdk)
if [ ! -d "${NJDIR}" ]; then
bail "unable to find build area"
fi
if [ ! -x "${NJDIR}/bin/java" ]; then
bail "unable to find java in build area"
fi
# looks like a successful build
rm -f "${JINSTANCES}/${mver}"
if [ ! -d "${JINSTANCES}" ]; then
mkdir -p "${JINSTANCES}"
fi
if [ ! -d "${JINSTANCES}" ]; then
bail "unable to create $JINSTANCES"
fi
ln -s "${NJDIR}" "${JINSTANCES}/${mver}"
echo "Successfully installed:"
${JINSTANCES}/${mver}/bin/java -version
;;
esac
}
#
# create a versioned tarball of a jdk image
#
do_export() {
JDKVER=$1
if [ ! -d "${JEXPORTDIR}" ]; then
mkdir -p "${JEXPORTDIR}"
fi
if [ ! -d "${JEXPORTDIR}" ]; then
bail "Unable to create ${JEXPORTDIR} to store images"
fi
mver=$(major_java_version "$JDKVER")
if [ ! -d "${JBUILD}/${JDKVER}" ]; then
bail "no built tag $JDKVER"
fi
NJDIR=$(echo ${JBUILD}/${JDKVER}/build/*/images/jdk)
if [ ! -d "${NJDIR}" ]; then
bail "unable to find build area"
fi
if [ ! -x "${NJDIR}/bin/java" ]; then
bail "unable to find java in build area"
fi
# looks like a successful build
# the image we start from is unversioned, and we want a versioned
# tarball that unpacks into a versioned directory
# so create a staging area
TDIR=/tmp/jdk-exporter.$$
rm -fr "$TDIR"
mkdir "$TDIR"
if [ ! -d "${TDIR}" ]; then
bail "unable to create staging area"
fi
# now we can copy things across
echo "Creating tarball"
cd ${JBUILD}/${JDKVER}/build/*/images
tar cf - jdk | ( cd "$TDIR" ; tar xf -)
cd "$TDIR"
mv jdk "$JDKVER"
tar cf - "$JDKVER" | gzip > "${JEXPORTDIR}/${JDKVER}.tar.gz"
ls -l "${JEXPORTDIR}/${JDKVER}.tar.gz"
}
#
# catch the install early
#
if [ -n "${DOINSTALL}" ]; then
do_install "$JDKVER"
exit 0
fi
#
# catch the export early
#
if [ -n "${DOEXPORT}" ]; then
do_export "$JDKVER"
exit 0
fi
#
# sanity check/debug
#
if [ ! -d "${JCACHEDIR}" ]; then
mkdir -p "$JCACHEDIR"
if [ ! -d "${JCACHEDIR}" ]; then
bail "Unable to create ${JCACHEDIR} to store tarballs"
fi
fi
if [ ! -d "${JPATCHDIR}" ]; then
bail "No patch directory, have you checked out jdk-sunos-patches?"
fi
if [ -n "${JBUILDTYPE}" ]; then
case ${JBUILDTYPE} in
release|fastdebug|slowdebug|optimized)
JTYPECONF="--with-debug-level=${JBUILDTYPE}"
;;
*)
bail "Invalid debug level for -T"
;;
esac
fi
#
# if testing, we need to make sure the test components are downloaded
# and installed, so do that now (it needs JCACHEDIR)
#
if [ -n "${DOTEST}" ]; then
initialize_test
fi
#
# there are 2 versions we use
# JDKVER is the version we want to build
# JDKALIAS is the version of the patches/scripts we use
#
JDKALIAS=${JDKVER}
mver=$(major_java_version "$JDKVER")
if [ -f "${JPATCHDIR}/${mver}/${JDKVER}.alias" ]; then
JDKALIAS=$(<${JPATCHDIR}/${mver}/${JDKVER}.alias)
echo "Found alias $JDKALIAS for $JDKVER"
fi
tball=$(find_tarball "$JDKVER")
if [ -s "${tball}" ]; then
echo "Found existing download ${tball}"
fi
if [ -f "${JPATCHDIR}/${mver}/${JDKALIAS}.pls" ]; then
echo "Found patch list for $JDKVER"
else
bail "No patch list for $JDKVER"
fi
if [ -d "${JPATCHDIR}/${mver}/${JDKALIAS}" ]; then
echo "Found patch directory for $JDKVER"
else
bail "No patch directory for $JDKVER"
fi
if [ -f "${JPATCHDIR}/${mver}/${JDKALIAS}/build.sh" ]; then
echo "Found build script for $JDKVER"
else
bail "No build script for $JDKVER"
fi
#
# from here on we do some work
#
#
# phase 1 is to download, if necessary
# stop if that's all we were asked to do
#
if [ -n "${DODOWNLOAD}" ]; then
echo "Downloading only"
fi
if [ -s "${tball}" ]; then
echo "Already downloaded $tball"
else
do_download "$JDKVER"
tball=$(find_tarball "$JDKVER")
fi
if [ ! -s "${tball}" ]; then
bail "no download found"
fi
if [ -n "${DODOWNLOAD}" ]; then
exit 0
fi
#
# phase 2 is to unpack and apply the patches, if necessary
# we already ensured the tarball was downloaded above
# stop if that's all we were asked to do
#
if [ -n "${DOPATCH}" ]; then
echo "Patching only"
fi
#
# with -P and -B we clean up an existing copy
#
if [ -n "${DOCLEAN}" ]; then
if [ -d "${JBUILD}/${JDKVER}" ]; then
echo "Removing existing unpacked ${JDKVER}"
rm -fr "${JBUILD}/${JDKVER}"
fi
fi
if [ -d "${JBUILD}/${JDKVER}" ]; then
echo "Found existing unpacked ${JDKVER}"
else
if [ ! -d "${JBUILD}" ]; then
mkdir -p "${JBUILD}"
fi
if [ ! -d "${JBUILD}" ]; then
bail "cannot create build area $JBUILD"
fi
cd "$JBUILD" || bail "cannot cd to build area $JBUILD"
do_unpack "$JDKVER" "$tball"
fi
if [ ! -d "${JBUILD}/${JDKVER}" ]; then
bail "Unpack of $JDKVER failed"
fi
if [ -n "${DOPATCH}" ]; then
exit 0
fi
#
# phase 3 is to run a build
# we know the location exists from above
#
cd "${JBUILD}/${JDKVER}" || bail "cannot cd to build directory $JBUILD/$JDKVER"
NJDIR=$(echo build/*/images/jdk)
if [ -x "${NJDIR}/bin/java" ]; then
echo "Build already ran successfully"
else
if [ -n "${DOTEST}" ]; then
#
# there are 2 ways for configure to pick up jtreg, the simplest
# is to set JT_HOME
#
JT_HOME="${TESTROOT}/jtreg"
export JT_HOME
#
# but gtest involves rewriting the configure command
#
enable_gtest "${mver}" "${JPATCHDIR}/${mver}/${JDKALIAS}/build.sh"
#
# put in a little marker to say we've actually done this
#
touch .jdk_sunos_test_enabled
fi
if [ -n "${JEXTRACONF}" ]; then
enable_configure_flags "${JPATCHDIR}/${mver}/${JDKALIAS}/build.sh" "${JEXTRACONF}"
fi
if [ -n "${JTYPECONF}" ]; then
enable_configure_flags "${JPATCHDIR}/${mver}/${JDKALIAS}/build.sh" "${JTYPECONF}"
fi
find_boot_jdk "${JPATCHDIR}/${mver}/${JDKALIAS}/build.sh"
fixup_build_script "${JPATCHDIR}/${mver}/${JDKALIAS}/build.sh"
echo "Running ${JPATCHDIR}/${mver}/${JDKALIAS}/build.sh"
${JPATCHDIR}/${mver}/${JDKALIAS}/build.sh
#
# if we rewrote the build script, restore it
# old Solaris git doesn't understand restore, do it the old way
#
cd "${JPATCHDIR}" || bail "unable to cd back to patch repo"
git checkout -- "${mver}/${JDKALIAS}/build.sh"
fi
#
# was the build successful?
#
cd "${JBUILD}/${JDKVER}" || bail "cannot cd to build directory $JBUILD/$JDKVER"
NJDIR=$(echo build/*/images/jdk)
if [ -x "${NJDIR}/bin/java" ]; then
echo "Build of ${JDKVER} completed successfully"
else
bail "Build of ${JDKVER} failed"
fi
#
# if we were asked to just do a build, stop here
#
if [ -n "${DOBUILD}" ]; then
exit 0
fi
#
# if testing isn't requested, also stop
#
if [ ! -n "${DOTEST}" ]; then
exit 0
fi
#
# run the tests
#
cd "${JBUILD}/${JDKVER}" || bail "cannot cd to build directory $JBUILD/$JDKVER"
#