1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 inherit autotools fixheadtails qmail
8 HOMEPAGE="http://www.inter7.com/index.php?page=vpopmail"
9 DESCRIPTION="Collection of programs to manage virtual email on Qmail servers"
10 SRC_URI="mirror://sourceforge/${PN}/${P}.tar.gz"
14 KEYWORDS="amd64 arm hppa ~ia64 ppc ppc64 ~s390 sparc x86"
15 IUSE="clearpasswd ipalias maildrop mysql postgres spamassassin"
16 REQUIRED_USE="mysql? ( !postgres )"
22 maildrop? ( mail-filter/maildrop )
23 mysql? ( dev-db/mysql-connector-c:0= )
24 postgres? ( <dev-db/postgresql-9999:=[server] )
25 spamassassin? ( mail-filter/spamassassin )"
29 "${FILESDIR}"/${PN}-5.4.9-access.violation.patch
30 "${FILESDIR}"/${PN}-lazy.patch
31 "${FILESDIR}"/${PN}-vpgsql.patch
32 "${FILESDIR}"/${PN}-double-free.patch
33 "${FILESDIR}"/${PN}-5.4.33-vdelivermail-add-static.patch
34 "${FILESDIR}"/${PN}-5.4.33-fix-those-vfork-instances-that-do-more-than-exec.patch
35 "${FILESDIR}"/${PN}-5.4.33-remove-unneeded-forward-declaration.patch
36 "${FILESDIR}"/${PN}-5.4.33-clean-up-calling-maildrop.patch
37 "${FILESDIR}"/${PN}-5.4.33-fix-S-tag-in-case-spamassassin-changed-the-file-size.patch
38 "${FILESDIR}"/${PN}-5.4.33-strncat.patch
39 "${FILESDIR}"/${PN}-5.4.33-unistd.patch
40 "${FILESDIR}"/${PN}-5.4.33-check-crypt-return-value-for-NULL.patch
41 "${FILESDIR}"/${PN}-5.4.33-use-proper-printf-format-strings.patch
52 VPOP_HOME="/var/vpopmail"
61 echo 'install-recursive: install-exec-am' \
62 >>"${S}"/Makefile.am || die
65 sed -i -e 's|Maildir|.maildir|g' \
66 vchkpw.c vconvert.c vdelivermail.c \
67 vpopbull.c vpopmail.c vqmaillocal.c \
68 vuserinfo.c maildirquota.c || die
70 # remove vpopmail advertisement
71 sed -i -e '/printf.*vpopmail/s:vpopmail (:(:' \
72 vdelivermail.c vpopbull.c vqmaillocal.c || die
75 mv "${S}"/configure.{in,ac} || die
76 sed -i -e 's,AM_CONFIG_HEADER,AC_CONFIG_HEADERS,g' \
81 -e 's/\(snprintf(\s*\(LI->[a-zA-Z_]\+\),\s*\)[a-zA-Z_]\+,/\1 sizeof(\2),/' \
85 ht_fix_file cdb/Makefile
91 incdir=$(mysql_config --variable=pkgincludedir || die)
92 libdir=$(mysql_config --variable=pkglibdir || die)
93 authopts+=( "--enable-auth-module=mysql"
94 "--enable-incdir=${incdir}"
95 "--enable-libdir=${libdir}"
96 "--enable-sql-logging"
98 "--disable-mysql-replication"
99 "--enable-mysql-limits"
101 elif use postgres; then
102 libdir=$(pg_config --libdir || die)
103 incdir=$(pg_config --pkgincludedir || die)
104 authopts+=( "--enable-auth-module=pgsql"
105 "--enable-incdir=${incdir}"
106 "--enable-libdir=${libdir}"
107 "--enable-sql-logging"
111 authopts+=( "--enable-auth-module=cdb" )
114 econf ${authopts[@]} \
115 --sysconfdir=${VPOP_HOME}/etc \
116 --enable-non-root-build \
117 --enable-qmaildir=${QMAIL_HOME} \
118 --enable-qmail-newu=${QMAIL_HOME}/bin/qmail-newu \
119 --enable-qmail-inject=${QMAIL_HOME}/bin/qmail-inject \
120 --enable-qmail-newmrh=${QMAIL_HOME}/bin/qmail-newmrh \
121 --enable-vpopuser=vpopmail \
122 --enable-vpopgroup=vpopmail \
123 --enable-many-domains \
124 --enable-file-locking \
126 --enable-md5-passwords \
128 --enable-auth-logging \
129 --enable-log-name=vpopmail \
131 --disable-tcpserver-file \
132 --disable-roaming-users \
133 $(use_enable ipalias ip-alias-domains) \
134 $(use_enable clearpasswd clear-passwd) \
135 $(use_enable maildrop) \
136 $(use_enable maildrop maildrop-prog /usr/bin/maildrop) \
137 $(use_enable spamassassin)
141 emake DESTDIR="${D}" install
142 keepdir "${VPOP_HOME}"/domains
144 # install helper script for maildir conversion
146 dobin "${FILESDIR}"/vpopmail-Maildir-dotmaildir-fix.sh
149 mv doc/doc_html/ doc/man_html/ . || die
151 rm -r "${D}/${VPOP_HOME}"/doc || die
153 # create /etc/vpopmail.conf
156 newins "${D}${VPOP_HOME}"/etc/vpopmail.mysql vpopmail.conf
157 dosym ../../../etc/vpopmail.conf "${VPOP_HOME}"/etc/vpopmail.mysql
159 sed 's/^[^#]/# &/' -i "${D}"/etc/vpopmail.conf || die
160 echo '# Read-only DB' >> "${D}"/etc/vpopmail.conf || die
161 echo 'localhost|0|vpopmail|secret|vpopmail' >> "${D}"/etc/vpopmail.conf || die
162 echo '# Write DB' >> "${D}"/etc/vpopmail.conf || die
163 echo 'localhost|0|vpopmail|secret|vpopmail' >> "${D}"/etc/vpopmail.conf || die
166 fperms 640 /etc/vpopmail.conf
167 fowners root:vpopmail /etc/vpopmail.conf
170 insinto "${VPOP_HOME}"/etc
172 dosym .."${VPOP_HOME}"/etc/vusagec.conf /etc/vusagec.conf
173 sed -i 's/Disable = False;/Disable = True;/g' "${D}${VPOP_HOME}"/etc/vusagec.conf || die
175 einfo "Installing env.d entry"
176 doenvd "${FILESDIR}"/99vpopmail
178 einfo "Locking down vpopmail permissions"
179 fowners -R root:0 "${VPOP_HOME}"/{bin,etc,include}
180 fowners root:vpopmail "${VPOP_HOME}"/bin/vchkpw
181 fperms 4711 "${VPOP_HOME}"/bin/vchkpw
187 elog "You have 'mysql' turned on in your USE"
188 elog "Vpopmail needs a VALID MySQL USER. Let's call it 'vpopmail'"
189 elog "You MUST add it and then specify its passwd in the /etc/vpopmail.conf file"
191 elog "First log into mysql as your mysql root user and pass. Then:"
192 elog "> create database vpopmail;"
194 elog "> grant select, insert, update, delete, create, drop on vpopmail.* to"
195 elog " vpopmail@localhost identified by 'your password';"
196 elog "> flush privileges;"
198 elog "If you have problems with vpopmail not accepting mail properly,"
199 elog "please ensure that /etc/vpopmail.conf is chmod 640 and"
200 elog "owned by root:vpopmail"
204 # do this for good measure
205 if [[ -e /etc/vpopmail.conf ]]; then
206 chmod 640 /etc/vpopmail.conf || die
207 chown root:vpopmail /etc/vpopmail.conf || die
214 elog "The vpopmail DATA will NOT be removed automatically."
215 elog "You can delete them manually by removing the ${VPOP_HOME} directory."
219 if has_version "<=net-mail/vpopmail-5.2.1-r8"; then
221 ewarn "Massive important warning if you are upgrading to 5.2.1-r8 or older"
222 ewarn "The internal structure of the mail storage has changed for"
223 ewarn "consistancy with the rest of Gentoo! Please review and utilize the "
224 ewarn "script at ${VPOP_HOME}/bin/vpopmail-Maildir-dotmaildir-fix.sh"
225 ewarn "to upgrade your system! (It can do conversions both ways)."
226 ewarn "You should be able to run it right away without any changes."
231 elog "Use of vpopmail's tcp.smtp[.cdb] is also deprecated now, consider"
232 elog "using net-mail/relay-ctrl instead."
236 if has_version "<=net-mail/vpopmail-5.4.17"; then
238 elog "If you are upgrading from 5.4.17 or older, you have to fix your"
239 elog "MySQL tables, please see the UPGRADE file in the documentation!"
245 ewarn "Newer versions of vpopmail contain a quota daemon called vusaged."
246 ewarn "This ebuild DOES NOT INSTALL vusaged and has therefore disabled"
247 ewarn "its usage in ${VPOP_HOME}/etc/vusagec.conf. DO NOT ENABLE!"
248 ewarn "Otherwise mail delivery WILL BREAK"