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:= )
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 --enable-onchange-script \
132 --disable-tcpserver-file \
133 --disable-roaming-users \
134 $(use_enable ipalias ip-alias-domains) \
135 $(use_enable clearpasswd clear-passwd) \
136 $(use_enable maildrop) \
137 $(use_enable maildrop maildrop-prog /usr/bin/maildrop) \
138 $(use_enable spamassassin)
142 emake DESTDIR="${D}" install
143 keepdir "${VPOP_HOME}"/domains
145 # install helper script for maildir conversion
147 dobin "${FILESDIR}"/vpopmail-Maildir-dotmaildir-fix.sh
150 mv doc/doc_html/ doc/man_html/ . || die
152 rm -r "${D}/${VPOP_HOME}"/doc || die
154 # create /etc/vpopmail.conf
157 newins "${D}${VPOP_HOME}"/etc/vpopmail.mysql vpopmail.conf
158 dosym ../../../etc/vpopmail.conf "${VPOP_HOME}"/etc/vpopmail.mysql
160 sed 's/^[^#]/# &/' -i "${D}"/etc/vpopmail.conf || die
161 echo '# Read-only DB' >> "${D}"/etc/vpopmail.conf || die
162 echo 'localhost|0|vpopmail|secret|vpopmail' >> "${D}"/etc/vpopmail.conf || die
163 echo '# Write DB' >> "${D}"/etc/vpopmail.conf || die
164 echo 'localhost|0|vpopmail|secret|vpopmail' >> "${D}"/etc/vpopmail.conf || die
167 fperms 640 /etc/vpopmail.conf
168 fowners root:vpopmail /etc/vpopmail.conf
171 insinto "${VPOP_HOME}"/etc
173 dosym .."${VPOP_HOME}"/etc/vusagec.conf /etc/vusagec.conf
174 sed -i 's/Disable = False;/Disable = True;/g' "${D}${VPOP_HOME}"/etc/vusagec.conf || die
176 einfo "Installing env.d entry"
177 doenvd "${FILESDIR}"/99vpopmail
179 einfo "Locking down vpopmail permissions"
180 fowners -R root:0 "${VPOP_HOME}"/{bin,etc,include}
181 fowners root:vpopmail "${VPOP_HOME}"/bin/vchkpw
182 fperms 4711 "${VPOP_HOME}"/bin/vchkpw
188 elog "You have 'mysql' turned on in your USE"
189 elog "Vpopmail needs a VALID MySQL USER. Let's call it 'vpopmail'"
190 elog "You MUST add it and then specify its passwd in the /etc/vpopmail.conf file"
192 elog "First log into mysql as your mysql root user and pass. Then:"
193 elog "> create database vpopmail;"
195 elog "> grant select, insert, update, delete, create, drop on vpopmail.* to"
196 elog " vpopmail@localhost identified by 'your password';"
197 elog "> flush privileges;"
199 elog "If you have problems with vpopmail not accepting mail properly,"
200 elog "please ensure that /etc/vpopmail.conf is chmod 640 and"
201 elog "owned by root:vpopmail"
205 # do this for good measure
206 if [[ -e /etc/vpopmail.conf ]]; then
207 chmod 640 /etc/vpopmail.conf || die
208 chown root:vpopmail /etc/vpopmail.conf || die
215 elog "The vpopmail DATA will NOT be removed automatically."
216 elog "You can delete them manually by removing the ${VPOP_HOME} directory."
220 if has_version "<=net-mail/vpopmail-5.2.1-r8"; then
222 ewarn "Massive important warning if you are upgrading to 5.2.1-r8 or older"
223 ewarn "The internal structure of the mail storage has changed for"
224 ewarn "consistancy with the rest of Gentoo! Please review and utilize the "
225 ewarn "script at ${VPOP_HOME}/bin/vpopmail-Maildir-dotmaildir-fix.sh"
226 ewarn "to upgrade your system! (It can do conversions both ways)."
227 ewarn "You should be able to run it right away without any changes."
232 elog "Use of vpopmail's tcp.smtp[.cdb] is also deprecated now, consider"
233 elog "using net-mail/relay-ctrl instead."
237 if has_version "<=net-mail/vpopmail-5.4.17"; then
239 elog "If you are upgrading from 5.4.17 or older, you have to fix your"
240 elog "MySQL tables, please see the UPGRADE file in the documentation!"
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"