APKBUILD 7.77 KB
Newer Older
1
# Contributor: Valery Kartel <valery.kartel@gmail.com>
2
# Contributor: Łukasz Jendrysik <scadu@yandex.com>
Michael Mason's avatar
Michael Mason committed
3
# Contributor: Michael Mason <ms13sp@gmail.com>
4
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
5
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
Michael Mason's avatar
Michael Mason committed
6
pkgname=dovecot
7
pkgver=2.3.4.1
TBK's avatar
TBK committed
8
_pkgvermajor=2.3
9
pkgrel=1
10
_pigeonholever=0.5.4
11
_pigeonholevermajor=${_pigeonholever%.*}
Michael Mason's avatar
Michael Mason committed
12
pkgdesc="IMAP and POP3 server"
TBK's avatar
TBK committed
13
url="https://www.dovecot.org/"
14
arch="all"
TBK's avatar
TBK committed
15
options="libtool"
16 17 18
case $CARCH in
	x86|armhf|armv7) options="$options !check" # test failures
esac
19
license="LGPL-2.0-or-later"
20
depends="openssl"
Natanael Copa's avatar
Natanael Copa committed
21 22
pkgusers="dovecot dovenull"
pkggroups="dovecot dovenull"
Jakub Jirutka's avatar
Jakub Jirutka committed
23 24 25 26 27 28 29 30
makedepends="
	autoconf
	automake
	bzip2-dev
	clucene-dev
	expat-dev
	heimdal-dev
	libcap-dev
31
	openssl-dev
Jakub Jirutka's avatar
Jakub Jirutka committed
32 33 34 35 36 37 38 39
	libtool
	linux-headers
	mariadb-connector-c-dev
	openldap-dev
	postgresql-dev
	sqlite-dev
	zlib-dev
	"
40
install="$pkgname.pre-install $pkgname.post-install $pkgname.post-upgrade"
Jakub Jirutka's avatar
Jakub Jirutka committed
41 42 43 44
subpackages="
	$pkgname-doc
	$pkgname-dev
	$pkgname-openrc
45 46 47
	$pkgname-lmtpd
	$pkgname-pop3d
	$pkgname-submissiond
Jakub Jirutka's avatar
Jakub Jirutka committed
48 49 50 51 52 53 54 55 56 57
	$pkgname-pigeonhole-plugin-ldap:_sieve_ldap
	$pkgname-pigeonhole-plugin:_sieve
	$pkgname-sql
	$pkgname-pgsql
	$pkgname-mysql
	$pkgname-sqlite
	$pkgname-gssapi
	$pkgname-ldap
	$pkgname-fts-solr:_fts_solr
	$pkgname-fts-lucene:_fts_lucene
Natanael Copa's avatar
Natanael Copa committed
58
	"
TBK's avatar
TBK committed
59 60
source="https://www.dovecot.org/releases/$_pkgvermajor/$pkgname-$pkgver.tar.gz
	https://pigeonhole.dovecot.org/releases/$_pkgvermajor/$pkgname-$_pkgvermajor-pigeonhole-$_pigeonholever.tar.gz
Natanael Copa's avatar
Natanael Copa committed
61
	skip-iconv-check.patch
62
	split-protocols.patch
63
	default-config.patch
64
	dovecot.logrotate
Michael Mason's avatar
Michael Mason committed
65
	dovecot.initd
66
	mysql-fix-double-close.patch
Michael Mason's avatar
Michael Mason committed
67
	"
Jakub Jirutka's avatar
Jakub Jirutka committed
68 69
builddir="$srcdir/$pkgname-$pkgver"
_builddir_pigeonhole="$srcdir/$pkgname-$_pkgvermajor-pigeonhole-$_pigeonholever"
70

71
# secfixes:
72 73
#   2.3.4.1-r0:
#     - CVE-2019-3814
TBK's avatar
TBK committed
74
#   2.3.1-r0:
75 76 77
#     - CVE-2017-15130
#     - CVE-2017-14461
#     - CVE-2017-15132
78 79

_configure() {
80 81 82 83
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
84
		--localstatedir=/var \
Natanael Copa's avatar
Natanael Copa committed
85
		--sysconfdir=/etc \
Michael Mason's avatar
Michael Mason committed
86 87
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
88 89 90 91 92 93 94
		--disable-static \
		"$@"
}

build() {
	cd "$builddir"
	_configure \
95 96
		--with-gssapi=plugin \
		--with-ldap=plugin \
97 98 99 100
		--with-sql=plugin \
		--with-mysql \
		--with-sqlite \
		--with-pgsql \
101 102
		--with-solr \
		--with-lucene \
103
		--with-ssl=openssl \
104
		--with-ssldir=/etc/ssl/dovecot \
105 106
		--with-rundir=/run/dovecot
	make
107 108

	# Build pigeonhole plugin
Jakub Jirutka's avatar
Jakub Jirutka committed
109
	cd "$_builddir_pigeonhole"
110
	_configure \
111
		--with-dovecot="$builddir" \
112
		--with-ldap=plugin
113
	make
114
}
Michael Mason's avatar
Michael Mason committed
115

Natanael Copa's avatar
Natanael Copa committed
116 117 118 119 120
check() {
	cd "$builddir"
	make check
}

121
package() {
122
	cd "$builddir"
Jakub Jirutka's avatar
Jakub Jirutka committed
123

124
	make DESTDIR="$pkgdir" install
125

Jakub Jirutka's avatar
Jakub Jirutka committed
126 127 128 129 130
	cd "$pkgdir"

	install -d ./etc/ssl/dovecot
	install -D -m 755 "$srcdir"/dovecot.initd ./etc/init.d/dovecot
	install -D -m 644 "$srcdir"/dovecot.logrotate ./etc/logrotate.d/dovecot
Natanael Copa's avatar
Natanael Copa committed
131 132

	# default config
Jakub Jirutka's avatar
Jakub Jirutka committed
133 134 135 136 137 138 139 140 141
	rm ./etc/dovecot/*
	rm ./usr/share/doc/dovecot/mkcert.sh
	mv ./usr/share/doc/dovecot/dovecot-openssl.cnf ./etc/dovecot/
	mv ./usr/share/doc/dovecot/example-config/dovecot* \
		./usr/share/doc/dovecot/example-config/conf.d \
		./etc/dovecot/
	rm -fr ./usr/share/doc/dovecot/example-config

	# Fix SSL dirs in default config.
Natanael Copa's avatar
Natanael Copa committed
142 143
	sed -i -e 's,^ssl_cert =.*,ssl_cert = </etc/ssl/dovecot/server.pem,' \
		-e 's,^ssl_key =.*,ssl_key = </etc/ssl/dovecot/server.key,' \
Jakub Jirutka's avatar
Jakub Jirutka committed
144 145 146 147
		./etc/dovecot/conf.d/10-ssl.conf

	# Set default passdb to passwd and create appropriate 'users' file.
	install -m 640 -o dovecot -g mail /dev/null ./etc/dovecot/users
148 149
	sed -i -e 's,!include auth-system.conf.ext,!include auth-passwdfile.conf.ext,' \
		-e 's,#!include auth-passwdfile.conf.ext,#!include auth-system.conf.ext,' \
Jakub Jirutka's avatar
Jakub Jirutka committed
150
		./etc/dovecot/conf.d/10-auth.conf
151 152


Jakub Jirutka's avatar
Jakub Jirutka committed
153 154
	# Installing pigeonhole plugin.
	cd "$_builddir_pigeonhole"
155
	make install DESTDIR="$pkgdir"
156 157 158

	# Moving config in the correct place
	mv "$pkgdir"/usr/share/doc/dovecot/example-config/conf.d/* \
159
		"$pkgdir"/etc/dovecot/conf.d
160 161 162

	# Remove libtool archives.
	find "$pkgdir" -name '*.la' | xargs rm -f
Michael Mason's avatar
Michael Mason committed
163 164
}

165 166
dev() {
	default_dev
167
	mkdir -p "$subpkgdir"/usr/lib/dovecot
168 169 170
	mv "$pkgdir"/usr/lib/dovecot/dovecot-config \
		"$subpkgdir"/usr/lib/dovecot/
}
171

172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
lmtpd() {
	pkgdesc="$pkgdesc (LMTP server)"
	_protocol lmtp
}

pop3d() {
	pkgdesc="$pkgdesc (POP3 daemon)"
	_protocol pop3
}

submissiond() {
	pkgdesc="$pkgdesc (mail submission agent)"
	_protocol submission
}

_protocol() {
	depends="$pkgname=$pkgver-r$pkgrel"
	replaces="$pkgname"  # for backward compatibility
	local name="$1"
	local protocolsd="$subpkgdir/usr/share/dovecot/protocols.d"

	cd "$pkgdir"
	_submv usr/libexec/dovecot/$name*
	_submv etc/dovecot/conf.d/*-$name.conf

	mkdir -p "$protocolsd"
198
	echo "protocols = \$protocols $name" \
199 200 201
		> "$protocolsd"/${subpkgname#$pkgname-}.conf
}

202
_sieve() {
Jakub Jirutka's avatar
Jakub Jirutka committed
203
	pkgdesc="Sieve and managesieve plugin for Dovecot"
204
	depends="$pkgname=$pkgver-r$pkgrel"
Jakub Jirutka's avatar
Jakub Jirutka committed
205 206 207 208 209 210 211

	cd "$pkgdir"
	_submv $(find usr/ -name '*sieve_extprograms*')
	_submv $(find usr/ -name '*sieve_imapsieve*')
	_submv $(find usr/ -name '*sieve*')
	_submv $(find usr/ -name '*pigeonhole*')
	_submv $(find etc/dovecot/ -name '*sieve*')
212 213
}

214
_sieve_ldap() {
Jakub Jirutka's avatar
Jakub Jirutka committed
215
	pkgdesc="Sieve and managesieve plugin for Dovecot (LDAP support)"
216
	depends="$pkgname-pigeonhole-plugin=$pkgver-r$pkgrel $pkgname-ldap=$pkgver-r$pkgrel"
Jakub Jirutka's avatar
Jakub Jirutka committed
217 218 219

	cd "$pkgdir"
	_submv $(find usr/ -name '*_sieve_storage_ldap_*')
220 221
}

222
pgsql() {
Jakub Jirutka's avatar
Jakub Jirutka committed
223
	pkgdesc="PostgreSQL driver for Dovecot"
224
	depends="$pkgname-sql=$pkgver-r$pkgrel"
Jakub Jirutka's avatar
Jakub Jirutka committed
225 226 227

	cd "$pkgdir"
	_submv $(find usr/ -name '*_pgsql*')
228 229 230
}

mysql() {
Jakub Jirutka's avatar
Jakub Jirutka committed
231
	pkgdesc="MySQL driver for Dovecot"
232
	depends="$pkgname-sql=$pkgver-r$pkgrel"
Jakub Jirutka's avatar
Jakub Jirutka committed
233 234 235

	cd "$pkgdir"
	_submv $(find usr/ -name '*_mysql*')
236 237 238
}

sqlite() {
Jakub Jirutka's avatar
Jakub Jirutka committed
239
	pkgdesc="SQLite driver for Dovecot"
240
	depends="$pkgname-sql=$pkgver-r$pkgrel"
Jakub Jirutka's avatar
Jakub Jirutka committed
241 242 243

	cd "$pkgdir"
	_submv $(find usr/ -name '*_sqlite*')
244 245
}

246
gssapi() {
Jakub Jirutka's avatar
Jakub Jirutka committed
247
	pkgdesc="GSSAPI auth plugin for Dovecot"
248
	depends="$pkgname=$pkgver-r$pkgrel"
Jakub Jirutka's avatar
Jakub Jirutka committed
249 250 251

	cd "$pkgdir"
	_submv $(find usr/ -name '*_gssapi*')
252 253 254
}

ldap() {
Jakub Jirutka's avatar
Jakub Jirutka committed
255
	pkgdesc="LDAP auth plugin for Dovecot"
256
	depends="$pkgname=$pkgver-r$pkgrel"
Jakub Jirutka's avatar
Jakub Jirutka committed
257 258 259 260

	cd "$pkgdir"
	_submv $(find usr/ -name '*[_-]ldap*')
	_submv $(find etc/dovecot/ -name '*-ldap.conf*')
261 262
}

263 264
sql() {
	pkgdesc="SQL plugin for dovecot"
265
	depends="$pkgname=$pkgver-r$pkgrel"
Jakub Jirutka's avatar
Jakub Jirutka committed
266 267 268 269

	cd "$pkgdir"
	_submv $(find usr/ -name '*-sql.*')
	_submv $(find etc/dovecot/ -name '*-sql.conf*')
Natanael Copa's avatar
Natanael Copa committed
270
}
271

272 273
_fts_solr() {
	pkgdesc="FTS-Solr plugin for dovecot"
274
	depends="$pkgname=$pkgver-r$pkgrel"
Jakub Jirutka's avatar
Jakub Jirutka committed
275 276 277

	cd "$pkgdir"
	_submv $(find usr/ -name '*fts*solr*')
278 279 280 281
}

_fts_lucene() {
	pkgdesc="FTS-Lucene plugin for dovecot"
282
	depends="$pkgname=$pkgver-r$pkgrel"
Jakub Jirutka's avatar
Jakub Jirutka committed
283 284 285 286 287 288 289 290 291 292 293 294 295 296

	cd "$pkgdir"
	_submv $(find usr/ -name '*fts*lucene*')
}

_submv() {
	local dir
	while [ $# -gt 0 ]; do
		dir=${1%/*}
		mkdir -p "$subpkgdir"/$dir
		mv "$pkgdir/$1" "$subpkgdir/$dir/"
		[ "$(ls -A $pkgdir/$dir)" ] || rmdir "$pkgdir"/$dir
		shift
	done
297
}
TBK's avatar
TBK committed
298

299 300
sha512sums="ff21aa0f0cae17dfa66617291688856727412defa48bad2b6be057cb509fbec1c2e134afbfee69929d06b8692a0fcbd8451671ba02860e1673ae1c9483c2c17e  dovecot-2.3.4.1.tar.gz
9c82cce7540f8ab66e2e370e0220c99048d6ac53ed680cd763e0b03d0200e2451cee4303ef97b87a16e7248e1c73b92ba91b47a2a20c75cb2cd62695a28046f3  dovecot-2.3-pigeonhole-0.5.4.tar.gz
TBK's avatar
TBK committed
301
fe4fbeaedb377d809f105d9dbaf7c1b961aa99f246b77189a73b491dc1ae0aa9c68678dde90420ec53ec877c08f735b42d23edb13117d7268420e001aa30967a  skip-iconv-check.patch
302
794875dbf0ded1e82c5c3823660cf6996a7920079149cd8eed54231a53580d931b966dfb17185ab65e565e108545ecf6591bae82f935ab1b6ff65bb8ee93d7d5  split-protocols.patch
303
0d8f89c7ba6f884719b5f9fc89e8b2efbdc3e181de308abf9b1c1b0e42282f4df72c7bf62f574686967c10a8677356560c965713b9d146e2770aab17e95bcc07  default-config.patch
304
9f19698ab45969f1f94dc4bddf6de59317daee93c9421c81f2dbf8a7efe6acf89689f1d30f60f536737bb9526c315215d2bce694db27e7b8d7896036a59c31f0  dovecot.logrotate
305 306
d91951b81150d7a3ef6a674c0dc7b012f538164dac4b9d27a6801d31da6813b764995a438f69b6a680463e1b60a3b4f2959654f68e565fe116ea60312d5e5e70  dovecot.initd
07500fdc27e8e76f8325e7160e3ac0dfd80e3dcb6d310499ea3b7d6c7899809bbb76c01aec78c4b8b9bf80cd8260dbc26726a612357d30f3b3c8be80f77f9abd  mysql-fix-double-close.patch"