# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/mail-mta/postfix/postfix-2.3.8-r1.ebuild,v 1.11 2008/07/22 17:44:21 dertobi123 Exp $

# NOTE: this ebuild is regular ebuild without mailer-config support
# comment lines below "regular ebuild" and uncomment lines below "mailer-config support"
# to turn this ebuild to mailer-config supported ebuild.

# regular ebuild
inherit eutils ssl-cert toolchain-funcs flag-o-matic pam
# mailer-config support.
#inherit eutils ssl-cert toolchain-funcs flag-o-matic mailer pam

# regular ebuild.
IUSE="ipv6 pam ldap mysql postgres ssl sasl dovecot-sasl mailwrapper mbox nis selinux hardened cdb vda"
# mailer-config support.
#IUSE="ipv6 pam ldap mysql postgres ssl sasl dovecot-sasl mbox nis selinux hardened cdb"

MY_PV=${PV/_rc/-RC}
MY_SRC=${PN}-${MY_PV}
MY_URI="ftp://ftp.porcupine.org/mirrors/postfix-release/official"
VDA_VER=2.3.3
VDA_P="${PN}-${VDA_VER}-vda"
RC_VER="2.2.9"

DESCRIPTION="A fast and secure drop-in replacement for sendmail."
HOMEPAGE="http://www.postfix.org/"
SRC_URI="${MY_URI}/${MY_SRC}.tar.gz
	vda? ( http://web.onda.com.br/nadal/postfix/VDA/${VDA_P}.patch.gz ) "
#	devel? ( ftp://ftp.porcupine.org/mirrors/postfix-release/experimental/${DEV_SRC}.tar.gz ) "

LICENSE="IPL-1"
SLOT="0"
#KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86"
KEYWORDS="alpha amd64 arm hppa ia64 ppc ppc64 s390 sh sparc x86 ~x86-fbsd"

# regular ebuild.
PROVIDE="virtual/mta virtual/mda"
# mailer-config support.
#PROVIDE="${PROVIDE} virtual/mda"

DEPEND="cdb? ( || ( >=dev-db/cdb-0.75-r1 >=dev-db/tinycdb-0.74 ) )
	>=sys-libs/db-3.2
	>=dev-libs/libpcre-3.4
	pam? ( virtual/pam )
	ldap? ( >=net-nds/openldap-1.2 )
	mysql? ( virtual/mysql )
	postgres? ( virtual/postgresql-base )
	ssl? ( >=dev-libs/openssl-0.9.6g )
	sasl? (  >=dev-libs/cyrus-sasl-2 )"

# regular ebuild.
RDEPEND="${DEPEND}
	>=net-mail/mailbase-0.00
	!mailwrapper? (
		!virtual/mta
		!net-mail/mailwrapper
	)
	mailwrapper? ( >=net-mail/mailwrapper-0.2 )
	selinux? ( sec-policy/selinux-postfix )"

# mailer-config support.
#RDEPEND="${DEPEND}
#	>=net-mail/mailbase-0.00
#	selinux? ( sec-policy/selinux-postfix )"

#if use devel; then
#	MY_SRC=${DEV_SRC}
#fi

S=${WORKDIR}/${MY_SRC}

group_user_check() {
	einfo "checking for postfix group...	create if missing."
	enewgroup postfix 207
	einfo "checking for postdrop group...	create if missing."
	enewgroup postdrop 208
	einfo "checking for postfix user...		create if missing."
	enewuser postfix 207 -1 /var/spool/postfix postfix,mail
}

pkg_setup() {
	# do not upgrade live from postfix <2.3.
	if [[ -f /var/lib/init.d/started/postfix ]] ; then
		if has_version '