Building GNR on FreeBSD 7.2 amd64

General information

Please read GNR_on_FreeBSD_7 for all the details.

This guide describes building GNR-601 on FreeBSD-7.2_amd64.

At this point it's good to note that everything should be run as root unless stated otherwise.

Getting the source via Perforce

You need to install Perforce either from /usr/ports:

cd /usr/ports/devel/perforce && make install distclean

or fetch perforce package and its dependency from zimbra.imladris.sk:

fetch http://zimbra.imladris.sk/download/packages/GNR-601/FreeBSD-7.2/amd64/compat6x-amd64-6.4.604000.200810_3.tbz
fetch http://zimbra.imladris.sk/download/packages/GNR-601/FreeBSD-7.2/amd64/perforce-08.2_5,1.tbz
pkg_add perforce-08.2_5,1.tbz

If you are using a csh derivate shell, which is the FreeBSD default, run:

rehash

Get the source:

setenv P4PORT codes.zimbra.com:2666
mkdir -p /home/public/p4
p4 -u public -P public1234 -c public-view sync -f //depot/zcs/GNR-601/...

The source is about 587 MB so it may take some time if you are sitting in the middle of Alaska.

Getting the source from zimbra.imladris.sk

GNR-601-src.tar.gz

mkdir -p /home/public/p4 && cd /home/public/p4
fetch http://zimbra.imladris.sk/download/src/GNR-601-src.tar.gz
tar xzf GNR-601-src.tar.gz

The unpacked source is about 587 MB so it may take some time if you aren't sitting on gigabit line.

Initial pre-build steps

Let's check our system:

uname -a
FreeBSD zimbra-src-amd64.solko.sk 7.2-RELEASE-p4 FreeBSD 7.2-RELEASE-p4 #0: Tue Oct  6 00:03:48 CEST 2009     solko@zimbra-src-amd64.solko.sk:/usr/obj/usr/src/sys/solko_pf_web  amd64 


cat /etc/make.conf
COPTFLAGS= -O2 -pipe
CFLAGS= -O2 -fno-strict-aliasing -pipe

Preparing build enviroment via /usr/ports

I created simple "meta" ports which will take care of everything. Since I am a very very creative person I named those: mail/zimbra-rundeps and mail/zimbra-builddeps.

The first installs all dependencies needed to run GNR-601 while the second installs all dependencies needed to build GNR-601. For reasons vastly uknown the second requires the first one.

cd /usr/ports/mail
fetch http://zimbra.imladris.sk/download/ports/usrports_zimbra-rundeps.tar.gz && \
    tar xzf usrports_zimbra-rundeps.tar.gz && \
        rm -f usrports_zimbra-rundeps.tar.gz
fetch http://zimbra.imladris.sk/download/ports/usrports_zimbra-builddeps.tar.gz && \
    tar xzf usrports_zimbra-builddeps.tar.gz && \
        rm -f usrports_zimbra-builddeps.tar.gz
cd /usr/ports/mail/zimbra-rundeps && make config-recursive install distclean
cd /usr/ports/mail/zimbra-builddeps && make config-recursive install distclean

If you are able to use /usr/ports you should be able to figure out the configure options (not that it matters much, mostly unimportant stuff). Be warned that GNR-601 requires jdk15 to build while apache-ant requires jdk16 to run so you will end up having both. Building diablo-jdk requires downloading java stuff. How boring! There are also those 64 perl modules..

If you are using a csh derivate shell, which is the FreeBSD default, run:

rehash

Preparing build enviroment via zimbra.imladris.sk

Since some people like to compile (me me me!) and others like to install-only I built all the neccessary packages.

cd /tmp && mkdir -p DELME && cd DELME && fetch http://zimbra.imladris.sk/download/packages/GNR-601/FreeBSD-7.2/FreeBSD-7.2_amd64_packages.tar.gz
tar xzf FreeBSD-7.2_amd64_packages.tar.gz && cd amd64
pkg_add zimbra-builddeps-6.0.1.tbz

You need to accept diablo-jdk license twice (jdk15+jdk16).

If you are using a csh derivate shell, which is the FreeBSD default, run:

rehash

Grats, you just saved yourself a lot of time.

Quick-hacks for a better day

Since Zimbra is a Linux lover by nature everything is /bin/bash but guess what.. we have /usr/local/bin/bash:

ln -s /usr/local/bin/bash /bin/bash

Since Zimbra uses gmake and since some ThirdParty does not honor ${MAKE} macro we have to replace make with gmake globally, otherwise some stuff just won't make with weird errors. I have no idea why recursive gmake running make fails but guess there is something deeper behind it:

cp /usr/bin/make /usr/bin/make.orig && cp /usr/local/bin/gmake /usr/bin/make

We need to compile with jdk15 so tell java about it:

setenv JAVA_VERSION 1.5

You should now get something like this:

java -version
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build diablo-1.5.0-b01)
Java HotSpot(TM) 64-Bit Server VM (build diablo-1.5.0_07-b01, mixed mode)

Patching GNR-601 to comply with FreeBSD

Download the patch and patch the source tree:

cd /home/public/p4 && fetch http://zimbra.imladris.sk/download/patches/GNR-601.FreeBSD.patch
cd GNR-601
patch -p1 -s < ../GNR-601.FreeBSD.patch

Remove unneccessary files (even those left by developers):

find . -name "*.orig" | xargs -n1 rm -f

Change modes of our new scripts else the build will fail:

chmod 0755 ZimbraBuild/rpmconf/Spec/Scripts/FreeBSD/*

Rest is handled by libexec/zmfixperms after installation.

Putting jdk16 into ThirdPartyBuilds

Zimbra requires you to supply jdk16 so we are happy to oblige by using installed version of diablo-jdk16:

mkdir -p ThirdPartyBuilds/FreeBSD_amd64/java && cd ThirdPartyBuilds/FreeBSD_amd64/java && \
    cp -pr /usr/local/diablo-jdk1.6.0 diablo-jdk1.6.0_07 &&\
        tar zcf diablo-jdk1.6.0_07.tgz diablo-jdk1.6.0_07 && \
            rm -rf diablo-jdk1.6.0_07 && cd ../../../

The destination tarball version must match with ZimbraBuild/defs/ThirdParty/FreeBSD_amd64.def!

Building Zimbra Collaboration Suite: GNR-601

Now that's the part where real Zimbra developer's magic kicks in:

cd ZimbraBuild
./buildZCS.sh -t

Sample log in already patched source tree.

Replace gmake with make:

cp /usr/bin/make.orig /usr/bin/make && rm /usr/bin/make.orig

You should have a fresh build inside:

cd zcs-6.0.*

Installing Zimbra Collaboration Suite: GNR-601 after a successful build

./install.sh

Further reading

GNR_on_FreeBSD_7

--Solko 13:46, 6 October 2009 (UTC)

Jump to: navigation, search