| 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-filter/opendkim/opendkim-2.4.3.ebuild,v 1.3 2012/03/24 17:18:11 phajdan.jr Exp $ |
| 4 |
|
| 5 |
EAPI=4 |
| 6 |
|
| 7 |
inherit eutils db-use user |
| 8 |
|
| 9 |
# for betas |
| 10 |
#MY_P=${P/_b/.B} |
| 11 |
#S=${WORKDIR}/${PN}-2.0.0 |
| 12 |
#SRC_URI="mirror://sourceforge/opendkim/${MY_P}.tar.gz" |
| 13 |
|
| 14 |
DESCRIPTION="A milter-based application to provide DKIM signing and verification" |
| 15 |
HOMEPAGE="http://opendkim.org" |
| 16 |
SRC_URI="mirror://sourceforge/opendkim/${P}.tar.gz" |
| 17 |
|
| 18 |
LICENSE="Sendmail-Open-Source BSD" |
| 19 |
SLOT="0" |
| 20 |
KEYWORDS="amd64 x86" |
| 21 |
IUSE="asyncdns +berkdb ldap lua opendbx poll sasl +ssl static-libs unbound" |
| 22 |
|
| 23 |
# FUTURE: diffheaders (libtre error) - bug #296813 |
| 24 |
|
| 25 |
DEPEND="|| ( mail-filter/libmilter mail-mta/sendmail ) |
| 26 |
ssl? ( >=dev-libs/openssl-0.9.8 ) |
| 27 |
berkdb? ( >=sys-libs/db-3.2 ) |
| 28 |
opendbx? ( >=dev-db/opendbx-1.4.0 ) |
| 29 |
lua? ( dev-lang/lua ) |
| 30 |
ldap? ( net-nds/openldap ) |
| 31 |
sasl? ( dev-libs/cyrus-sasl ) |
| 32 |
unbound? ( >=net-dns/unbound-1.4.1 net-dns/dnssec-root )" |
| 33 |
#diffheaders? ( dev-libs/tre ) |
| 34 |
#gnutls? ( >=net-libs/gnutls-2.11.7 ) |
| 35 |
|
| 36 |
RDEPEND="${DEPEND}" |
| 37 |
|
| 38 |
REQUIRED_USE="sasl? ( ldap ) |
| 39 |
lua? ( berkdb )" |
| 40 |
|
| 41 |
pkg_setup() { |
| 42 |
enewgroup milter |
| 43 |
# mail-milter/spamass-milter creates milter user with this home directory |
| 44 |
# For consistency reasons, milter user must be created here with this home directory |
| 45 |
# even though this package doesn't need a home directory for this user (#280571) |
| 46 |
enewuser milter -1 -1 /var/lib/milter milter |
| 47 |
} |
| 48 |
|
| 49 |
src_prepare() { |
| 50 |
sed -i -e 's:/var/db/dkim:/etc/opendkim:g' \ |
| 51 |
-e 's:/var/db/opendkim:/var/lib/opendkim:g' \ |
| 52 |
-e 's:/etc/mail:/etc/opendkim:g' \ |
| 53 |
-e 's:mailnull:milter:g' \ |
| 54 |
-e 's:^#[[:space:]]*PidFile.*:PidFile /var/run/opendkim/opendkim.pid:' \ |
| 55 |
opendkim/opendkim.conf.sample opendkim/opendkim.conf.simple.in \ |
| 56 |
contrib/stats/opendkim-reportstats || die |
| 57 |
} |
| 58 |
|
| 59 |
src_configure() { |
| 60 |
local myconf |
| 61 |
if use berkdb ; then |
| 62 |
myconf=$(db_includedir) |
| 63 |
myconf="--with-db-incdir=${myconf#-I}" |
| 64 |
myconf+=" --enable-popauth" |
| 65 |
myconf+=" --enable-query_cache" |
| 66 |
myconf+=" --enable-report_intervals" |
| 67 |
myconf+=" --enable-stats" |
| 68 |
fi |
| 69 |
if use asyncdns ; then |
| 70 |
if use unbound; then |
| 71 |
myconf+=" --with-unbound" |
| 72 |
else |
| 73 |
myconf+=" --enable-arlib" |
| 74 |
fi |
| 75 |
else |
| 76 |
myconf+=" $(use_with unbound) --disable-arlib" |
| 77 |
fi |
| 78 |
if use ldap; then |
| 79 |
myconf+=" $(use_with sasl)" |
| 80 |
fi |
| 81 |
econf \ |
| 82 |
$(use_with berkdb db) \ |
| 83 |
$(use_with opendbx odbx) \ |
| 84 |
$(use_with lua) \ |
| 85 |
$(use_enable lua statsext) \ |
| 86 |
$(use_enable lua rbl) \ |
| 87 |
$(use_with ldap openldap) \ |
| 88 |
$(use_enable ldap ldap_caching) \ |
| 89 |
$(use_enable poll) \ |
| 90 |
$(use_enable static-libs static) \ |
| 91 |
${myconf} \ |
| 92 |
--docdir=/usr/share/doc/${PF} \ |
| 93 |
--enable-filter \ |
| 94 |
--without-domainkeys \ |
| 95 |
--enable-oversign \ |
| 96 |
--enable-adsp_lists \ |
| 97 |
--enable-dkim_reputation \ |
| 98 |
--enable-identity_header \ |
| 99 |
--enable-rate_limit \ |
| 100 |
--enable-redirect \ |
| 101 |
--enable-resign \ |
| 102 |
--enable-replace_rules \ |
| 103 |
--enable-selector_header \ |
| 104 |
--enable-default_sender \ |
| 105 |
--enable-sender_macro \ |
| 106 |
--enable-vbr \ |
| 107 |
--disable-rpath \ |
| 108 |
--disable-live-testing |
| 109 |
#$(use_enable diffheaders) |
| 110 |
} |
| 111 |
|
| 112 |
src_install() { |
| 113 |
emake DESTDIR="${D}" install |
| 114 |
# file collision |
| 115 |
rm -f "${D}"/usr/share/man/man3/ar.3 |
| 116 |
|
| 117 |
dosbin contrib/stats/opendkim-reportstats |
| 118 |
newinitd "${FILESDIR}/opendkim.init.r2" opendkim |
| 119 |
dodir /etc/opendkim /var/lib/opendkim |
| 120 |
fowners milter:milter /var/lib/opendkim |
| 121 |
|
| 122 |
# default configuration |
| 123 |
if [ ! -f "${ROOT}"/etc/opendkim/opendkim.conf ]; then |
| 124 |
grep ^[^#] "${S}"/opendkim/opendkim.conf.simple \ |
| 125 |
> "${D}"/etc/opendkim/opendkim.conf |
| 126 |
if use unbound; then |
| 127 |
echo TrustedAnchorFile /etc/dnssec/root-anchors.txt >> "${D}"/etc/opendkim/opendkim.conf |
| 128 |
fi |
| 129 |
echo UserID milter >> "${D}"/etc/opendkim/opendkim.conf |
| 130 |
if use berkdb; then |
| 131 |
echo Statistics /var/lib/opendkim/stats.dat >> \ |
| 132 |
"${D}"/etc/opendkim/opendkim.conf |
| 133 |
fi |
| 134 |
fi |
| 135 |
|
| 136 |
use static-libs || find "${D}" -name "*.la" -delete |
| 137 |
} |
| 138 |
|
| 139 |
pkg_postinst() { |
| 140 |
elog "If you want to sign your mail messages and need some help" |
| 141 |
elog "please run:" |
| 142 |
elog " emerge --config ${CATEGORY}/${PN}" |
| 143 |
elog "It will help you create your key and give you hints on how" |
| 144 |
elog "to configure your DNS and MTA." |
| 145 |
|
| 146 |
ewarn "Make sure your MTA has r/w access to the socket file." |
| 147 |
ewarn "This can be done either by setting UMask to 002 and adding MTA's user" |
| 148 |
ewarn "to milter group or you can simply set UMask to 000." |
| 149 |
} |
| 150 |
|
| 151 |
pkg_config() { |
| 152 |
local selector keysize pubkey |
| 153 |
|
| 154 |
read -p "Enter the selector name (default ${HOSTNAME}): " selector |
| 155 |
[[ -n "${selector}" ]] || selector=${HOSTNAME} |
| 156 |
if [[ -z "${selector}" ]]; then |
| 157 |
eerror "Oddly enough, you don't have a HOSTNAME." |
| 158 |
return 1 |
| 159 |
fi |
| 160 |
if [[ -f "${ROOT}"etc/opendkim/${selector}.private ]]; then |
| 161 |
ewarn "The private key for this selector already exists." |
| 162 |
else |
| 163 |
einfo "Select the size of private key:" |
| 164 |
einfo " [1] 512 bits" |
| 165 |
einfo " [2] 1024 bits" |
| 166 |
while read -n 1 -s -p " Press 1 or 2 on the keyboard to select the key size " keysize ; do |
| 167 |
[[ "${keysize}" == "1" || "${keysize}" == "2" ]] && echo && break |
| 168 |
done |
| 169 |
case ${keysize} in |
| 170 |
1) keysize=512 ;; |
| 171 |
*) keysize=1024 ;; |
| 172 |
esac |
| 173 |
|
| 174 |
# generate the private and public keys |
| 175 |
opendkim-genkey -b ${keysize} -D "${ROOT}"etc/opendkim/ \ |
| 176 |
-s ${selector} -d '(your domain)' && \ |
| 177 |
chown milter:milter \ |
| 178 |
"${ROOT}"etc/opendkim/"${selector}".private || \ |
| 179 |
{ eerror "Failed to create private and public keys." ; return 1; } |
| 180 |
chmod go-r "${ROOT}"etc/opendkim/"${selector}".private |
| 181 |
fi |
| 182 |
|
| 183 |
# opendkim selector configuration |
| 184 |
echo |
| 185 |
einfo "Make sure you have the following settings in your /etc/opendkim/opendkim.conf:" |
| 186 |
einfo " Keyfile /etc/opendkim/${selector}.private" |
| 187 |
einfo " Selector ${selector}" |
| 188 |
|
| 189 |
# MTA configuration |
| 190 |
echo |
| 191 |
einfo "If you are using Postfix, add following lines to your main.cf:" |
| 192 |
einfo " smtpd_milters = unix:/var/run/opendkim/opendkim.sock" |
| 193 |
einfo " non_smtpd_milters = unix:/var/run/opendkim/opendkim.sock" |
| 194 |
einfo " and read http://www.postfix.org/MILTER_README.html" |
| 195 |
|
| 196 |
# DNS configuration |
| 197 |
einfo "After you configured your MTA, publish your key by adding this TXT record to your domain:" |
| 198 |
cat "${ROOT}"etc/opendkim/${selector}.txt |
| 199 |
einfo "t=y signifies you only test the DKIM on your domain. See following page for the complete list of tags:" |
| 200 |
einfo " http://www.dkim.org/specs/rfc4871-dkimbase.html#key-text" |
| 201 |
einfo |
| 202 |
einfo "Also look at the ADSP http://tools.ietf.org/html/rfc5617" |
| 203 |
} |