Solaris - Setup Build Environment

Intro

Update in progress: 21/10/2008 for 5.0.10

So, this is a series of articles and patches that document the procedure for building Zimbra Collaboration Suite (ZCS) on Solaris 10.  This procedure works for both x86 and Sparc architectures.  Even with these detailed instructions and (hopefully) clean patches, building ZCS from source is not for the faint of heart, or for those without large amounts of time.  Unless you have a really good reason, it's highly advised to just download a binary installer for you platform which will get you up and running in a matter of minutes.

In terms of the Operating System setup, I have tested building this on Solaris u1 to u5, x86 and Sparc.  I haven't tried Solaris Express or OpenSolaris for building, but it has been tested and definitely does NOT run on Solaris Express or OpenSolaris.  Support for Solaris Express and OpenSolaris is planned for future releases.  Default 'entire' install is recommended, minimal install does NOT work and probably won't in the near future - it doesn't provide enough of a GNU-like environment currently.  Hopefully in the future the installer will support minimal install, as it is many times smaller than the entire install.  After Solaris is fully installed and rebooted, make sure you register the system with Sunsolve and run 'smpatch update' to fully update the system. Do not continue with the rest of this without fully updating the OS. The system will need a reboot after patching.

A collection of opensource packages (/usr/sfw, *NOT RELATED TO* http://www.sunfreeware.com) is included now as default in Solaris 10/11. Unfortunately, SFW does not have a good track record of updating packages in a timely manner and often the latest available lags far behind latest development. In particular, the compiler toolsets have a poor record of working well - often the gcc packages are good only for doing multistage builds of gcc from source. For these test builds, remove /usr/sfw/bin from your bin and crle path so we don't get things conflicts.  For now we will use Blastwave packages to build and install, later on instructions for building and installing with SunFreeware.com packages will follow.


Setup environment

We need to set various environment settings to a) reflect the install environment, and b) enable us to obtain and build the source code.  As this port has evolved, we have removed the need to have Blastwave or SFW in the execution or library paths - these are specified through runtime variables and library hinting.  It is important not to set library paths in crle or LD_LIBRARY_PATH.
IMPORTANT: ensure $LD_LIBRARY_PATH is null, and 'crle' is not altered.Although we remove the need to alter the path for installation/running environment, it makes things easier when we're building.  Best place to configure path is in /etc/default/login, and /etc/default/su. I login as a user, then su to root to do everything, so I setup SUPATH in /etc/default/su:

SUPATH=/opt/csw/bin:/usr/sbin:/usr/bin:/usr/ccs/bin:/opt/SUNWspro/bin I set the prompt and change shell to bash (it's ok-ish in Solaris 10+ to do this for root, especially for dev box - even sh is linked these days).  Shell scripts should all have /bin/bash specified as the first line, so this is for convenience only, it is not a necessity. I also mkdir /root and usermod -d /root root as is default in Linux - yes diehard Solaris bods will recoil in horror but it stops making a mess of /.  Now we setup ~/.profile (/root/.profile if you were philistine enough to follow the preceding suggestion).  There are various useful environment variables to set in here, relating to Zimbra build vars, Java/Ant vars, and P4 setup.
PS1='$LOGNAME@`hostname`: `pwd`> '
BUILD_HOME="/opt/build.zimbra/source"
JAVA_HOME=/opt/build.zimbra/java
ANT_HOME=/opt/build.zimbra/ant
PATH=/opt/build.zimbra/java/bin:/opt/build.zimbra/ant/bin:/opt/build.zimbra/bin:$PATH
P4EDITOR=emacs
P4PORT=codes.zimbra.com:2666
P4USER=public
P4CLIENT=public-view
P4PASSWD=public1234
P4=${BUILD_HOME}/bin/p4
RELEASE=FRANKLIN
PERLLIB=/opt/build.zimbra/source/FRANKLIN/ThirdParty/Perl/zimbramon/lib
PERLLIB=$PERLLIB:/opt/build.zimbra/source/FRANKLIN/ThirdParty/Perl/zimbramon/lib/sun4-solaris-64int
PERLLIB=$PERLLIB:/opt/build.zimbra/source/FRANKLIN/ThirdParty/Perl/zimbramon/lib/i86pc-solaris-64int
export PATH PS1 JAVA_HOME ANT_HOME BUILD_HOME PERLLIB P4EDITOR P4PORT P4USER P4CLIENT P4PASSWD P4 RELEASE
Now we need to add Japanese locale to the environment.  This is necessary because recently translation files have made their way into the source tree with funny encoding and the build fails unless it can process these.  Adding locales to Solaris is an invasive lengthy procedure, fortunately in Solaris 10 there is a tool to do it all for you: localeadm.  This requires either your original Solaris install CD/DVD, or a loopback mounted iso image.  You can mount an ISO image with lofiadm - google for the two line procedure.  Once you have the dvd/iso mounted - we'll assume /mnt - then you have build the locale database before installing:
localadm -a ja -d /mntLogout, log back in.


Set up Blastwave

We currently depend on Blastwave (http://www.blastwave.org) packages to build and install ZCS.  They have developed pkg-get, which is very like debian apt-get. It is very user friendly and the package repository contains well built, up-to-date software.

IMPORTANT: Make sure the OS is fully patched before installing BlastwaveInstall Blastwave pkg-get:
pkgadd -d http://www.blastwave.org/pkg_get.pkgChoose your closest mirror in /opt/csw/etc/pkg-get.conf - add /stable to end of url, do NOT use /unstable (nothing bad should happen, just we want as stable a package as possible at the end of this - the /stable branch is tested and has no open bug reports against it):
url=http://ftp.uni-erlangen.de/pub/mirrors/blastwave.org/stableThis next action is optional - it restricts Blastwave package installation into the current zone only.  This is very useful if you are building in one zone and testing in another, as it isolates the zones completely with relation to Blastwave dependencies.  Edit /opt/csw/etc/pkg-get.conf again, and uncomment the following line:
PKGADDFLAGS=-GTurn off irritating confirmations:
cp -p /var/pkg-get/admin-fullauto /var/pkg-get/adminSetup blastwave package key/opt/csw/bin/pkg-get install wget gnupg textutils
/opt/csw/bin/wget --output-document=pgp.key http://www.blastwave.org/mirrors.html
/opt/csw/bin/gpg --import pgp.key
Disable blastwave perl, ensure we build with/use the default Solaris perl
mv /opt/csw/bin/perl /opt/csw/bin/perl.blastwave
ln -s /usr/bin/perl /opt/csw/bin/perl
Install blastwave packages:
/opt/csw/bin/pkg-get install gmake gtar lynx libgmp curl autoconf automake libxml2 groff gsed gawk sudo pcre gcc3 gcc3g++ libtool diffutils colordiff


Setup Java and ANT for building

** IGNORE THIS SECTION FOR NOW **
Although Zimbra now runs with Java 1.6, it still needs to be built with 1.5 so both must be downloaded. For Solaris we must download two packages for each version - the main 32bit package and the additional 64bit support. Download the latest 1.5 and 1.6 JDKs from for you Solaris 10 architecture:
Download Java 1.6
Download Java 1.5

We should end up with files similar to this:
jdk-1_5_0_14-solaris-amd64.sh
jdk-1_5_0_14-solaris-i586.sh
jdk-6u4-solaris-amd64.sh
jdk-6u4-solaris-i586.sh
** END IGNORE **

Update: Zimbra 5.0.6 has regressed to JDK1.5.0_15 for runtime, as there are unresolved bugs in JDK1.6.   So you don't have to download and unpack JDK1.6, only 1.5.0_15.  Make sure you get _15, _16 is currently the latest release but Zimbra uses _15.  Get the full JDK for your architecture.  If using x86/x64, get x86 and x64 even though we're currently not specifically calling 64bit it will at least enable manual hack if required on large memory boxes.  Make sure to get the self extracting binaries, not the package tars.
Download Java 1.5

Install JDK1.5:
sh jdk-1_5_0_14-solaris-i586.sh
sh jdk-1_5_0_14-solaris-amd64.ss
mkdir -p /opt/build.zimbra
mv jdk1.5.0_15 /opt/build.zimbra
ln -s /opt/build.zimbra/jdk1.5.0_15/ /opt/build.zimbra/java
ln -s /opt/build.zimbra/java /usr/local/java (mkdir /usr/local if necessary)
Install ANT:
wget http://mirror.public-internet.co.uk/ftp/apache/ant/binaries/apache-ant-1.7.1-bin.tar.gz
gtar -xzf apache-ant-1.7.1-bin.tar.gz
mv apache-ant-1.7.1 /opt/build.zimbra/
ln -s /opt/build.zimbra/apache-ant-1.7.1 /opt/build.zimbra/ant


Setup Sun Studio 12

It is highly advised to build perl modules with the same compiler that the perl binary is buit with, in this case cc.  As we must install Sun Studio which provides the SUNWspro cc compiler set, we therefore build as much as we can with cc as it provides better performing binaries.  gcc also has a poor history with producing reliable 64bit sparcv9 compiles, although recent versions are better.

Go here to download latest release of Sun Studio 12 for whichever architecture you are using:
Download Sun Studio 12
mkdir tmp; cd tmp
bzcat ../SunStudio12ml-solaris-x86-200709-pkg.tar.bz2 |tar -xf -
./installer -nodisplay (Best to install into default /opt, accept all defaults, should be correct)
cd ..


Create Users/Groups

Create zimbra user and group:
groupadd zimbra && useradd -g zimbra zimbra
mkdir -p /opt/zimbra
usermod -d /opt/zimbra zimbra
usermod -s /bin/bash zimbra
Create postfix user and group:
groupadd postdrop
groupadd postfix
useradd -g postfix postfix


Obtain Zimbra Source

First we need to download the p4 client binary from perforce:
mkdir -p /opt/build.zimbra/bin; cd /opt/build.zimbra/bin
wget http://www.perforce.com/downloads/perforce/r08.1/bin.solaris10x86_64/p4
chmod a+rx p4
Now synch the source (hint: don't do this right now, keep reading):
cd /opt/build.zimbra/source
/opt/build.zimbra/bin/p4 sync -f //depot/zcs/...
This should currently synch three branches - FRANK, FRANKLIN and main. FRANK is 4.5.x, and main is HEAD - as we want to build a stable 5.0 release, we want FRANKLIN branch. If you're doing dev, probably better choosing main branch.

As the trees are quite large, you can (and probably should) opt for a single tree.  Here we're going for the current 5.0.x branch - FRANKLIN:
/opt/build.zimbra/bin/p4 sync -f //depot/zcs/FRANKLIN/...

Zimbra now creates special branches for each release.  Because of the way the public cache works, it's not very reliable to try and get a specific release by tag or sync number/date, so they've kindly created nice branches for each release, where the release path is //depot/zcs/FRANKLIN-50<release>, ie.
/opt/build.zimbra/bin/p4 sync -f //depot/zcs/FRANKLIN-5010/...

The synch goes into /home/public/p4/FRANKLIN.  When the synch is completed, move it into our build tree:
mv /home/public/p4/FRANKLIN-5010 /opt/build.zimbra/source
ln -s FRANKLIN-5010 FRANKLIN
Now download the latest Solaris source patches from the download area.


Patch Zimbra Source

Patch the vanilla Source with the Solaris patchset:
cd /opt/build.zimbra/source
gpatch -p0 <zimbra.5.0.10.solaris10.gdiff
gpatch -p0 <zimbra.5.0.10.ThirdParty.solaris10.gdiff

Build ThirdParty

Right, now you're ready to start building ThirdParty component!
<- Go Here ->

 
RocketTheme Joomla Templates