Building GNR 6.0.9 on FreeBSD 8 amd64

Developer Article

Article Information

This article applies to the following ZCS versions.

ZCS 6.0 Article ZCS 6.0

General information

Please, read GNR_on_FreeBSD_7 for all the details.

This guide describes building GNR-609 on FreeBSD-8_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 from /usr/ports:

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

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

rehash

Setup the perforce enviroment:

setenv P4PORT codes.zimbra.com:2666
setenv P4USER public
setenv P4CLIENT public-view 
setenv P4PASSWD public1234

Fire up the workspace editor:

p4 client

which may look like this:

# A Perforce Client Specification.
#
#  Client:      The client name.
#  Update:      The date this specification was last modified.
#  Access:      The date this client was last used in any way.
#  Owner:       The user who created this client.
#  Host:        If set, restricts access to the named host.
#  Description: A short description of the client (optional).
#  Root:        The base directory of the client workspace.
#  AltRoots:    Up to two alternate client workspace roots.
#  Options:     Client options:
#                      [no]allwrite [no]clobber [no]compress
#                      [un]locked [no]modtime [no]rmdir
#  SubmitOptions:
#                      submitunchanged/submitunchanged+reopen
#                      revertunchanged/revertunchanged+reopen
#                      leaveunchanged/leaveunchanged+reopen
#  LineEnd:     Text file line endings on client: local/unix/mac/win/share.
#  View:        Lines to map depot files into the client workspace.
#
# Use 'p4 help client' to see more about client views and options.

Client: public-view

Update: 2008/04/08 04:45:37

Access: 2010/05/13 11:43:08

Owner:  public

Description:
               Created by admin.

Root:   /home/public/p4

AltRoots:
        /opt/zimbra-src/
        /site/src/zimbra/p4

Options:        noallwrite noclobber nocompress unlocked modtime normdir

SubmitOptions:  submitunchanged

LineEnd:        local

View:
        //depot/zcs/... //public-view/...

and change Root: some_path to Root: /home/zimbrasrc.

Run the sync:

p4 sync -f //depot/zcs/GNR-609/...
cd /home/zimbrasrc

which should be now downloaded to /home/zimbrasrc/GNR-609.

Getting the source from zimbra.imladris.sk

GNR-609-src.tgz

mkdir -p /home/zimbrasrc && \
    cd /home/zimbrasrc && \
        fetch http://zimbra.imladris.sk/download/src/GNR-609-src.tgz && \
            tar xzf GNR-609-src.tgz

Initial pre-build steps

Let's check our system:

uname -a
FreeBSD zmail.domain.tld 8.2-PRERELEASE FreeBSD 8.2-PRERELEASE #0: Fri Dec 17 14:03:02 CET 2010     solko@zmail.domain.tld:/usr/obj/usr/src/sys/solko_pf_web  amd64

We love some optimizations:

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-609 while the second installs all dependencies needed to build GNR-609. For reasons vastly uknown the second requires the first one.

cd /usr/ports/mail
fetch http://zimbra.imladris.sk/download/ports/usrports_zimbra-rundeps-6.0.9.tgz && \
    tar xzf usrports_zimbra-rundeps-6.0.9.tgz && \
        rm -f usrports_zimbra-rundeps-6.0.9.tgz
fetch http://zimbra.imladris.sk/download/ports/usrports_zimbra-builddeps-6.0.9.tgz && \
    tar xzf usrports_zimbra-builddeps-6.0.9.tgz && \
        rm -f usrports_zimbra-builddeps-6.0.9.tgz
cd /usr/ports/mail/zimbra-builddeps && make -DWITHOUT_X11 -DWITHOUT_XPM -DWITH_XS config-recursive install

followed by an optional:

make distclean

to completely clean the build mess including source files.


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 - just be sure NOT TO configure diablo-jdk16 for POLICY (as your build will be doomed to fail)). Be warned that GNR-609 requires jdk15 to build and jdk16 to run so you will end up having both. Building diablo-jdk requires downloading java stuff. How boring!

There are also those 100+ 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 and others like to install-only I built all the necessary zimbra-builddeps packages.

cd /tmp && \
    fetch http://zimbra.imladris.sk/download/packages/GNR-609/FreeBSD-8/amd64/zimbra-builddeps-8_amd64-6.0.9.tgz && \
        tar xzf zimbra-builddeps-8_amd64-6.0.9.tgz && \
            cd zimbra-builddeps-8_amd64-6.0.9 && \
                pkg_add zimbra-builddeps-6.0.9.tbz && cd /tmp && rm -rf zimbra-builddeps-8_amd64-6.0.9

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 (specifically snmp install script) does not honor ${MAKE} macro we have to replace make with gmake globally, otherwise some stuff just won't make (it) with weird errors:

cp -p /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-609 to comply with FreeBSD

Download the GNR-609 FreeBSD patch and patch the source tree:

cd /home/zimbrasrc && \
    fetch http://zimbra.imladris.sk/download/patches/GNR-609.FreeBSD.patch && \
        cd GNR-609 && patch -p1 -s < ../GNR-609.FreeBSD.patch

Remove unnecessary files:

find . -name "*.orig" -delete

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

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

Rest is handled by libexec/zmfixperms after installation.

Putting diablo-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-609

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

cd ZimbraBuild
./buildZCS.sh -t

Let's clean up after the build:

cp -p /usr/bin/make.orig /usr/bin/make && rm -f /usr/bin/make.orig

You should have a fresh build inside:

cd zcs-6.*

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

./install.sh

Further reading

GNR_on_FreeBSD_7

--Solko 12:05, 19 December 2010 (UTC)

Jump to: navigation, search