1 # Copyright 1999-2014 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
6 inherit autotools eutils fixheadtails qmail user
8 HOMEPAGE="http://www.inter7.com/index.php?page=vpopmail"
9 DESCRIPTION="A collection of programs to manage virtual email domains and accounts on your Qmail mail servers"
10 SRC_URI="mirror://sourceforge/${PN}/${P}.tar.gz"
14 KEYWORDS="amd64 arm hppa ia64 ppc ppc64 s390 sh sparc x86"
15 IUSE="clearpasswd ipalias maildrop mysql spamassassin"
18 maildrop? ( mail-filter/maildrop )
19 mysql? ( virtual/mysql )
20 spamassassin? ( mail-filter/spamassassin )"
23 # This makes sure the variable is set, and that it isn't null.
24 VPOP_DEFAULT_HOME="/var/vpopmail"
26 vpopmail_set_homedir() {
27 VPOP_HOME=$(egethome vpopmail)
28 if [[ -z "${VPOP_HOME}" ]]; then
30 eerror "vpopmail's home directory is null in passwd data!"
31 eerror "You probably want to check that out."
32 eerror "Continuing with default."
33 VPOP_HOME="${VPOP_DEFAULT_HOME}"
35 einfo "Setting VPOP_HOME to: $VPOP_HOME"
41 enewuser vpopmail 89 -1 ${VPOP_DEFAULT_HOME} vpopmail
46 epatch "${FILESDIR}"/${PN}-5.4.9-access.violation.patch
47 epatch "${FILESDIR}"/${PN}-lazy.patch
48 epatch "${FILESDIR}"/${PN}-double-free.patch
51 sed -i -e 's|Maildir|.maildir|g' \
52 vchkpw.c vconvert.c vdelivermail.c \
53 vpopbull.c vpopmail.c vqmaillocal.c \
54 vuserinfo.c maildirquota.c || die
56 # remove vpopmail advertisement
57 sed -i -e '/printf.*vpopmail/s:vpopmail (:(:' \
58 vdelivermail.c vpopbull.c vqmaillocal.c || die
61 mv -f "${S}"/configure.{in,ac} || die
62 sed -i -e 's,AM_CONFIG_HEADER,AC_CONFIG_HEADERS,g' \
67 -e 's/\(snprintf(\s*\(LI->[a-zA-Z_]\+\),\s*\)[a-zA-Z_]\+,/\1 sizeof(\2),/' \
71 ht_fix_file cdb/Makefile
79 authopts="$(mysql_config --include)"
80 authopts="--enable-incdir=${authopts#-I}"
81 authopts+=" --enable-auth-module=mysql"
82 authopts+=" --enable-libdir=/usr/$(get_libdir)/mysql"
83 authopts+=" --enable-sql-logging"
84 authopts+=" --enable-valias"
85 authopts+=" --disable-mysql-replication"
86 authopts+=" --enable-mysql-limits"
88 authopts="--enable-auth-module=cdb"
92 --sysconfdir=${VPOP_HOME}/etc \
93 --enable-non-root-build \
94 --enable-qmaildir=${QMAIL_HOME} \
95 --enable-qmail-newu=${QMAIL_HOME}/bin/qmail-newu \
96 --enable-qmail-inject=${QMAIL_HOME}/bin/qmail-inject \
97 --enable-qmail-newmrh=${QMAIL_HOME}/bin/qmail-newmrh \
98 --enable-vpopuser=vpopmail \
99 --enable-vpopgroup=vpopmail \
100 --enable-many-domains \
101 --enable-file-locking \
103 --enable-md5-passwords \
105 --enable-auth-logging \
106 --enable-log-name=vpopmail \
108 --disable-tcpserver-file \
109 --disable-roaming-users \
110 $(use_enable ipalias ip-alias-domains) \
111 $(use_enable clearpasswd clear-passwd) \
112 $(use_enable maildrop) \
113 $(use_enable maildrop maildrop-prog /usr/bin/maildrop) \
114 $(use_enable spamassassin)
121 emake -j1 DESTDIR="${D}" install
122 keepdir "${VPOP_HOME}"/domains
124 # install helper script for maildir conversion
126 dobin "${FILESDIR}"/vpopmail-Maildir-dotmaildir-fix.sh
129 dodoc doc/AUTHORS ChangeLog doc/FAQ doc/INSTALL doc/README*
130 dohtml doc/doc_html/* doc/man_html/*
131 rm -rf "${D}/${VPOP_HOME}"/doc
132 dosym /usr/share/doc/${PF}/ "${VPOP_HOME}"/doc
134 # create /etc/vpopmail.conf
137 mv "${D}${VPOP_HOME}"/etc/vpopmail.mysql "${D}"/etc/vpopmail.conf
138 dosym /etc/vpopmail.conf "${VPOP_HOME}"/etc/vpopmail.mysql
140 sed -e '12d' -i "${D}"/etc/vpopmail.conf
141 echo '# Read-only DB' >> "${D}"/etc/vpopmail.conf
142 echo 'localhost|0|vpopmail|secret|vpopmail' >> "${D}"/etc/vpopmail.conf
143 echo '# Write DB' >> "${D}"/etc/vpopmail.conf
144 echo 'localhost|0|vpopmail|secret|vpopmail' >> "${D}"/etc/vpopmail.conf
147 fperms 640 /etc/vpopmail.conf
148 fowners root:vpopmail /etc/vpopmail.conf
151 insinto "${VPOP_HOME}"/etc
153 dosym "${VPOP_HOME}"/etc/vusagec.conf /etc/vusagec.conf
154 sed -i 's/Disable = False;/Disable = True;/g' "${D}${VPOP_HOME}"/etc/vusagec.conf
156 einfo "Installing env.d entry"
158 doenvd "${FILESDIR}"/99vpopmail
160 einfo "Locking down vpopmail permissions"
161 fowners root:0 -R "${VPOP_HOME}"/{bin,etc,include}
162 fowners root:vpopmail "${VPOP_HOME}"/bin/vchkpw
163 fperms 4711 "${VPOP_HOME}"/bin/vchkpw
169 elog "You have 'mysql' turned on in your USE"
170 elog "Vpopmail needs a VALID MySQL USER. Let's call it 'vpopmail'"
171 elog "You MUST add it and then specify its passwd in the /etc/vpopmail.conf file"
173 elog "First log into mysql as your mysql root user and pass. Then:"
174 elog "> create database vpopmail;"
176 elog "> grant select, insert, update, delete, create, drop on vpopmail.* to"
177 elog " vpopmail@localhost identified by 'your password';"
178 elog "> flush privileges;"
180 elog "If you have problems with vpopmail not accepting mail properly,"
181 elog "please ensure that /etc/vpopmail.conf is chmod 640 and"
182 elog "owned by root:vpopmail"
186 # do this for good measure
187 if [[ -e /etc/vpopmail.conf ]]; then
188 chmod 640 /etc/vpopmail.conf
189 chown root:vpopmail /etc/vpopmail.conf
198 elog "The vpopmail DATA will NOT be removed automatically."
199 elog "You can delete them manually by removing the ${VPOP_HOME} directory."
204 ewarn "Massive important warning if you are upgrading to 5.2.1-r8 or older"
205 ewarn "The internal structure of the mail storage has changed for"
206 ewarn "consistancy with the rest of Gentoo! Please review and utilize the "
207 ewarn "script at ${VPOP_HOME}/bin/vpopmail-Maildir-dotmaildir-fix.sh"
208 ewarn "to upgrade your system! (It can do conversions both ways)."
209 ewarn "You should be able to run it right away without any changes."
213 elog "Use of vpopmail's tcp.smtp[.cdb] is also deprecated now, consider"
214 elog "using net-mail/relay-ctrl instead."
219 elog "If you are upgrading from 5.4.17 or older, you have to fix your"
222 elog 'ALTER TABLE `dir_control` CHANGE `domain` `domain` CHAR(96) NOT NULL;'
223 elog 'ALTER TABLE `ip_alias_map` CHANGE domain domain CHAR(96) NOT NULL;'
224 elog 'ALTER TABLE `lastauth` CHANGE domain domain CHAR(96) NOT NULL;'
225 elog 'ALTER TABLE `valias` CHANGE domain domain CHAR(96) NOT NULL;'
226 elog 'ALTER TABLE `vlog` CHANGE domain domain CHAR(96) NOT NULL;'
227 elog 'ALTER TABLE `vpopmail` CHANGE domain domain CHAR(96) NOT NULL;'
228 elog 'ALTER TABLE `limits` CHANGE domain domain CHAR(96) NOT NULL,'
229 elog ' ADD `disable_spamassassin` TINYINT(1) DEFAULT '0' NOT NULL AFTER `disable_smtp`,'
230 elog ' ADD `delete_spam` TINYINT(1) DEFAULT '0' NOT NULL AFTER `disable_spamassassin`;'
235 ewarn "Newer versions of vpopmail contain a quota daemon called vusaged."
236 ewarn "This ebuild DOES NOT INSTALL vusaged and has therefore disabled"
237 ewarn "its usage in ${VPOP_HOME}/etc/vusagec.conf. DO NOT ENABLE!"
238 ewarn "Otherwise mail delivery WILL BREAK"