# Copyright 1999-2005 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ inherit eutils webapp ssl-cert toolchain-funcs java-pkg versionator depend.apache MY_PV=$(replace_version_separator 3 '-') MY_P="${PN}-${MY_PV}" DESCRIPTION="A Collaboration and Integration Server Environment" HOMEPAGE="http://www.open-xchange.org/" SRC_URI="http://mirror.open-xchange.org/download/${MY_P}.tar.bz2 http://www.mikefetherston.ca/OX/Crystal_OX_Theme.tgz" LICENSE="GPL-2" KEYWORDS="~x86" RESTRICT="primaryuri" IUSE="ssl doc webdav mysql postgres" S="${WORKDIR}/${MY_P}" RDEPEND=">=virtual/jre-1.4 >=dev-java/java-config-1.2 >=www-servers/tomcat-5.0.27-r6 dev-perl/Net-SSLeay dev-java/jdom net-nds/openldap app-text/ispell dev-java/sun-javamail-bin dev-perl/XML-NamespaceSupport dev-perl/XML-SAX-Base dev-perl/Authen-SASL dev-perl/Convert-ASN1 dev-perl/perl-ldap net-www/webapp-config mysql? ( !postgres? ( dev-java/jdbc-mysql >=dev-db/mysql-4.1 ) ) !mysql? ( ~dev-java/jdbc3-postgresql-7.4.5 dev-db/postgresql ) postgres? ( ~dev-java/jdbc3-postgresql-7.4.5 dev-db/postgresql ) ssl? ( dev-libs/openssl dev-perl/IO-Socket-SSL )" # COMMENT: Why is the jdbc requirement set to 7.4.5 and now >=7.4.5? DEPEND="${RDEPEND} >=virtual/jdk-1.4" RDEPEND="${RDEPEND} www-apache/mod_jk app-admin/sudo" use_postgres() { use postgres || ! use mysql } pkg_setup() { # COMMENT: Don't use the environment variables for them here. You shouldn't have these set here... just down in pkg_config(). if [[ -z ${OX_DBHOST} ]] ; then einfo " " ewarn "The environment \$OX_DBHOST was not set, it is used for the correct location of the database server. I will take the default" ewarn "value 'localhost'. " einfo " " OX_DBHOST="localhost" FAIL=1 fi if [[ -z ${OX_DBNAME} ]] ; then einfo " " ewarn "The environment \$OX_DBNAME was not set, it is used for the correct name of the database. I will take the default" ewarn "value 'open_xchange'. " einfo " " OX_DBNAME="open_xchange" FAIL=1 fi if [[ -z ${OX_DBUSER} ]] ; then einfo " " ewarn "The environment \$OX_DBUSER was not set, it is used for the user accessing the database. I will take the default" ewarn "value 'open_xchange'." einfo " " OX_DBUSER="open_xchange" FAIL=1 fi if [[ -z ${OX_DBPASS} ]] ; then einfo " " ewarn "The environment \$OX_DBPASS was not set, it used for accessing the database. I will take the default" ewarn "value 'xxx'." einfo " " OX_DBPASS="xxx" FAIL=1 fi if [[ -z ${OX_DOMAIN} ]] ; then einfo " " ewarn "The environment \$OX_DOMAIN was not set. I will take the default" ewarn "value 'example.org'." einfo " " OX_DOMAIN="example.org" FAIL=1 fi if [[ -z ${OX_ORG} ]] ; then einfo " " ewarn "The environment \$OX_ORG was not set. I will take the default" ewarn "value 'Example Org'." einfo " " OX_ORG="Example Org" FAIL=1 fi if [[ -z ${OX_BASEDN} ]] ; then einfo " " ewarn "The environment \$OX_BASEDN was not set. I will take the default" ewarn "value 'dc=example,dc=org'." einfo " " OX_BASEDN="dc=example,dc=org" FAIL=1 fi if [[ -z ${OX_ROOTDN} ]] ; then einfo " " ewarn "The environment \$OX_ROOTDN was not set. I will take the default" ewarn "value 'cn=Manager,${OX_BASEDN}'." einfo " " OX_ROOTDN="cn=Manager,${OX_BASEDN}" FAIL=1 fi if [[ -z ${OX_ROOTPW} ]] ; then einfo " " ewarn "The environment \$OX_ROOTPW was not set, it is used for accesing the LDAP-Server." ewarn " I will take the default" ewarn "value 'secret'." einfo " " OX_ROOTPW="secret" FAIL=1 fi if [[ ${FAIL} -eq 1 ]] ; then ewarn "If you don't want to use the default values then hit " ewarn "to cancel and set the environment before emerging open-xchange." einfo " " echo -ne " >>> " for TICKER in 1 2 3 4 5 6 7 8; do # Double beep here. echo -ne "$TICKER " echo -ne "\a" ; sleep 0.1 &>/dev/null ; sleep 0,1 &>/dev/null echo -ne "\a" ; sleep 1 done sleep 5 echo " " fi TOMCAT_DIR=`java-config -g CATALINA_HOME` if has_version '>=www-servers/tomcat-5.0.28-r4' ; then # it is now installed to the profile-directory choosen from /etc/conf.d/tomcat-5 local PROFILE="$(sed -n "s:^PROFILE=\(.*\):\1:p" /etc/conf.d/tomcat-5)" local CATALINA_BASE="$(sed -n "s:^CATALINA_BASE=\(.*\)/$.*:\1:p" /etc/conf.d/tomcat-5)" SERVLETDIR="${CATALINA_BASE}/${PROFILE}/webapps" else SERVLETDIR="${TOMCAT_DIR}/webapps" fi webapp_pkg_setup } src_unpack() { unpack ${A} cd ${S} # reported bug at open-xchang.org #656 sed -i "s|\${DESTDIR}|\$(DESTDIR)|g" Makefile.am export WANT_AUTOMAKE=1.8 export WANT_AUTOCONF=2.5 libtoolize --force --copy || die aclocal -I m4 || die automake -a -f -c || die autoheader || die autoconf || die # doing all preconfigure which can be done here # correct ispell-handling of german dictionary sed -i "s|-ddeutsch|-dgerman|g" conf/webmail/spellcheck.cfg if use ssl; then # change login.pm-script if ssl should be used sed -i "s|connection_mode = 3;|connection_mode = 2;|g" src/misc/login/login.pm.in fi # change image- and link- to the open-xchange location find groupware/ -regex '.*\.htm' |xargs sed -i "s|/cfintranet/|/open-xchange/cfintranet/|g" find templates/ -regex '.*\.htm' |xargs sed -i "s|/cfintranet/|/open-xchange/cfintranet/|g" find webmail/ -regex '.*\.htm' |xargs sed -i "s|/cfintranet/|/open-xchange/cfintranet/|g" find templates/ -regex '.*\.lang' |xargs sed -i "s|/cfintranet/|/open-xchange/cfintranet/|g" find system/www/ -regex '.*\.htm' |xargs sed -i "s|/cfintranet/|/open-xchange/cfintranet/|g" find system/www/ -regex '.*\.js' |xargs sed -i "s|/cfintranet/|/open-xchange/cfintranet/|g" sed -i "s|/cfintranet/|/open-xchange/cfintranet/|g" conf/groupware/system.properties.in sed -i "s|/cfintranet/|/open-xchange/cfintranet/|g" conf/webmail/system.properties.in } src_compile() { local myconf local tempvar if use_postgres ; then tempvar="$(java-config --classpath=$(java-config -l | sed -n "s:^\[\(jdbc[^-]*-postgresql[^]]*\).*:\1:p" | head -n 1))" if [[ -f "${tempvar}" && "${tempvar}" != "" ]]; then myconf="${myconf} --with-jdbcjar=$(java-config --classpath=$(java-config -l | sed -n "s:^\[\(jdbc[^-]*-postgresql[^]]*\).*:\1:p" | head -n 1))" else myconf="${myconf} --with-jdbcjar=/usr/share/jdbc3-postgresql/lib/jdbc3-postgresql.jar" fi myconf="${myconf} --with-dbdriver=org.postgresql.Driver" else tempvar="$(java-config --classpath=$(java-config -l | sed -n "s:^\[\(jdbc[^-]*-mysql[^]]*\).*:\1:p" | head -n 1))" if [[ -f "${tempvar}" && "${tempvar}" != "" ]]; then myconf="${myconf} --with-jdbcjar=$(java-config --classpath=$(java-config -l | sed -n "s:^\[\(jdbc[^-]*-mysql[^]]*\).*:\1:p" | head -n 1))" else myconf="${myconf} --with-jdbcjar=/usr/share/jdbc-mysql/lib/mysql-connector-java-3.0.11-stable-bin.jar" fi myconf="${myconf} --with-dbdriver=com.mysql.jdbc.Driver" fi myconf="${myconf} $(use_enable doc) $(use_enable webdav) $(use_enable ssl)" # Servlet API # COMMENT: This stuff shouldn't be set in here. myconf="${myconf} --with-dbname=${OX_DBNAME}" myconf="${myconf} --with-dbuser=${OX_DBUSER}" myconf="${myconf} --with-dbpass=${OX_DBPASS}" myconf="${myconf} --with-domain=${OX_DOMAIN}" myconf="${myconf} --with-organization=${OX_ORG}" myconf="${myconf} --with-basedn=${OX_BASEDN}" myconf="${myconf} --with-rootdn=${OX_ROOTDN}" myconf="${myconf} --with-rootpw=${OX_ROOTPW}" myconf="${myconf} --with-servletdir=${SERVLETDIR}" if has_version '>=www-servers/tomcat-5.0.28-r4' ; then myconf="${myconf} --with-jsdkjar=${TOMCAT_DIR}/common/lib/servlet-api.jar" else myconf="${myconf} --with-jsdkjar=/usr/share/servletapi-2.4/lib/servlet-api.jar" fi myconf="${myconf} --with-mailjar=/usr/share/sun-javamail-bin/lib/mail.jar" myconf="${myconf} --with-activationjar=/usr/share/sun-jaf-bin/lib/activation.jar" myconf="${myconf} --with-jdomjar=$(java-config --classpath=$(java-config -l | sed -n "s:^\[\(jdom[^]]*\).*:\1:p" | head -n 1))" myconf="${myconf} --with-xercesjar=/usr/share/xerces-2/lib/xercesImpl.jar" myconf="${myconf} --with-jni-dir=$(java-config -O)/include" myconf="${myconf} --with-runuid=tomcat" myconf="${myconf} --with-rungid=tomcat" myconf="${myconf} --with-tomcatuser=tomcat" myconf="${myconf} --with-htdocsdir=${MY_HTDOCSDIR}" myconf="${myconf} --with-cgibindir=${MY_CGIBINDIR}" myconf="${myconf} --sysconfdir=/etc/open-xchange" myconf="${myconf} --datadir=/usr/share/open-xchange" myconf="${myconf} --includedir=/usr/include/open-xchange" myconf="${myconf} --libdir=/usr/$(get_libdir)/open-xchange" myconf="${myconf} --localstatedir=/var/open-xchange" econf ${myconf} || die "bad ./configure" # replace the string "jikes" with "modern". We dont want to see all jikes warnings sed -i "s|jikes|modern|g" build.xml emake -j1 || die "make failed" # use sudo instead of su for the startup script and # correct var-log for foo in groupware sessiond webmail ; do sed -i "s:^\([\t ]*\)\(su \$USER.*$\):\1#\2:gI;s:^\([\t ]*\)#\(sudo -u \$USER.*\)$:\1\2:gI" system/etc/init.d/${foo} sed -i "s|open-xchange/log|log/open-xchange|g" system/etc/init.d/${foo} done sed -i "s|open-xchange/log|log/open-xchange|g" conf/groupware/system.properties } src_install() { webapp_src_preinst dodoc AUTHORS ChangeLog INSTALL NEWS README # Install this big thing cd ${S} make DESTDIR=${D} install || die "Failed on make install" # copy the ldif.in file for better config-abilities in pkg_preinst cp ${S}/system/setup/init_ldap.ldif.in ${D}/usr/share/open-xchange/init_ldap.ldif # remove obsolete log-files they should be saved in /var/log/open-xchange rm ${D}/var/open-xchange/log/groupware.log rm ${D}/var/open-xchange/log/jserv.log rm ${D}/var/open-xchange/log/sessiond.log rm ${D}/var/open-xchange/log/webmail.log rmdir ${D}/var/open-xchange/log/ # create log-dir keepdir /var/log/open-xchange # remove unessary war-files, they are needed for deploying application rm ${D}/usr/lib/open-xchange/*.war # remove empty include-dir rmdir ${D}/usr/include/open-xchange/ rmdir ${D}/usr/include/ # remove unneeded init-script - not used by gentoo rm ${D}/etc/open-xchange/init.d/openexchange # Init script newinitd "${FILESDIR}/init.d.open-xchange" open-xchange || die "newinitd failed" if has_version '