net-mail/qmailadmin: propagate ia64 keywords
[gentoo.git] / net-mail / vpopmail / vpopmail-5.4.33-r7.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 inherit autotools fixheadtails qmail
7
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"
11
12 LICENSE="GPL-2"
13 SLOT="0"
14 KEYWORDS="~amd64 ~arm ~hppa ~ia64 ~ppc ~ppc64 ~s390 ~sparc ~x86"
15 IUSE="clearpasswd ipalias maildrop mysql postgres spamassassin"
16 REQUIRED_USE="mysql? ( !postgres )"
17
18 DEPEND="
19         acct-group/vpopmail
20         acct-user/vpopmail
21         virtual/qmail
22         maildrop? ( mail-filter/maildrop )
23         mysql? ( dev-db/mysql-connector-c:0= )
24         postgres? ( dev-db/postgresql:= )
25         spamassassin? ( mail-filter/spamassassin )"
26 RDEPEND="${DEPEND}"
27
28 PATCHES=(
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
42 )
43 DOCS=(
44         ChangeLog
45         doc/.
46 )
47 HTML_DOCS=(
48         doc_html/.
49         man_html/.
50 )
51
52 VPOP_HOME="/var/vpopmail"
53
54 pkg_setup() {
55         upgradewarning
56 }
57
58 src_prepare() {
59         default
60
61         echo 'install-recursive: install-exec-am' \
62                 >>"${S}"/Makefile.am || die
63
64         # fix maildir paths
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
69
70         # remove vpopmail advertisement
71         sed -i -e '/printf.*vpopmail/s:vpopmail (:(:' \
72                 vdelivermail.c vpopbull.c vqmaillocal.c || die
73
74         # automake/autoconf
75         mv "${S}"/configure.{in,ac} || die
76         sed -i -e 's,AM_CONFIG_HEADER,AC_CONFIG_HEADERS,g' \
77                 configure.ac || die
78
79         # _FORTIFY_SOURCE
80         sed -i \
81                 -e 's/\(snprintf(\s*\(LI->[a-zA-Z_]\+\),\s*\)[a-zA-Z_]\+,/\1 sizeof(\2),/' \
82                 vlistlib.c || die
83
84         eautoreconf
85         ht_fix_file cdb/Makefile
86 }
87
88 src_configure() {
89         local -a authopts
90         if use mysql; then
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"
97                         "--enable-valias"
98                         "--disable-mysql-replication"
99                         "--enable-mysql-limits"
100                 )
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"
108                         "--enable-valias"
109                 )
110         else
111                 authopts+=( "--enable-auth-module=cdb" )
112         fi
113
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 \
125                 --enable-file-sync \
126                 --enable-md5-passwords \
127                 --enable-logging \
128                 --enable-auth-logging \
129                 --enable-log-name=vpopmail \
130                 --enable-qmail-ext \
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)
139 }
140
141 src_install() {
142         emake DESTDIR="${D}" install
143         keepdir "${VPOP_HOME}"/domains
144
145         # install helper script for maildir conversion
146         into "${VPOP_HOME}"
147         dobin "${FILESDIR}"/vpopmail-Maildir-dotmaildir-fix.sh
148         into /usr
149
150         mv doc/doc_html/ doc/man_html/ . || die
151         einstalldocs
152         rm -r "${D}/${VPOP_HOME}"/doc || die
153
154         # create /etc/vpopmail.conf
155         if use mysql; then
156                 insinto /etc
157                 newins "${D}${VPOP_HOME}"/etc/vpopmail.mysql vpopmail.conf
158                 dosym ../../../etc/vpopmail.conf "${VPOP_HOME}"/etc/vpopmail.mysql
159
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
165
166                 # lock down perms
167                 fperms 640 /etc/vpopmail.conf
168                 fowners root:vpopmail /etc/vpopmail.conf
169         fi
170
171         insinto "${VPOP_HOME}"/etc
172         doins vusagec.conf
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
175
176         einfo "Installing env.d entry"
177         doenvd "${FILESDIR}"/99vpopmail
178
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
183 }
184
185 pkg_postinst() {
186         if use mysql ; then
187                 elog
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"
191                 elog
192                 elog "First log into mysql as your mysql root user and pass. Then:"
193                 elog "> create database vpopmail;"
194                 elog "> use mysql;"
195                 elog "> grant select, insert, update, delete, create, drop on vpopmail.* to"
196                 elog "  vpopmail@localhost identified by 'your password';"
197                 elog "> flush privileges;"
198                 elog
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"
202                 elog
203         fi
204
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
209         fi
210
211         upgradewarning
212 }
213
214 pkg_postrm() {
215         elog "The vpopmail DATA will NOT be removed automatically."
216         elog "You can delete them manually by removing the ${VPOP_HOME} directory."
217 }
218
219 upgradewarning() {
220         if has_version "<=net-mail/vpopmail-5.2.1-r8"; then
221                 ewarn
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."
228                 ewarn
229         fi
230
231         elog
232         elog "Use of vpopmail's tcp.smtp[.cdb] is also deprecated now, consider"
233         elog "using net-mail/relay-ctrl instead."
234         elog
235
236         if use mysql; then
237                 if has_version "<=net-mail/vpopmail-5.4.17"; then
238                         elog
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!"
241                         elog
242                 fi
243         fi
244
245         ewarn
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"
250         ewarn
251 }