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 postgres spamassassin"
16 REQUIRED_USE="mysql? ( !postgres )"
19 maildrop? ( mail-filter/maildrop )
20 mysql? ( virtual/mysql )
21 postgres? ( dev-db/postgresql[server] )
22 spamassassin? ( mail-filter/spamassassin )"
25 # This makes sure the variable is set, and that it isn't null.
26 VPOP_DEFAULT_HOME="/var/vpopmail"
28 vpopmail_set_homedir() {
29 VPOP_HOME=$(egethome vpopmail)
30 if [[ -z "${VPOP_HOME}" ]]; then
32 eerror "vpopmail's home directory is null in passwd data!"
33 eerror "You probably want to check that out."
34 eerror "Continuing with default."
35 VPOP_HOME="${VPOP_DEFAULT_HOME}"
37 einfo "Setting VPOP_HOME to: $VPOP_HOME"
43 enewuser vpopmail 89 -1 ${VPOP_DEFAULT_HOME} vpopmail
48 epatch "${FILESDIR}"/${PN}-5.4.9-access.violation.patch
49 epatch "${FILESDIR}"/${PN}-lazy.patch
50 epatch "${FILESDIR}"/${PN}-double-free.patch
51 epatch "${FILESDIR}"/${PN}-vpgsql.patch
53 echo 'install-recursive: install-exec-am' \
57 sed -i -e 's|Maildir|.maildir|g' \
58 vchkpw.c vconvert.c vdelivermail.c \
59 vpopbull.c vpopmail.c vqmaillocal.c \
60 vuserinfo.c maildirquota.c || die
62 # remove vpopmail advertisement
63 sed -i -e '/printf.*vpopmail/s:vpopmail (:(:' \
64 vdelivermail.c vpopbull.c vqmaillocal.c || die
67 mv -f "${S}"/configure.{in,ac} || die
68 sed -i -e 's,AM_CONFIG_HEADER,AC_CONFIG_HEADERS,g' \
73 -e 's/\(snprintf(\s*\(LI->[a-zA-Z_]\+\),\s*\)[a-zA-Z_]\+,/\1 sizeof(\2),/' \
77 ht_fix_file cdb/Makefile
85 mysqlinc=$(mysql_config --include)
86 authopts="--enable-incdir=${mysqlinc#-I}"
87 authopts+=" --enable-auth-module=mysql"
88 authopts+=" --enable-libdir=/usr/$(get_libdir)/mysql"
89 authopts+=" --enable-sql-logging"
90 authopts+=" --enable-valias"
91 authopts+=" --disable-mysql-replication"
92 authopts+=" --enable-mysql-limits"
93 elif use postgres; then
94 pglibdir=$(pg_config --libdir)
95 authopts+=" --enable-auth-module=pgsql"
96 authopts+=" --enable-libdir=${pglibdir}"
97 authopts+=" --enable-sql-logging"
98 authopts+=" --enable-valias"
100 authopts+=" --enable-auth-module=cdb"
104 --sysconfdir=${VPOP_HOME}/etc \
105 --enable-non-root-build \
106 --enable-qmaildir=${QMAIL_HOME} \
107 --enable-qmail-newu=${QMAIL_HOME}/bin/qmail-newu \
108 --enable-qmail-inject=${QMAIL_HOME}/bin/qmail-inject \
109 --enable-qmail-newmrh=${QMAIL_HOME}/bin/qmail-newmrh \
110 --enable-vpopuser=vpopmail \
111 --enable-vpopgroup=vpopmail \
112 --enable-many-domains \
113 --enable-file-locking \
115 --enable-md5-passwords \
117 --enable-auth-logging \
118 --enable-log-name=vpopmail \
120 --disable-tcpserver-file \
121 --disable-roaming-users \
122 $(use_enable ipalias ip-alias-domains) \
123 $(use_enable clearpasswd clear-passwd) \
124 $(use_enable maildrop) \
125 $(use_enable maildrop maildrop-prog /usr/bin/maildrop) \
126 $(use_enable spamassassin)
132 emake DESTDIR="${D}" install
133 keepdir "${VPOP_HOME}"/domains
135 # install helper script for maildir conversion
137 dobin "${FILESDIR}"/vpopmail-Maildir-dotmaildir-fix.sh
140 dodoc doc/AUTHORS ChangeLog doc/FAQ doc/INSTALL doc/README*
141 dohtml doc/doc_html/* doc/man_html/*
142 rm -rf "${D}/${VPOP_HOME}"/doc
143 dosym /usr/share/doc/${PF}/ "${VPOP_HOME}"/doc
145 # create /etc/vpopmail.conf
148 mv "${D}${VPOP_HOME}"/etc/vpopmail.mysql "${D}"/etc/vpopmail.conf
149 dosym /etc/vpopmail.conf "${VPOP_HOME}"/etc/vpopmail.mysql
151 sed -e '12d' -i "${D}"/etc/vpopmail.conf
152 echo '# Read-only DB' >> "${D}"/etc/vpopmail.conf
153 echo 'localhost|0|vpopmail|secret|vpopmail' >> "${D}"/etc/vpopmail.conf
154 echo '# Write DB' >> "${D}"/etc/vpopmail.conf
155 echo 'localhost|0|vpopmail|secret|vpopmail' >> "${D}"/etc/vpopmail.conf
158 fperms 640 /etc/vpopmail.conf
159 fowners root:vpopmail /etc/vpopmail.conf
162 insinto "${VPOP_HOME}"/etc
164 dosym "${VPOP_HOME}"/etc/vusagec.conf /etc/vusagec.conf
165 sed -i 's/Disable = False;/Disable = True;/g' "${D}${VPOP_HOME}"/etc/vusagec.conf
167 einfo "Installing env.d entry"
169 doenvd "${FILESDIR}"/99vpopmail
171 einfo "Locking down vpopmail permissions"
172 fowners -R root:0 "${VPOP_HOME}"/{bin,etc,include}
173 fowners root:vpopmail "${VPOP_HOME}"/bin/vchkpw
174 fperms 4711 "${VPOP_HOME}"/bin/vchkpw
180 elog "You have 'mysql' turned on in your USE"
181 elog "Vpopmail needs a VALID MySQL USER. Let's call it 'vpopmail'"
182 elog "You MUST add it and then specify its passwd in the /etc/vpopmail.conf file"
184 elog "First log into mysql as your mysql root user and pass. Then:"
185 elog "> create database vpopmail;"
187 elog "> grant select, insert, update, delete, create, drop on vpopmail.* to"
188 elog " vpopmail@localhost identified by 'your password';"
189 elog "> flush privileges;"
191 elog "If you have problems with vpopmail not accepting mail properly,"
192 elog "please ensure that /etc/vpopmail.conf is chmod 640 and"
193 elog "owned by root:vpopmail"
197 # do this for good measure
198 if [[ -e /etc/vpopmail.conf ]]; then
199 chmod 640 /etc/vpopmail.conf
200 chown root:vpopmail /etc/vpopmail.conf
209 elog "The vpopmail DATA will NOT be removed automatically."
210 elog "You can delete them manually by removing the ${VPOP_HOME} directory."
215 ewarn "Massive important warning if you are upgrading to 5.2.1-r8 or older"
216 ewarn "The internal structure of the mail storage has changed for"
217 ewarn "consistancy with the rest of Gentoo! Please review and utilize the "
218 ewarn "script at ${VPOP_HOME}/bin/vpopmail-Maildir-dotmaildir-fix.sh"
219 ewarn "to upgrade your system! (It can do conversions both ways)."
220 ewarn "You should be able to run it right away without any changes."
224 elog "Use of vpopmail's tcp.smtp[.cdb] is also deprecated now, consider"
225 elog "using net-mail/relay-ctrl instead."
230 elog "If you are upgrading from 5.4.17 or older, you have to fix your"
233 elog 'ALTER TABLE `dir_control` CHANGE `domain` `domain` CHAR(96) NOT NULL;'
234 elog 'ALTER TABLE `ip_alias_map` CHANGE domain domain CHAR(96) NOT NULL;'
235 elog 'ALTER TABLE `lastauth` CHANGE domain domain CHAR(96) NOT NULL;'
236 elog 'ALTER TABLE `valias` CHANGE domain domain CHAR(96) NOT NULL;'
237 elog 'ALTER TABLE `vlog` CHANGE domain domain CHAR(96) NOT NULL;'
238 elog 'ALTER TABLE `vpopmail` CHANGE domain domain CHAR(96) NOT NULL;'
239 elog 'ALTER TABLE `limits` CHANGE domain domain CHAR(96) NOT NULL,'
240 elog ' ADD `disable_spamassassin` TINYINT(1) DEFAULT '0' NOT NULL AFTER `disable_smtp`,'
241 elog ' ADD `delete_spam` TINYINT(1) DEFAULT '0' NOT NULL AFTER `disable_spamassassin`;'
246 ewarn "Newer versions of vpopmail contain a quota daemon called vusaged."
247 ewarn "This ebuild DOES NOT INSTALL vusaged and has therefore disabled"
248 ewarn "its usage in ${VPOP_HOME}/etc/vusagec.conf. DO NOT ENABLE!"
249 ewarn "Otherwise mail delivery WILL BREAK"