![]() |
|||||
· Home of “Community Software for Solaris” ( CSW ) |
|||||
|
|
How To Build OpenSolaris - { updated for snv_20060918 }
Introduction
The Solaris Operating System has been open source for nearly a year now. It may seem somewhat daunting and overwhelming in its size and features because it is not merely a kernel but is in fact a complete operating system. This is One-Stop Shopping and you can get everything you need in one place. That includes a very slick looking desktop. Star Office is in the Solaris Express Community Release also. The build of OpenSolaris that I use in this article has 20,862 source files with millions of lines of code. Well, my line count is a little higher because I have made a few modification in the AMD Opteron platform specific code but you can see that we are going to compile a massive code base.
Let's work together now and build this :
Step 1 - Go and get Solaris Express Community Release
You need a recent edition of Solaris Express Community Edition.
Go get Solaris Express Community Edition
Now here comes the tough part that I will need to write a full article on, you need to install Solaris Express. If you have worked with Linux or Solaris before then it will all be easy. If you have lived your life in the Windows world then you may need some help. Drop into the #opensolaris IRC channel and call out for HELP! and you will most likely get people that are only too happy to walk you all the way through the installation. Key points to consider while installing Solaris Express Community Edition :
Step 2 - Get the Sun Studio 11 Compilers and Tools
You can download a free edition of Sun ONE Studio 11 as a compressed tarball. There are other ways to get the compiler tools but if you want to make this really easy then just get the “Download install image” that you can find at the OpenSolaris site.
The tarball file will be either sunstudio11-ii-20060829-sol-x86.tar.Z for AMD Opteron and x86 or sunstudio11-ii-20060829-sol-sparc.tar.Z for UltraSparc. Let me stop you right now and let you know that I am going to focus on the AMD Opteron architecture here. You will be better than fine if you are using UltraSparc also. I will come back and edit this article after the fact to insert UltraSparc changes as required but for now, this is AMD Opteron focused. Step 3 - Install the Sun ONE Studio 11 Tools
With the compressed tarball all we need to do is extract it into /opt/SUNWspro .
n.b.: you need to be root for this
$ su -
Password:
Sun Microsystems Inc. SunOS 5.11 snv_47 October 2007
#
# cd /opt
# mkdir SUNWspro
# cd SUNWspro
# /usr/sfw/bin/gtar -zxf $HOME/sunstudio11-ii-20060829-sol-x86.tar.Z
# ls -lap
total 30
drwxr-xr-x 14 root sys 512 Jan 27 2006 ./
drwxr-xr-x 6 root sys 512 Sep 25 21:41 ../
drwxr-xr-x 8 root sys 1024 Jan 25 2006 READMEs/
drwxr-xr-x 3 root sys 1536 Jan 25 2006 bin/
drwxr-xr-x 5 root sys 512 Jan 25 2006 contrib/
drwxr-xr-x 4 root sys 512 Jan 25 2006 docs/
drwxr-xr-x 2 root sys 512 Jan 25 2006 examples/
drwxr-xr-x 2 root sys 512 Jan 25 2006 include/
drwxr-xr-x 3 root sys 512 Jan 25 2006 inventory/
drwxr-xr-x 9 root sys 1024 Jan 25 2006 lib/
drwxr-xr-x 15 root sys 512 Jan 25 2006 man/
drwxr-xr-x 19 root sys 512 Jan 25 2006 prod/
drwxr-xr-x 5 root sys 512 Jan 25 2006 sfw/
drwxr-xr-x 2 root sys 512 Jan 25 2006 system/
#
# exit
$
Okay, now let's give that a quick test drive :
# /opt/SUNWspro/bin/cc -V
cc: Sun C 5.8 Patch 121016-02 2006/03/31
usage: cc [ options] files. Use 'cc -flags' for details
# /opt/SUNWspro/bin/CC -V
CC: Sun C++ 5.8 Patch 121018-02 2006/04/26
Most important is this little bit of information. Sun Studio 11 no longer requires a Serial Number. To learn more about Sun Studio 11 please see : Release Notes: http://developers.sun.com/prodtech/cc/documentation/ss11/release_notes.html Step 4 - Get the OpenSolaris Source !
You would think that this would be step 1 but we don't need the sources until now. I recommended that you get the SUNWonbld kit, the on-closed-bins as well as the on-src files. I get all of this from
I personally drop all of this into my HOME directory thus :
$ date
Mon Sep 25 23:10:15 EDT 2006
$ pwd
/export/home/dclarke/snv-20060918
$ ls -lap
total 132758
drwxr-xr-x 2 dclarke csw 512 Sep 25 23:08 ./
drwxr-xr-x 20 dclarke csw 1024 Sep 25 23:06 ../
-rw-r--r-- 1 dclarke csw 769 Sep 25 23:08 MD5SUMS
-rw-r--r-- 1 dclarke csw 959468 Sep 25 23:08 SUNWonbld-20060918.i386.tar.bz2
-rw-r--r-- 1 dclarke csw 6853651 Sep 25 23:08 on-closed-bins-20060918.i386.tar.bz2
-rw-r--r-- 1 dclarke csw 60086116 Sep 25 23:08 on-src-20060918.tar.bz2
$
Now you have MD5 sigs for a reason so use them to verify your files.
$ /bin/digest -a md5 -v SUNWonbld-20060918.i386.tar.bz2
md5 (SUNWonbld-20060918.i386.tar.bz2) = 1cc135bcd2fd221c7b1f63ca422977ac
$ /bin/digest -a md5 -v on-closed-bins-20060918.i386.tar.bz2
md5 (on-closed-bins-20060918.i386.tar.bz2) = 274bc695c3f2e62b28227ef60326836c
$ /bin/digest -a md5 -v on-src-20060918.tar.bz2
md5 (on-src-20060918.tar.bz2) = d2e53f824a0eaee0748017559aa50e06
$
$ cat MD5SUMS
1efc634702af40979a27956213dda39e README.opensolaris
1cc135bcd2fd221c7b1f63ca422977ac SUNWonbld-20060918.i386.tar.bz2
bee0ac4c821db056001dc3f19adc5c44 SUNWonbld-20060918.sparc.tar.bz2
2fe8160fd101d9366c536b787604c92f on-bfu-20060918.i386.tar.bz2
51d356f91832128bc556dd987ca887dd on-bfu-20060918.sparc.tar.bz2
0e5caba116e7b43eb4145a61eb397f2e on-changelog-20060918.html
26f45dd05ee02c3b3c9cd78b9aa779cd on-changelog-20060918.sparse.txt
274bc695c3f2e62b28227ef60326836c on-closed-bins-20060918.i386.tar.bz2
020e7e411c6c50b64f0fc8bea33d88f8 on-closed-bins-20060918.sparc.tar.bz2
0ac2b153779f38ee29e7290d386b4c7b on-hg-bundle-20060918.hg
82ca7b1d8e595fce54785b46d2b43a6f on-hg-bundle_20060911-20060918.hg
d2e53f824a0eaee0748017559aa50e06 on-src-20060918.tar.bz2
$
Step 5 - Create a Workarea for the build
Opinions differ on this step but I will show you how I go about a build of OpenSolaris. I have done this more times than I can count and sometimes over and over in one day. The notion of having a separate filesystem ( or multiple filesystems ) for the build works very well. You may choose to skip this step if you wish but I will show you how I do things.
Remember back in step 1 I asked you to create a workarea slice? Well I set aside a big chunk of space within slice 6 of my boot disk and now I need to create the workarea filesystem thus :
# prtvtoc /dev/rdsk/c0t0d0s0
* /dev/rdsk/c0t0d0s0 partition map
*
* Dimensions:
* 512 bytes/sector
* 63 sectors/track
* 255 tracks/cylinder
* 16065 sectors/cylinder
* 4426 cylinders
* 4424 accessible cylinders
*
* Flags:
* 1: unmountable
* 10: read-only
*
* First Sector Last
* Partition Tag Flags Sector Count Sector Mount Directory
0 2 00 50090670 20980890 71071559 /
1 3 01 16065 8401995 8418059
2 5 00 0 71071560 71071559
4 0 00 20643525 64260 20707784
5 0 00 20707785 8401995 29109779 /opt
6 0 00 8418060 12225465 20643524
7 8 00 29109780 20980890 50090669 /export/home
8 1 01 0 16065 16064
#
# newfs -s 12225465 -b 8192 -f 2048 -i 2048 -m 3 /dev/rdsk/c0t0d0s6
newfs: construct a new file system /dev/rdsk/c0t0d0s6: (y/n)? y
Warning: 1096 sector(s) in last cylinder unallocated
/dev/rdsk/c0t0d0s6: 12225464 sectors in 1990 cylinders of 48 tracks, 128 sectors
5969.5MB in 133 cyl groups (15 c/g, 45.00MB/g, 21696 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
32, 92320, 184608, 276896, 369184, 461472, 553760, 646048, 738336, 830624,
11343264, 11435552, 11527840, 11620128, 11712416, 11796512, 11888800,
11981088, 12073376, 12165664
#
# mkdir /export/mybuild
# mount -F ufs -o logging /dev/dsk/c0t0d0s6 /export/mybuild
# chown dclarke:csw /export/mybuild
#
Step 6 - Unpack the source into the workarea
Simply cd to the workarea filesystem and then extract the source and the closed binaries :
$ uname -a
SunOS phobos 5.11 snv_47 i86pc i386 i86pc
$ cd /export/mybuild
$ bzcat $HOME/snv-20060918/on-src-20060918.tar.bz2 | tar -xf -
$ bzcat $HOME/snv-20060918/on-closed-bins-20060918.i386.tar.bz2 | tar -xf -
Step 7 - Install the current onbld tools.
You will need to be root for this step.
$ su -
Password:
Sun Microsystems Inc. SunOS 5.11 snv_47 October 2007
# cd /tmp
# mkdir foo
# cd foo
# bzcat /export/home/dclarke/snv-20060918/SUNWonbld-20060918.i386.tar.bz2 | tar -xf -
# ls
onbld
# pkgadd -d onbld SUNWonbld
Processing package instance <SUNWonbld> from </tmp/foo/onbld>
OS-Net Build Tools(i386) 11.11,REV=2006.09.19.03.58
Copyright 2006 Sun Microsystems, Inc. All rights reserved.
Use is subject to license terms.
Using </> as the package base directory.
## Processing package information.
## Processing system information.
1 package pathname is already properly installed.
## Verifying package dependencies.
## Verifying disk space requirements.
## Checking for conflicts with packages already installed.
## Checking for setuid/setgid programs.
This package contains scripts which will be executed with super-user
permission during the process of installing this package.
Do you want to continue with the installation of <SUNWonbld> [y,n,?] y
Installing OS-Net Build Tools as <SUNWonbld>
## Installing part 1 of 1.
/opt/onbld/bin/Install
/opt/onbld/bin/SampleLinks
/opt/onbld/bin/SamplePkgLinks
/opt/onbld/bin/acr
/opt/onbld/bin/bfu
/opt/onbld/bin/bldenv
/opt/onbld/bin/bringovercheck
/opt/onbld/bin/build_cscope
/opt/onbld/bin/cddlchk
/opt/onbld/bin/check_fnames
/opt/onbld/bin/check_rtime
/opt/onbld/bin/checkpaths
/opt/onbld/bin/checkproto
/opt/onbld/bin/cstyle
/opt/onbld/bin/ctfcvtptbl
/opt/onbld/bin/ctffindmod
/opt/onbld/bin/elfcmp
/opt/onbld/bin/flg.flp
/opt/onbld/bin/genoffsets
/opt/onbld/bin/get_depend_info
/opt/onbld/bin/hdrchk
/opt/onbld/bin/i386/abi_audit
/opt/onbld/bin/i386/aw
/opt/onbld/bin/i386/bfuld
/opt/onbld/bin/i386/codereview
/opt/onbld/bin/i386/cpiotranslate
/opt/onbld/bin/i386/cscope-fast
/opt/onbld/bin/i386/ctfconvert
/opt/onbld/bin/i386/ctfdump
/opt/onbld/bin/i386/ctfmerge
/opt/onbld/bin/i386/ctfstabs
/opt/onbld/bin/i386/cw
/opt/onbld/bin/i386/fastfs
/opt/onbld/bin/i386/findunref
/opt/onbld/bin/i386/install
/opt/onbld/bin/i386/lintdump
/opt/onbld/bin/i386/pmodes
/opt/onbld/bin/i386/protocmp
/opt/onbld/bin/i386/protolist
/opt/onbld/bin/intf_check
/opt/onbld/bin/jstyle
/opt/onbld/bin/keywords
/opt/onbld/bin/make_pkg_db
/opt/onbld/bin/makebfu
/opt/onbld/bin/mkacr
/opt/onbld/bin/mkbfu
/opt/onbld/bin/nightly
/opt/onbld/bin/protocmp.terse
/opt/onbld/bin/sccscheck
/opt/onbld/bin/sccscp
/opt/onbld/bin/sccshist
/opt/onbld/bin/sccsmv
/opt/onbld/bin/sccsrm
/opt/onbld/bin/validate_flg
/opt/onbld/bin/validate_paths
/opt/onbld/bin/wdiff
/opt/onbld/bin/webrev
/opt/onbld/bin/ws
/opt/onbld/bin/wsdiff
/opt/onbld/bin/wx
/opt/onbld/bin/xref
/opt/onbld/bin/xref.mk
/opt/onbld/env/developer
/opt/onbld/env/gatekeeper
/opt/onbld/etc/abi/ABI_i386.db
/opt/onbld/etc/abi/ABI_sparc.db
/opt/onbld/etc/abi/exceptions
/opt/onbld/gk/.cshrc
/opt/onbld/gk/.login
/opt/onbld/lib/i386/libdwarf.so.1
/opt/onbld/man/man1/Install.1
/opt/onbld/man/man1/acr.1
/opt/onbld/man/man1/bldenv.1
/opt/onbld/man/man1/bringovercheck.1
/opt/onbld/man/man1/cddlchk.1
/opt/onbld/man/man1/check_rtime.1
/opt/onbld/man/man1/checkpaths.1
/opt/onbld/man/man1/codereview.1
/opt/onbld/man/man1/cstyle.1
/opt/onbld/man/man1/cw.1
/opt/onbld/man/man1/flg.flp.1
/opt/onbld/man/man1/get_depend_info.1
/opt/onbld/man/man1/intf_check.1
/opt/onbld/man/man1/lintdump.1
/opt/onbld/man/man1/make_pkg_db.1
/opt/onbld/man/man1/mkacr.1
/opt/onbld/man/man1/nightly.1
/opt/onbld/man/man1/sccscheck.1
/opt/onbld/man/man1/sccscp.1
/opt/onbld/man/man1/sccsmv.1
/opt/onbld/man/man1/sccsrm.1
/opt/onbld/man/man1/webrev.1
/opt/onbld/man/man1/ws.1
/opt/onbld/man/man1/wsdiff.1
/opt/onbld/man/man1/wx.1
/opt/onbld/man/man1/xref.1
[ verifying class <none> ]
/opt/onbld/bin/i386/install.bin <linked pathname>
## Executing postinstall script.
Installing 'gk' account
dmake concurrency set to 12.
Installation of <SUNWonbld> was successful.
#
Step 8 - edit the opensolaris.sh script
Now we need to actually “do something” other than just extracting bits and installing bits. Now you will need to edit a script file, but only a slightly. Its so easy really thats it just silly to think that soon you will be compiling millions of lines of code. Amazing really.
$
$ cd /export/mybuild
$ cp usr/src/tools/env/opensolaris.sh .
$ chmod 644 opensolaris.sh
$ TERM=vt100;LINES=24;COLUMNS=80;EDITOR=/usr/xpg4/bin/vi
$ export TERM LINES COLUMNS EDITOR
$ /usr/xpg4/bin/vi opensolaris.sh
You will need to know how to work with vi to get this job done. Go to line 47 or thereabouts and find the GATE variable thus :
# This is a variable for the rest of the script - GATE doesn't matter to
# nightly itself
GATE=testws; export GATE
Change that to “mybuild” because that is our work area. So in this I case I am working in /export/mybuild .. thus
# This is a variable for the rest of the script - GATE doesn't matter to
# nightly itself
GATE=mybuild; export GATE
Go to line 93 or where you see this STAFFER info :
# The bringover, if any, is done as STAFFER.
# Set STAFFER to your own login as gatekeeper or developer
# The point is to use group "staff" and avoid referencing the parent
# workspace as root.
# Some scripts optionally send mail messages to MAILTO.
#
STAFFER=nobody; export STAFFER
MAILTO=$STAFFER; export MAILTO
I have no idea what a “bringover” is other than when someone can bring over some coffee to me. Just change that “nobody” to be your username like so :
# The bringover, if any, is done as STAFFER.
# Set STAFFER to your own login as gatekeeper or developer
# The point is to use group "staff" and avoid referencing the parent
# workspace as root.
# Some scripts optionally send mail messages to MAILTO.
#
STAFFER=dclarke; export STAFFER
MAILTO=$STAFFER; export MAILTO
Look at around line 124 and you may see a block that looks like this :
# build environment variables, including version info for mcs, motd,
# motd, uname and boot messages. Mostly you shouldn't change this except
# when the release slips (nah) or you move an environment file to a new
# release
#
ROOT="$CODEMGR_WS/proto/root_${MACH}"; export ROOT
SRC="$CODEMGR_WS/usr/src"; export SRC
VERSION="$GATE"; export VERSION
Let's suppose that you want you build to report the Solaris Nevada release data. In this case you would do something like this :
# build environment variables, including version info for mcs, motd,
# motd, uname and boot messages. Mostly you shouldn't change this except
# when the release slips (nah) or you move an environment file to a new
# release
#
ROOT="$CODEMGR_WS/proto/root_${MACH}"; export ROOT
SRC="$CODEMGR_WS/usr/src"; export SRC
VERSION="snv_20060918"; export VERSION
Then goto line 142 where you can put in the build date. At least the month and year at least.
# the RELEASE and RELEASE_DATE variables are set in Makefile.master;
# there might be special reasons to override them here, but that
# should not be the case in general
#
# RELEASE="5.11"; export RELEASE
# RELEASE_DATE="October 2007"; export RELEASE_DATE
RELEASE_DATE="September 2006"; export RELEASE_DATE
I really do NOT recommended that you change the “5.11” release data unless you want to see lots of scripts in your life start to fail. Just leave that alone ... for now. Now save this file and have a look at what you changed with diff :
$ diff opensolaris.sh usr/src/tools/env/opensolaris.sh | grep "<"
< GATE=mybuild; export GATE
< STAFFER=dclarke; export STAFFER
< VERSION="snv_20060918"; export VERSION
< RELEASE_DATE="September 2006"; export RELEASE_DATE
Looks good .. let build this thing ! Step 9 - EXTRA Step from Dennis
I know that I am about to fire off a complete build of the OpenSolaris source.
That is a lot of work. Even for a killer fast machine it will take nearly an hour. So let's thin out services and processes that we just do not need right now okay ? Its easy thanks to SMF and preconfigured service profiles. As root .. do this :
# svccfg
svc:> apply /var/svc/profile/generic_limited_net.xml
svc:> exit
#
Now we can continue ... Step 10 - Build !
WARNING : If you have an old slow machine, better be prepared for a 15 hour wait.
Be sure to set some environment variables, like your PATH and also be sure that the variable CC is NOT set !
$ PATH=/opt/SUNWspro/bin:/opt/onbld/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/ccs/bin
$ export PATH
$ TERM=vt100;LINES=24;COLUMNS=80;EDITOR=vi;LANG=C;LC_ALL=C
$ export TERM LINES COLUMNS EDITOR LANG LC_ALL
$ cd /export/mybuild
$
$ env
COLUMNS=80
EDITOR=vi
HOME=/export/home/dclarke
LANG=C
LC_ALL=C
LINES=24
LOGNAME=dclarke
MAIL=/var/mail//dclarke
MANPATH=/usr/openwin/share/man:/usr/share/man:/usr/dt/share/man
PATH=/opt/SUNWspro/bin:/opt/onbld/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/ccs/bin
SHELL=/sbin/sh
SSH_CLIENT=192.168.35.254 48861 22
SSH_CONNECTION=192.168.35.254 48861 192.168.35.40 22
SSH_TTY=/dev/pts/2
TERM=vt100
TZ=Canada/Eastern
USER=dclarke
$
$
$ psrinfo -v
Status of virtual processor 0 as of: 09/26/2006 01:13:20
on-line since 09/16/2006 13:39:31.
The i386 processor operates at 1992 MHz,
and has an i387 compatible floating point processor.
Status of virtual processor 1 as of: 09/26/2006 01:13:20
on-line since 09/16/2006 13:39:32.
The i386 processor operates at 1992 MHz,
and has an i387 compatible floating point processor.
$ prtconf -v | grep Mega
Memory size: 2048 Megabytes
$ date
Tue Sep 26 01:13:26 EDT 2006
$ which nightly
/opt/onbld/bin/nightly
$ /opt/onbld/bin/nightly ./opensolaris.sh &
2912
$ vmstat 60
kthr memory page disk faults cpu
r b w swap free re mf pi po fr de sr s0 s1 s1 -- in sy cs us sy id
0 0 0 5837844 1799632 0 1 0 0 0 0 0 0 0 0 0 341 48 123 0 0 100
1 0 0 5689612 1574200 1699 22587 0 0 0 0 0 147 0 0 0 1374 25823 1493 50 22 28
0 0 0 5695804 1599248 1797 24413 2 4 4 0 0 149 0 0 0 1465 26204 1503 43 24 33
0 0 0 5693708 1623208 1914 26935 3 2 2 0 0 201 0 0 0 1656 26451 1654 27 27 46
1 0 0 5703632 1655560 1500 17620 135 62 57 0 0 192 0 0 0 1303 19535 1162 22 17 61
1 0 0 5694380 1661952 2606 32875 36 280 263 0 0 153 0 0 0 1552 30671 1292 26 30 44
3 0 0 5615564 1606604 748 15847 18 281 237 0 0 43 0 0 0 664 15271 256 85 12 3
2 0 0 5600460 1597756 499 13666 7 264 220 0 0 15 0 0 0 546 12068 251 89 10 1
2 0 0 5653320 1641704 1295 22001 6 352 275 0 0 22 0 0 0 633 20654 311 81 17 2
2 0 0 5631512 1631296 974 17571 2 259 212 0 0 16 0 0 0 576 16778 269 85 14 1
1 0 0 5644644 1640704 1028 16042 27 300 238 0 0 25 0 0 0 1893 16665 1396 78 13 9
1 0 0 5598752 1619840 751 15419 1 294 223 0 0 18 0 0 0 659 15307 243 86 12 2
1 0 0 5615972 1634248 1259 21666 2 403 297 0 0 23 0 0 0 588 20586 299 81 17 3
1 0 0 5612508 1629008 1268 20613 2 314 225 0 0 24 0 0 0 597 20297 312 82 17 1
3 0 0 5623880 1627072 1035 16373 9 349 265 0 0 29 0 0 0 1932 17506 1567 77 14 9
3 0 0 5643720 1670040 1273 20876 6 410 313 0 0 52 0 0 0 1048 21737 572 77 17 6
4 0 0 5632888 1654104 1547 27864 20 573 487 0 0 45 0 0 0 859 26029 461 77 21 2
2 0 0 5635124 1652280 1505 25844 6 591 434 0 0 34 0 0 0 1209 24323 773 75 20 5
kthr memory page disk faults cpu
r b w swap free re mf pi po fr de sr s0 s1 s1 -- in sy cs us sy id
2 0 0 5625660 1645064 928 17534 8 424 330 0 0 35 0 0 0 1393 18089 870 80 14 6
.
.
.
At this point it is best to walk away for a while. If you have a dual processor AMD Opteron with plenty of RAM then don't wander away too far. If you have a single proc 400MHz Pentium then I suggest you go build a suspension bridge in your back yard. Proceed to Next Page |
|||||||