# Copyright 2003 Andreas Simon # Distributed under the terms of the GNU General Public License v2 # $Header: $ IUSE="debug ipv6 ldap maildir pam postgres sasl ssl vpopmail nopop3d" inherit base DESCRIPTION="An IMAP and POP3 server written with security primarily in mind" HOMEPAGE="http://dovecot.procontrol.fi/" SRC_URI="${HOMEPAGE}/${P}.tar.gz" SLOT="0" LICENSE="LGPL-2.1" KEYWORDS="~x86" #PROVIDE="virtual/imapd" DEPEND=">=sys-libs/db-3.2 >=sys-apps/sed-4 ldap? ( >=net-nds/openldap-1.2 ) pam? ( sys-libs/pam ) sasl? ( >=dev-libs/cyrus-sasl-2.1 ) ssl? ( >=dev-libs/openssl-0.9.6g ) postgres? ( dev-db/postgresql ) vpopmail? ( net-mail/vpopmail )" RDEPEND="${DEPEND} net-mail/mailbase" pkg_setup() { # Add user and group for login process if ! grep -q ^dovecot: /etc/group ; then groupadd dovecot || die "problem adding group dovecot" fi if ! grep -q ^dovecot: /etc/passwd ; then useradd -c dovecot -d /usr/libexec/dovecot -g dovecot \ -s /bin/false dovecot || die "problem adding user dovecot" fi } src_unpack() { unpack ${P}.tar.gz } src_compile() { local myconf use debug && myconf="--enable-debug" use ldap && myconf="${myconf} --with-ldap" use ipv6 || myconf="${myconf} --disable-ipv6" use nopop3d && myconf="${myconf} --without-pop3d" use pam || myconf="${myconf} --without-pam" use postgres && myconf="${myconf} --with-pgsql" use sasl && myconf="${myconf} --with-cyrus-sasl2" use ssl || myconf="${myconf} --without-ssl" use vpopmail || myconf="${myconf} --without-vpopmail" ./configure ${myconf} \ --prefix=/usr \ --sysconfdir=/etc \ --localstatedir=/var \ --host=${CHOST} \ || die emake || die } src_install () { make DESTDIR=${D} install || die # If /etc/dovecot.conf doesn't already exist, install a copy of # dovecot-example.conf, changing the default mailbox locations to # Gentoo's default ($HOME/.maildiir/ or /var/spool/mail/$USER) if [ ! -f /etc/dovecot.conf ]; then cd ${D}/etc if [ "`use maildir`" ]; then sed s/^#default_mail_env.*$/default_mail_env\ =\ maildir:%h\\/.maildir/ dovecot-example.conf > dovecot.conf else sed s/^#default_mail_env.*$/default_mail_env\ =\ mbox:\\/var\\/spool\\/mail\\/%u/ dovecot-example.conf > dovecot.conf fi cd - fi rm -f ${D}/etc/dovecot-example.conf # Documentation rm -fr ${D}/usr/share/doc/dovecot cd ${S} dodoc AUTHORS COPYING* NEWS README TODO dovecot-example.conf dodoc doc/*.txt doc/*.conf doc/*.cnf # per default dovecot wants it ssl cert called dovecot.pem # fix this in mkcert.sh, which we use to generate the ssl certs cd ${S}/doc mv mkcert.sh mkcert.sh.tmp sed s/imapd.pem/dovecot.pem/g mkcert.sh.tmp > mkcert.sh dodoc mkcert.sh # rc script exeinto /etc/init.d doexe ${FILESDIR}/init.d/dovecot # PAM if [ "`use pam`" ]; then dodir /etc/pam.d insinto /etc/pam.d doins ${FILESDIR}/pam.d/dovecot fi # Create SSL certificates if [ "`use ssl`" ]; then cd ${S}/doc dodir /etc/ssl/certs dodir /etc/ssl/private [ -f /etc/ssl/certs/dovecot.pem -a -f /etc/ssl/private/dovecot.pem ] \ || SSLDIR=${D}/etc/ssl sh mkcert.sh fi } pkg_postinst() { # Needed directories install -m0700 -o root -g root -d ${ROOT}/var/run/dovecot install -m0750 -o root -g dovecot -d ${ROOT}/var/run/dovecot/login if [ "`use pam`" ]; then ewarn "If you are upgrading from Dovecot prior to 0.99.10, be aware" ewarn "that the PAM profile was changed from 'imap' to 'dovecot'." ewarn "Please review /etc/pam.d/dovecot." fi }