# Copyright 1999-2015 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ EAPI="4" PHP_EXT_NAME="mapi" USE_PHP="php5-3 php5-4 php5-5" PYTHON_DEPEND="python? 2" inherit eutils bash-completion flag-o-matic depend.php php-ext-source-r2 python unpacker autotools versionator systemd DESCRIPTION="Open Source Groupware Solution" HOMEPAGE="http://zarafa.com/" ZARAFA_RELEASE="final" ZARAFA_ARM="0.6.0" MY_PV=$(replace_version_separator 3 '-' ) MY_PVV=$(replace_version_separator 3 'beta' $MY_PV ) MY_PVM=$(get_version_component_range 1-2 ) MY_PVR=$(get_version_component_range 1-3 ) SRC_URI="http://download.zarafa.com/community/${ZARAFA_RELEASE}/${MY_PVM}/${MY_PV}/sourcecode/zcp-${MY_PVR}.tar.gz amd64? ( licensed? ( http://download.zarafa.com/zarafa/drupal/download_platform.php?platform=${ZARAFA_RELEASE}/${MY_PVM}/${MY_PV}/zcp-${MY_PV}-ubuntu-12.04-x86_64-supported.tar.gz https://launchpad.net/ubuntu/+archive/primary/+files/libboost-system1.46.1_1.46.1-7ubuntu3_amd64.deb https://launchpad.net/ubuntu/+archive/primary/+files/libboost-filesystem1.46.1_1.46.1-7ubuntu3_amd64.deb https://launchpad.net/ubuntu/+archive/primary/+files/libssl1.0.0_1.0.1-4ubuntu5.20_amd64.deb https://launchpad.net/ubuntu/+archive/primary/+files/libicu48_4.8.1.1-3ubuntu0.1_amd64.deb ) ) x86? ( licensed? ( http://download.zarafa.com/zarafa/drupal/download_platform.php?platform=${ZARAFA_RELEASE}/${MY_PVM}/${MY_PV}/zcp-${MY_PV}-ubuntu-12.04-i386-supported.tar.gz https://launchpad.net/ubuntu/+archive/primary/+files/libboost-system1.46.1_1.46.1-7ubuntu3_i386.deb https://launchpad.net/ubuntu/+archive/primary/+files/libboost-filesystem1.46.1_1.46.1-7ubuntu3_i386.deb https://launchpad.net/ubuntu/+archive/primary/+files/libssl1.0.0_1.0.1-4ubuntu5.20_i386.deb https://launchpad.net/ubuntu/+archive/primary/+files/libicu48_4.8.1.1-3ubuntu0.1_i386.deb ) ) arm? ( licensed? ( http://www.jdo.it/Zarafa_${ZARAFA_ARM}_arm.spk -> zcp-${MY_PV}-spk-arm-free.tar ) )" S="${WORKDIR}"/zarafa-${MY_PVR} ZARAFA_SERVICES="dagent gateway ical monitor search server spooler" LICENSE="AGPL-3" SLOT="0" KEYWORDS="~x86 ~amd64 ~arm" RESTRICT="mirror" IUSE="debug +kerberos +icu +ldap +logrotate +python static +swig +tcmalloc +licensed sparsehash profiling +pic" RDEPEND=">=dev-libs/libical-0.44 >=dev-cpp/libvmime-0.9.2_pre512 virtual/httpd-php virtual/mysql >=dev-cpp/clucene-2.3.3.4-r5 dev-db/kyotocabinet dev-libs/boost dev-libs/libxml2 dev-libs/openssl net-misc/curl sys-libs/e2fsprogs-libs sys-libs/zlib icu? ( dev-libs/icu ) kerberos? ( virtual/krb5 ) ldap? ( net-nds/openldap ) logrotate? ( app-admin/logrotate ) python? ( dev-lang/python ) swig? ( =dev-lang/swig-1.3* ) tcmalloc? ( dev-util/google-perftools[static-libs] )" DEPEND="${RDEPEND} sparsehash? ( dev-cpp/sparsehash ) dev-util/pkgconfig sys-devel/gettext" need_php_httpd pkg_setup() { python_set_active_version 2 python_pkg_setup } src_prepare() { local slot orig_s="$S" for slot in $(php_get_slots); do php_init_slot_env ${slot} EPATCH_SOURCE="${FILESDIR}/${PV}" EPATCH_SUFFIX="patch" \ EPATCH_FORCE="yes" epatch edos2unix php-webclient-ajax/config.php.dist AT_M4DIR="autoconf" eautoreconf done append-flags "-fPIC" } src_unpack() { unpack zcp-${MY_PVR}.tar.gz local slot orig_s="$S" for slot in $(php_get_slots); do cp -r "${orig_s}" "${WORKDIR}/${slot}" done if use licensed; then if [[ "${ARCH}" == "amd64" ]]; then unpack zcp-${MY_PV}-ubuntu-12.04-x86_64-supported.tar.gz fi if [[ "${ARCH}" == "x86" ]]; then unpack zcp-${MY_PV}-ubuntu-12.04-i386-supported.tar.gz fi if [[ "${ARCH}" == "arm" ]]; then unpack zcp-${MY_PV}-spk-arm-free.tar unpack $(find ./ -name "package.tgz") mkdir arm pushd arm unpack $(find ./../ -name "zarafa.tgz") popd fi pushd "${WORKDIR}" mkdir licensed cd licensed if [[ "${ARCH}" == "amd64" || "${ARCH}" == "x86" ]]; then unpack_deb $(find ./../ -name "zarafa-licensed*.deb") unpack_deb $(find ./../ -name "zarafa-client*.deb") unpack_deb $(find ./../../ -name "libboost-system1.46.1*.deb") unpack_deb $(find ./../../ -name "libboost-filesystem1.46.1*.deb") unpack_deb $(find ./../../ -name "libssl1.0.0*.deb") unpack_deb $(find ./../../ -name "libicu48*.deb") fi if [[ "${ARCH}" == "arm" ]]; then mv ../arm/zarafa-licensed usr mv usr/bin/zarafa-licensed-arm usr/bin/zarafa-licensed echo "#/bin/sh" > usr/bin/zarafa-report echo "echo \"zarafa-report not ported to arm\"" >> usr/bin/zarafa-report echo "echo \"Please contact zarafa for arm\"" >> usr/bin/zarafa-report echo "echo \"support.\"" >> usr/bin/zarafa-report echo "exit 0" >> usr/bin/zarafa-report mkdir -p etc/zarafa/license mv ../arm/etc/zarafa/licensed.cfg etc/zarafa/ mkdir -p usr/share/doc/zarafa-licensed mv ../arm/share/doc/zarafa/eula.txt usr/share/doc/zarafa-licensed/ mkdir -p usr/share/man/man{1,5} mv ../arm/share/man/man1/zarafa-{licensed,report}.* usr/share/man/man1/ mv ../arm/share/man/man5/zarafa-licensed.cfg.* usr/share/man/man5/ fi popd fi cd "${S}" } src_configure() { append-flags -fpermissive local slot for slot in $(php_get_slots); do php_init_slot_env ${slot} econf \ --enable-oss \ --enable-release \ --enable-unicode \ --enable-epoll \ --with-userscript-prefix=/etc/zarafa/userscripts \ --with-quotatemplate-prefix=/etc/zarafa/quotamails \ --with-searchscripts-prefix=/etc/zarafa/searchscripts \ --with-php-config=${PHPCONFIG} \ $(use_with pic) \ $(use_enable icu) \ $(use_enable static) \ $(use_enable python) \ $(use_enable swig) \ $(use_enable tcmalloc tcmalloc-full) \ $(use_enable profiling) \ $(use_enable sparsehash) \ $(use_enable debug) || die "Unable to configure code to compile" done } src_compile() { local slot for slot in $(php_get_slots); do php_init_slot_env ${slot} find swig -type f | xargs touch emake || die "emake failed" done } src_install() { local slot for slot in $(php_get_slots); do php_init_slot_env ${slot} emake DESTDIR="${D}" install || die "make install failed" done emake DESTDIR="${D}" install-ajax-webaccess || die "make install-ajax-webaccess failed" rm -rf "${D}"/etc/php php-ext-source-r2_createinifiles php-ext-source-r2_addtoinifiles "mapi.debug" "0" if [[ "${ARCH}" == "x86" || "${ARCH}" == "amd64" || "${ARCH}" == "arm" ]]; then if use licensed; then ZARAFA_SERVICES="${ZARAFA_SERVICES} licensed" make_wrapper zarafa-licensed "/opt/zarafa/bin/zarafa-licensed" /opt/zarafa/bin /opt/zarafa/$(get_libdir) make_wrapper zarafa-report "/opt/zarafa/bin/zarafa-report" /opt/zarafa/bin /opt/zarafa/$(get_libdir) into /opt/zarafa dobin "${WORKDIR}"/licensed/usr/bin/zarafa-{licensed,report} || die "Failed to install licensed binaries" dolib.so $(find ${WORKDIR}/licensed -name "*.so*") doman "${WORKDIR}"/licensed/usr/share/man/*/zarafa-* || die "Failed to install man files" dodoc -r "${WORKDIR}"/licensed/usr/share/doc/zarafa-licensed/* || die "Failed to install docs" insinto /etc/zarafa doins -r "${WORKDIR}"/licensed/etc/zarafa/* || die "Failed to install config files" fi fi insinto /etc/apache2/modules.d newins "${FILESDIR}/50_zarafa-webaccess.conf" 50_zarafa-webaccess.conf || die "Failed to install apache config files" rm "${D}"/usr/share/zarafa-webaccess/*.conf || die "Failed to remove apache config files" rm "${D}"/etc/conf.d/zarafa || die "Failed to remove wrong file files" exeinto /etc/zarafa/userscripts/ newexe "${FILESDIR}"/junklearn.dspam junklearn if use logrotate; then insinto /etc/logrotate.d newins installer/linux/zarafa.logrotate zarafa || die "Failed to install logrotate" fi if use ldap; then insinto /etc/openldap/schema doins installer/ldap/zarafa.* || die "Failed to install ldap schema files" fi insinto /etc/zarafa doins installer/linux/*.cfg || die "Failed to install config files" dodir /var/log/zarafa keepdir /var/log/zarafa for service in ${ZARAFA_SERVICES}; do newconfd "${FILESDIR}/zarafa-${service}.confd" "zarafa-${service}" newinitd "${FILESDIR}/zarafa-${service}.initd" "zarafa-${service}" systemd_newunit "${FILESDIR}/zarafa-${service}.service" "zarafa-${service}.service" done dobashcompletion "${FILESDIR}/zarafa-bash-completion.sh" ${PN} }