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