2007年12月16日星期日

在 OpenBSD 4.2 中编译安装 jdk 1.5 的笔记

在 OpenBSD 4.2 中编译安装 jdk 1.5 的笔记

我先后编译和安装了 OpenBSD 4.2 正式版本中的 JDK 1.5u12,以及 4.3 开发版本中的
JDK 1.5u13。注意,根据 Ports 中的 Make 文件得知,如果你需要尝试编译 JDK 1.6u3
或 JDK 1.7,也需要先编译 JDK 1.5。

我是在笔记本上安装的虚拟机中构建,PM 1.73 GHz,256M 内存,8.4G 磁盘文件。构建
时主要压力集中在CPU,少量在硬盘,内存需求很低。总之,没有想像中的要求资源很高,
构建很流畅,结束后磁盘空间状态是:
$ df -k
Filesystem 1K-blocks Used Avail Capacity Mounted on
/dev/wd0a 7625342 4197862 3046214 58% /
/dev/cd0a 208548 208548 0 100% /mnt/cdrom

1. 需要安装文件集:
comp42.tgz
xbase42.tgz
xshare42.tgz

tar -C / -zxphf comp42.tgz
tar -C / -zxphf xbase42.tgz
tar -C / -zxphf xshare42.tgz

2. 下列编译时依赖的包也必须安装(当然,如果你的机器可以从外网下载,也可以在编译
的时候自动构建和安装):
[root@bsd42 /usr/ports/devel/jdk/1.5]$ pkg_info | sort | wc -l
25
[root@bsd42 /usr/ports/devel/jdk/1.5]$ pkg_info | sort
atk-1.18.0p0 accessibility toolkit used by gtk+
bzip2-1.0.4 block-sorting file compressor, unencumbered
cairo-1.4.10 vector graphics library
esound-0.2.34p0v0 sound library for Enlightenment
gettext-0.14.6p0 GNU gettext
glib2-2.12.12p1 general-purpose utility library
glitz-0.5.6 OpenGL image compositing library
gmake-3.80p1 GNU make
gmp-4.2.1 library for arbitrary precision arithmetic
gtar-1.17 GNU version of the traditional tar archiver
gtk+2-2.10.13 multi-platform graphical toolkit
hicolor-icon-theme-0.10p0 high-color icon theme shell for GNOME and KDE
jikes-1.22p3 compile Java source into .class files (quickly!)
jpeg-6bp3 IJG's JPEG compression utilities
kaffe-1.1.7p3 kaffe.org's Java JDK1.4 compiler, runtime and libs
libaudiofile-0.2.6p0 SGI audiofile library clone
libiconv-1.9.2p3 character set conversion library
libltdl-1.5.22p2 GNU libtool system independent dlopen wrapper
nspr-4.6.7 Netscape Portable Runtime
openmotif-2.3.0 Motif toolkit
pango-1.16.4 library for layout and rendering of text
png-1.2.18 library for manipulating PNG images
tiff-3.8.2p0 tools and library routines for working with TIFF images
unzip-5.52 extract, list & test files in a ZIP archive
zip-2.32 create/update ZIP files compatible with PKZip(tm)

3. 配置构建系统
$ wget ftp://ftp.openbsd.org/pub/OpenBSD/4.2/ports.tar.gz
$ tar -zxphf ports.tar.gz -C /usr
$ export CVSROOT=anoncvs@anoncvs3.usa.openbsd.org:/cvs
$ cd /usr/ports
$ cvs -q up -rOPENBSD_4_2 -Pd
$ vi /etc/mk.conf
#USE_SYSTRACE=Yes
ACCEPT_JRL_LICENSE=Yes
WRKOBJDIR=/usr/ports/obj
DISTDIR=/usr/ports/distfiles
PACKAGE_REPOSITORY=/usr/ports/packages

4. 自己下载,放到/usr/ports/distfiles目录中
http://www.eyesbeyond.com/freebsddom/java/status.html
http://www.eyesbeyond.com/freebsddom/java/jdk15.html
http://www.java.net/download/tiger/tiger_u12
http://java.sun.com/products/archive/j2se/5.0_12/
http://archive.apache.org/dist/xml/xalan-j/binaries/

bsd-jdk15-patches-6.tar.bz2 1M
jdk-1_5_0_12-fcs-bin-b04-jrl-02_may_2007.jar 2M
jdk-1_5_0_12-fcs-src-b04-jrl-02_may_2007.jar 55M
jdk-1_5_0_12-solaris-i586.tar.Z 82M
xalan-j_2_7_0-bin.tar.gz 13M

5. 构建和安装
[root@bsd42 /usr/ports/devel/jdk/1.5]$ time make
316m31.34s real 144m27.40s user 119m51.09s system

[root@bsd42 /usr/ports/devel/jdk/1.5]$ time make package
5m14.10s real 1m15.32s user 1m19.35s system

[root@bsd42 /usr/ports/devel/jdk/1.5]$ time make install
0m56.66s real 0m11.78s user 0m16.49s system

$ du -ms j*
92 jdk-1.5.0.12.tgz
28 jre-1.5.0.12.tgz
[root@bsd42 /usr/ports/packages/i386/all]
$ du -ks *
93488 jdk-1.5.0.13.tgz
28512 jre-1.5.0.13.tgz

$ java -version
java version "1.5.0_12-p6"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_12-p6-root_07_dec_2007_22_18)
Java HotSpot(TM) Client VM (build 1.5.0_12-p6-root_07_dec_2007_22_18, mixed mode)

$ java -server -version
java version "1.5.0_12-p6"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_12-p6-root_07_dec_2007_22_18)
Java HotSpot(TM) Server VM (build 1.5.0_12-p6-root_07_dec_2007_22_18, mixed mode)

$ java -version
java version "1.5.0_13-p7"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_13-p7-root_08_dec_2007_20_36)
Java HotSpot(TM) Client VM (build 1.5.0_13-p7-root_08_dec_2007_20_36, mixed mode)

$ java -server -version
java version "1.5.0_13-p7"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_13-p7-root_08_dec_2007_20_36)
Java HotSpot(TM) Server VM (build 1.5.0_13-p7-root_08_dec_2007_20_36, mixed mode)