| 1 |
# Copyright 1999-2012 Gentoo Foundation
|
| 2 |
# Distributed under the terms of the GNU General Public License v2
|
| 3 |
# $Header: /var/cvsroot/gentoo-x86/mail-mta/postfix/postfix-2.9.4.ebuild,v 1.11 2012/10/30 17:10:15 jer Exp $
|
| 4 |
|
| 5 |
EAPI=4
|
| 6 |
|
| 7 |
inherit eutils multilib ssl-cert toolchain-funcs flag-o-matic pam user versionator
|
| 8 |
|
| 9 |
MY_PV="${PV/_rc/-RC}"
|
| 10 |
MY_SRC="${PN}-${MY_PV}"
|
| 11 |
MY_URI="ftp://ftp.porcupine.org/mirrors/postfix-release/official"
|
| 12 |
VDA_PV="2.9.1"
|
| 13 |
VDA_P="${PN}-vda-v11-${VDA_PV}"
|
| 14 |
RC_VER="2.7"
|
| 15 |
|
| 16 |
DESCRIPTION="A fast and secure drop-in replacement for sendmail."
|
| 17 |
HOMEPAGE="http://www.postfix.org/"
|
| 18 |
SRC_URI="${MY_URI}/${MY_SRC}.tar.gz
|
| 19 |
vda? ( http://vda.sourceforge.net/VDA/${VDA_P}.patch ) "
|
| 20 |
|
| 21 |
LICENSE="IBM"
|
| 22 |
SLOT="0"
|
| 23 |
KEYWORDS="alpha amd64 arm hppa ia64 ~mips ppc ppc64 s390 sh sparc x86 ~x86-fbsd"
|
| 24 |
IUSE="+berkdb cdb doc dovecot-sasl hardened ldap ldap-bind memcached mbox mysql nis pam postgres sasl selinux sqlite ssl vda"
|
| 25 |
|
| 26 |
DEPEND=">=dev-libs/libpcre-3.4
|
| 27 |
dev-lang/perl
|
| 28 |
berkdb? ( >=sys-libs/db-3.2 )
|
| 29 |
cdb? ( || ( >=dev-db/tinycdb-0.76 >=dev-db/cdb-0.75-r1 ) )
|
| 30 |
ldap? ( net-nds/openldap )
|
| 31 |
ldap-bind? ( net-nds/openldap[sasl] )
|
| 32 |
mysql? ( virtual/mysql )
|
| 33 |
pam? ( virtual/pam )
|
| 34 |
postgres? ( dev-db/postgresql-base )
|
| 35 |
sasl? ( >=dev-libs/cyrus-sasl-2 )
|
| 36 |
sqlite? ( dev-db/sqlite:3 )
|
| 37 |
ssl? ( >=dev-libs/openssl-0.9.6g )"
|
| 38 |
|
| 39 |
RDEPEND="${DEPEND}
|
| 40 |
dovecot-sasl? ( net-mail/dovecot )
|
| 41 |
memcached? ( net-misc/memcached )
|
| 42 |
net-mail/mailbase
|
| 43 |
selinux? ( sec-policy/selinux-postfix )
|
| 44 |
!mail-mta/courier
|
| 45 |
!mail-mta/esmtp
|
| 46 |
!mail-mta/exim
|
| 47 |
!mail-mta/mini-qmail
|
| 48 |
!mail-mta/msmtp[mta]
|
| 49 |
!mail-mta/netqmail
|
| 50 |
!mail-mta/nullmailer
|
| 51 |
!mail-mta/qmail-ldap
|
| 52 |
!mail-mta/sendmail
|
| 53 |
!<mail-mta/ssmtp-2.64-r2
|
| 54 |
!>=mail-mta/ssmtp-2.64-r2[mta]
|
| 55 |
!net-mail/fastforward"
|
| 56 |
|
| 57 |
REQUIRED_USE="ldap-bind? ( ldap sasl )"
|
| 58 |
|
| 59 |
S="${WORKDIR}/${MY_SRC}"
|
| 60 |
|
| 61 |
pkg_setup() {
|
| 62 |
# Add postfix, postdrop user/group (bug #77565)
|
| 63 |
enewgroup postfix 207
|
| 64 |
enewgroup postdrop 208
|
| 65 |
enewuser postfix 207 -1 /var/spool/postfix postfix,mail
|
| 66 |
}
|
| 67 |
|
| 68 |
src_prepare() {
|
| 69 |
if use vda; then
|
| 70 |
epatch "${DISTDIR}"/${VDA_P}.patch
|
| 71 |
fi
|
| 72 |
|
| 73 |
if ! use berkdb; then
|
| 74 |
epatch "${FILESDIR}/${PN}_no-berkdb.patch"
|
| 75 |
fi
|
| 76 |
|
| 77 |
sed -i -e "/^#define ALIAS_DB_MAP/s|:/etc/aliases|:/etc/mail/aliases|" \
|
| 78 |
src/util/sys_defs.h || die "sed failed"
|
| 79 |
|
| 80 |
# change default paths to better comply with portage standard paths
|
| 81 |
sed -i -e "s:/usr/local/:/usr/:g" conf/master.cf || die "sed failed"
|
| 82 |
}
|
| 83 |
|
| 84 |
src_configure() {
|
| 85 |
# Make sure LDFLAGS get passed down to the executables.
|
| 86 |
local mycc="-DHAS_PCRE" mylibs="${LDFLAGS} -lpcre -lcrypt -lpthread"
|
| 87 |
|
| 88 |
use pam && mylibs="${mylibs} -lpam"
|
| 89 |
|
| 90 |
if use ldap; then
|
| 91 |
mycc="${mycc} -DHAS_LDAP"
|
| 92 |
mylibs="${mylibs} -lldap -llber"
|
| 93 |
fi
|
| 94 |
|
| 95 |
if use mysql; then
|
| 96 |
mycc="${mycc} -DHAS_MYSQL $(mysql_config --include)"
|
| 97 |
mylibs="${mylibs} $(mysql_config --libs)"
|
| 98 |
fi
|
| 99 |
|
| 100 |
if use postgres; then
|
| 101 |
mycc="${mycc} -DHAS_PGSQL -I$(pg_config --includedir)"
|
| 102 |
mylibs="${mylibs} -lpq -L$(pg_config --libdir)"
|
| 103 |
fi
|
| 104 |
|
| 105 |
if use sqlite; then
|
| 106 |
mycc="${mycc} -DHAS_SQLITE"
|
| 107 |
mylibs="${mylibs} -lsqlite3"
|
| 108 |
fi
|
| 109 |
|
| 110 |
if use ssl; then
|
| 111 |
mycc="${mycc} -DUSE_TLS"
|
| 112 |
mylibs="${mylibs} -lssl -lcrypto"
|
| 113 |
fi
|
| 114 |
|
| 115 |
# broken. and "in other words, not supported" by upstream.
|
| 116 |
# Use inet_protocols setting in main.cf
|
| 117 |
#if ! use ipv6; then
|
| 118 |
# mycc="${mycc} -DNO_IPV6"
|
| 119 |
#fi
|
| 120 |
|
| 121 |
if use sasl; then
|
| 122 |
if use dovecot-sasl; then
|
| 123 |
# Set dovecot as default.
|
| 124 |
mycc="${mycc} -DDEF_SASL_SERVER=\\\"dovecot\\\""
|
| 125 |
fi
|
| 126 |
if use ldap-bind; then
|
| 127 |
mycc="${mycc} -DUSE_LDAP_SASL"
|
| 128 |
fi
|
| 129 |
mycc="${mycc} -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl"
|
| 130 |
mylibs="${mylibs} -lsasl2"
|
| 131 |
elif use dovecot-sasl; then
|
| 132 |
mycc="${mycc} -DUSE_SASL_AUTH -DDEF_SERVER_SASL_TYPE=\\\"dovecot\\\""
|
| 133 |
fi
|
| 134 |
|
| 135 |
if ! use nis; then
|
| 136 |
sed -i -e "s|#define HAS_NIS|//#define HAS_NIS|g" \
|
| 137 |
src/util/sys_defs.h || die "sed failed"
|
| 138 |
fi
|
| 139 |
|
| 140 |
if ! use berkdb; then
|
| 141 |
mycc="${mycc} -DNO_DB"
|
| 142 |
if use cdb; then
|
| 143 |
# change default hash format from Berkeley DB to cdb
|
| 144 |
sed -i -e "s/hash/cdb/" src/util/sys_defs.h || die
|
| 145 |
fi
|
| 146 |
fi
|
| 147 |
|
| 148 |
if use cdb; then
|
| 149 |
mycc="${mycc} -DHAS_CDB -I/usr/include/cdb"
|
| 150 |
CDB_LIBS=""
|
| 151 |
# Tinycdb is preferred.
|
| 152 |
if has_version dev-db/tinycdb ; then
|
| 153 |
einfo "Building with dev-db/tinycdb"
|
| 154 |
CDB_LIBS="-lcdb"
|
| 155 |
else
|
| 156 |
einfo "Building with dev-db/cdb"
|
| 157 |
CDB_PATH="/usr/$(get_libdir)"
|
| 158 |
for i in cdb.a alloc.a buffer.a unix.a byte.a ; do
|
| 159 |
CDB_LIBS="${CDB_LIBS} ${CDB_PATH}/${i}"
|
| 160 |
done
|
| 161 |
fi
|
| 162 |
mylibs="${mylibs} ${CDB_LIBS}"
|
| 163 |
fi
|
| 164 |
|
| 165 |
# Robin H. Johnson <robbat2@gentoo.org> 17/Nov/2006
|
| 166 |
# Fix because infra boxes hit 2Gb .db files that fail a 32-bit fstat signed check.
|
| 167 |
mycc="${mycc} -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE"
|
| 168 |
filter-lfs-flags
|
| 169 |
|
| 170 |
# Workaround for bug #76512
|
| 171 |
if use hardened; then
|
| 172 |
[[ "$(gcc-version)" == "3.4" ]] && replace-flags -O? -Os
|
| 173 |
fi
|
| 174 |
|
| 175 |
# Remove annoying C++ comment style warnings - bug #378099
|
| 176 |
append-flags -Wno-comment
|
| 177 |
|
| 178 |
sed -i -e "/^RANLIB/s/ranlib/$(tc-getRANLIB)/g" "${S}"/makedefs
|
| 179 |
sed -i -e "/^AR/s/ar/$(tc-getAR)/g" "${S}"/makedefs
|
| 180 |
emake DEBUG="" CC="$(tc-getCC)" OPT="${CFLAGS}" CCARGS="${mycc}" AUXLIBS="${mylibs}" makefiles
|
| 181 |
}
|
| 182 |
|
| 183 |
src_install () {
|
| 184 |
local myconf
|
| 185 |
use doc && myconf="readme_directory=\"/usr/share/doc/${PF}/readme\" \
|
| 186 |
html_directory=\"/usr/share/doc/${PF}/html\""
|
| 187 |
|
| 188 |
/bin/sh postfix-install \
|
| 189 |
-non-interactive \
|
| 190 |
install_root="${D}" \
|
| 191 |
config_directory="/etc/postfix" \
|
| 192 |
manpage_directory="/usr/share/man" \
|
| 193 |
command_directory="/usr/sbin" \
|
| 194 |
mailq_path="/usr/bin/mailq" \
|
| 195 |
newaliases_path="/usr/bin/newaliases" \
|
| 196 |
sendmail_path="/usr/sbin/sendmail" \
|
| 197 |
${myconf} \
|
| 198 |
|| die "postfix-install failed"
|
| 199 |
|
| 200 |
# Fix spool removal on upgrade
|
| 201 |
rm -Rf "${D}"/var
|
| 202 |
keepdir /var/spool/postfix
|
| 203 |
|
| 204 |
# Install rmail for UUCP, closes bug #19127
|
| 205 |
dobin auxiliary/rmail/rmail
|
| 206 |
|
| 207 |
# Provide another link for legacy FSH
|
| 208 |
dosym /usr/sbin/sendmail /usr/$(get_libdir)/sendmail
|
| 209 |
|
| 210 |
# Install qshape tool
|
| 211 |
dobin auxiliary/qshape/qshape.pl
|
| 212 |
doman man/man1/qshape.1
|
| 213 |
|
| 214 |
# Performance tuning tools and their manuals
|
| 215 |
dosbin bin/smtp-{source,sink} bin/qmqp-{source,sink}
|
| 216 |
doman man/man1/smtp-{source,sink}.1 man/man1/qmqp-{source,sink}.1
|
| 217 |
|
| 218 |
# Set proper permissions on required files/directories
|
| 219 |
dodir /var/lib/postfix
|
| 220 |
keepdir /var/lib/postfix
|
| 221 |
fowners -R postfix:postfix /var/lib/postfix
|
| 222 |
fperms 0750 /var/lib/postfix
|
| 223 |
fowners root:postdrop /usr/sbin/post{drop,queue}
|
| 224 |
fperms 02711 /usr/sbin/post{drop,queue}
|
| 225 |
|
| 226 |
keepdir /etc/postfix
|
| 227 |
if use mbox; then
|
| 228 |
mypostconf="mail_spool_directory=/var/spool/mail"
|
| 229 |
else
|
| 230 |
mypostconf="home_mailbox=.maildir/"
|
| 231 |
fi
|
| 232 |
"${D}"/usr/sbin/postconf -c "${D}"/etc/postfix \
|
| 233 |
-e ${mypostconf} || die "postconf failed"
|
| 234 |
|
| 235 |
insinto /etc/postfix
|
| 236 |
newins "${FILESDIR}"/smtp.pass saslpass
|
| 237 |
fperms 600 /etc/postfix/saslpass
|
| 238 |
|
| 239 |
newinitd "${FILESDIR}"/postfix.rc6.${RC_VER} postfix
|
| 240 |
# do not start mysql/postgres unnecessarily - bug #359913
|
| 241 |
use mysql || sed -i -e "s/mysql //" "${D}/etc/init.d/postfix"
|
| 242 |
use postgres || sed -i -e "s/postgresql //" "${D}/etc/init.d/postfix"
|
| 243 |
|
| 244 |
dodoc *README COMPATIBILITY HISTORY PORTING RELEASE_NOTES*
|
| 245 |
mv "${D}"/etc/postfix/{*.default,makedefs.out} "${D}"/usr/share/doc/${PF}/
|
| 246 |
use doc && mv "${S}"/examples "${D}"/usr/share/doc/${PF}/
|
| 247 |
|
| 248 |
pamd_mimic_system smtp auth account
|
| 249 |
|
| 250 |
if use sasl; then
|
| 251 |
insinto /etc/sasl2
|
| 252 |
newins "${FILESDIR}"/smtp.sasl smtpd.conf
|
| 253 |
fi
|
| 254 |
|
| 255 |
# header files
|
| 256 |
insinto /usr/include/postfix
|
| 257 |
doins include/*.h
|
| 258 |
|
| 259 |
# Remove unnecessary files
|
| 260 |
rm -f "${D}"/etc/postfix/{*LICENSE,access,aliases,canonical,generic}
|
| 261 |
rm -f "${D}"/etc/postfix/{header_checks,relocated,transport,virtual}
|
| 262 |
}
|
| 263 |
|
| 264 |
pkg_preinst() {
|
| 265 |
# default for inet_protocols changed from ipv4 to all in postfix-2.9.
|
| 266 |
# check inet_protocols setting in main.cf and modify if necessary to prevent
|
| 267 |
# performance loss with useless DNS lookups and useless connection attempts.
|
| 268 |
[[ -d ${ROOT}/etc/postfix ]] && {
|
| 269 |
if [[ "$(${D}/usr/sbin/postconf -dh inet_protocols)" != "ipv4" ]]; then
|
| 270 |
if [[ ! -n "$(${D}/usr/sbin/postconf -c ${ROOT}/etc/postfix -nh inet_protocols)" ]];
|
| 271 |
then
|
| 272 |
ewarn "\nCOMPATIBILITY: adding inet_protocols=ipv4 to main.cf."
|
| 273 |
ewarn "That will keep the same behaviour as previous postfix versions."
|
| 274 |
ewarn "Specify inet_protocols explicitly if you want to enable IPv6.\n"
|
| 275 |
else
|
| 276 |
# delete inet_protocols setting. there is already one in /etc/postfix
|
| 277 |
sed -i -e /inet_protocols/d "${D}"/etc/postfix/main.cf || die
|
| 278 |
fi
|
| 279 |
fi
|
| 280 |
}
|
| 281 |
}
|
| 282 |
|
| 283 |
pkg_postinst() {
|
| 284 |
# Do not install server.{key,pem) SSL certificates if they already exist
|
| 285 |
if use ssl && [[ ! -f "${ROOT}"/etc/ssl/postfix/server.key \
|
| 286 |
&& ! -f "${ROOT}"/etc/ssl/postfix/server.pem ]] ; then
|
| 287 |
SSL_ORGANIZATION="${SSL_ORGANIZATION:-Postfix SMTP Server}"
|
| 288 |
install_cert /etc/ssl/postfix/server
|
| 289 |
chown postfix:mail "${ROOT}"/etc/ssl/postfix/server.{key,pem}
|
| 290 |
fi
|
| 291 |
|
| 292 |
if [[ ! -e /etc/mail/aliases.db ]] ; then
|
| 293 |
ewarn
|
| 294 |
ewarn "You must edit /etc/mail/aliases to suit your needs"
|
| 295 |
ewarn "and then run /usr/bin/newaliases. Postfix will not"
|
| 296 |
ewarn "work correctly without it."
|
| 297 |
ewarn
|
| 298 |
fi
|
| 299 |
|
| 300 |
if [[ $(get_version_component_range 2 ${REPLACING_VERSIONS}) -lt 9 ]]; then
|
| 301 |
elog "If you are using old style postfix instances by symlinking"
|
| 302 |
elog "startup scripts in ${ROOT}etc/init.d, please consider"
|
| 303 |
elog "upgrading your config for postmulti support. For more info:"
|
| 304 |
elog "http://www.postfix.org/MULTI_INSTANCE_README.html"
|
| 305 |
if ! use berkdb; then
|
| 306 |
ewarn "\nPostfix is installed without BerkeleyDB support."
|
| 307 |
ewarn "Please turn on berkdb USE flag for hash or btree table"
|
| 308 |
ewarn "lookup support.\n"
|
| 309 |
fi
|
| 310 |
ewarn "Postfix daemons now live under /usr/libexec/postfix"
|
| 311 |
ewarn "Please adjust your main.cf accordingly by running"
|
| 312 |
ewarn "etc-update/dispatch-conf or similar and accepting the new"
|
| 313 |
ewarn "daemon_directory setting."
|
| 314 |
fi
|
| 315 |
}
|