Zimbra on FreeBSD: Difference between revisions

No edit summary
Line 39: Line 39:
'''5) complete rework of ''PRE-INSTALL/POST-INSTALL/DEINSTALL'' scripts in ''ZimbraBuild/rpmconf/Spec/Scripts/FreeBSD''.'''
'''5) complete rework of ''PRE-INSTALL/POST-INSTALL/DEINSTALL'' scripts in ''ZimbraBuild/rpmconf/Spec/Scripts/FreeBSD''.'''


'''6) every ''su - zimbra -c'' call has been replaced by ''sudo -u zimbra -i -- -c'' call because su+bash is hitting a race condition on FreeBSD-7.2 (and other systems.. like Linux) which causes libexec/* scripts to hang up indefinitely (GOD, THIS TOOK ME A YEAR OF LIFE). Funny that the same bug appears on both my tested systems, while it doesn't appear on my FreeBSD-7.2 zimbra-5.0.16 installation (even the same command is okay to run).'''
'''6) every ''su - zimbra -c'' call has been replaced by ''sudo -u zimbra -i -- -c'' call because su+bash is hitting a race condition on FreeBSD-7.2 (and other systems.. like Linux) which causes some scripts to hang up indefinitely.'''


'''7) ''libexec/zmfixperms'' now fixes all needed permissions. It is called in every ''POST-INSTALL'' script.'''
'''7) ''libexec/zmfixperms'' now fixes all needed permissions. It is called in every ''POST-INSTALL'' script.'''

Revision as of 18:35, 5 October 2009

General information

The perforce cache gives users access to download and build/modify Zimbra source code for Open Source products. Building Zimbra Collaboration Suite from Zimbra's Perforce cache requires advanced knowledge of troubleshooting. It is not available for Network Edition components. Changes cannot be committed to the Perforce cache.

By building Zimbra, you agree to Zimbra's licensing terms. Building from source is not covered under the ZEUL, unlike pre-compiled binaries, but rather the YPL.

By fetching Zimbra from zimbra.imladris.sk, you agree to Zimbra's licensing terms. I am not good at legal stuff, screw it.

Technical support for source building can be found in the Zimbra Developers forum.

This guide describes building and installing zimbra-6.0.1 (GNR-601) on FreeBSD-7.2_amd64. Trying to install on a different version (that means older than 7.2-RELEASE) is not advised and not covered.

Zimbra does not support FreeBSD operating system out of the box and there are no plans for the future support (or so we all heard). I tried to integrate FreeBSD into source tree as much as possible so the same version should compile fine on other supported systems.

GNR-601 is the latest 6.0 series release. Current version & changelist can be found on Pmweb.

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

Patch notes

This is a complete rework of GNR-601 source tree and it sometimes makes things better than the original. Some notable changes:

1) openssl, bdb, libtool, popt, expat, pcre, libxml2, tcmalloc are used from base system.

Rest is too Zimbra specific and would be of no other use on the system.

2) most perl modules are used from base system. Those left unchanged are:

Getopt::Easy - not in /usr/ports and it's not really used at all besides one tiny script (no idea why not using Getopt::Long like usual),

DBD::mysql - mysql specific includes/libs not part of base,

Net-LDAPapi - ldap/cyrus-sasl specific includes/libs not part of base,

Mail-SpamAssassin - requires different datadir.

3) FreeBSD specific includes in ZimbraBuild/defs/FreeBSD* and ZimbraBuild/defs/ThirdParty/*

4) package generation is handled by pkg_create so we install real packages.

5) complete rework of PRE-INSTALL/POST-INSTALL/DEINSTALL scripts in ZimbraBuild/rpmconf/Spec/Scripts/FreeBSD.

6) every su - zimbra -c call has been replaced by sudo -u zimbra -i -- -c call because su+bash is hitting a race condition on FreeBSD-7.2 (and other systems.. like Linux) which causes some scripts to hang up indefinitely.

7) libexec/zmfixperms now fixes all needed permissions. It is called in every POST-INSTALL script.

8) Zimbra is FreeBSD aware!

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 from zimbra.imladris.sk:

fetch http://zimbra.imladris.sk/download/packages/GNR/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 vxzf 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 blurp.euba.sk 7.2-RELEASE-p4 FreeBSD 7.2-RELEASE-p4 #0: Sun Oct  4 10:52:43 CEST 2009  


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

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 vxzf 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 vxzf 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/FreeBSD-7.2/FreeBSD-7.2_amd64_packages.tar.gz
tar vxzf 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

Putting jdk into ThirdPartyBuilds

Zimbra requires you to supply jdk so let's do that. You can either download the tarred version:

mkdir -p ThirdPartyBuilds/FreeBSD_amd64/java && cd ThirdPartyBuilds/FreeBSD_amd64/java
fetch http://zimbra.imladris.sk/download/java/diablo-jdk1.6.0_07.tgz

or re-tar your installed version of diablo-jdk16:

cp -pr /usr/local/diablo-jdk1.6.0 diablo-jdk1.6.0_07
tar vzcf diablo-jdk1.6.0_07.tgz diablo-jdk1.6.0_07
rm -rf diablo-jdk1.6.0_07

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

Now it's as easy as:

./install.sh

Installing Zimbra Collaboration Suite: GNR-601 without building (skip steps 3-12)

Installing_GNR_on_FreeBSD_7

Suggested tweaks

1) cpu spikes every minute or two:

su - zimbra
zmlocalconfig -e zmmtaconfig_interval=6000
zmprov mcf zimbraLogRawLifetime 7d
zmprov mcf zimbraLogSummaryLifetime 30d
/opt/zimbra/libexec/zmlogprocess

sed -I "" -e s'|.* \* \* \* \* /opt/zimbra/libexec/zmstatuslog|\*/60 \* \* \* \* /opt/zimbra/libexec/zmstatuslog|' /var/cron/tabs/zimbra

TO DO

1) create a Zimbra FreeBSD specific start-up script in /usr/local/etc/rc.d.

I failed miserably at the attempt so please someone supply somehow..

Troubleshooting

This is the part where opensource community unites to solve all the problems!

--Solko 12:52, 5 October 2009 (UTC)

Jump to: navigation, search