Building GNR 6.0.13 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 Zimbra_on_FreeBSD for all the details.

This guide describes building GNR-6013 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-6013/...
cd /home/zimbrasrc

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

Getting the source from zimbra.imladris.sk

GNR-6013-src.tgz

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

Initial pre-build steps

Let's check our system:

uname -a
FreeBSD zimbra-src-amd64.solko.sk 8.2-RELEASE-p2 FreeBSD 8.2-RELEASE-p2 #0: Wed Jun  8 02:07:09 CEST 2011     solko@zimbra-src-amd64.solko.sk:/usr/obj/usr/src/sys/GENERIC  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-6013 while the second installs all dependencies needed to build GNR-6013. 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.13.tgz && \
    tar xzf usrports_zimbra-rundeps-6.0.13.tgz && \
        rm -f usrports_zimbra-rundeps-6.0.13.tgz
fetch http://zimbra.imladris.sk/download/ports/usrports_zimbra-builddeps-6.0.13.tgz && \
    tar xzf usrports_zimbra-builddeps-6.0.13.tgz && \
        rm -f usrports_zimbra-builddeps-6.0.13.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-6013 requires diablo-jdk16 to build/run and building diablo-jdk16 requires downloading some java stuff.

There are also those 117+ 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-6013/FreeBSD-8/amd64/zimbra-builddeps-8_amd64-6.0.13.tgz && \
        tar xzf zimbra-builddeps-8_amd64-6.0.13.tgz && \
            cd zimbra-builddeps-6.0.13 && \
                pkg_add zimbra-builddeps-6.0.13.tbz && cd /tmp && \
                    rm -rf zimbra-builddeps-*

You need to accept diablo-jdk16 license.


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 diablo-jdk16 so you should now get something like this:

java -version
java version "1.6.0_07"
Diablo Java(TM) SE Runtime Environment (build 1.6.0_07-b02)
Diablo Java HotSpot(TM) 64-Bit Server VM (build 10.0-b23, mixed mode)

Patching GNR-6013 to comply with FreeBSD

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

cd /home/zimbrasrc && \
    fetch http://zimbra.imladris.sk/download/patches/GNR-6013.FreeBSD.patch && \
        cd GNR-6013 && patch -p1 -s < ../GNR-6013.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-6013

First build yourself the native library and push it to the proper place:

cd ZimbraNative && make push && cd ../

Get junit package just in case:

cd ZimbraCommon/jars && \
    fetch http://zimbra.imladris.sk/download/jars/junit-4.8.2.jar && \
        cd ../../

Now (finally!) 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-6013 after a successful build

./install.sh

Further reading

Zimbra_on_FreeBSD

--Solko 16:43, 12 June 2011 (PDT)--

Jump to: navigation, search