aboutsummaryrefslogtreecommitdiffstats
path: root/main/postfix/APKBUILD
blob: 4115be5cfbde7e054b1220d3dfcc1f5e962f65e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# Contributor: Valery Kartel <valery.kartel@gmail.com>
# Contributor: Łukasz Jendrysik <scadu@yandex.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=postfix
pkgver=3.2.4
pkgrel=1
pkgdesc="Secure and fast drop-in replacement for Sendmail (MTA)"
url="http://www.postfix.org/"
arch="all"
license="IPL-1"
depends=
makedepends="db-dev pcre-dev libressl-dev postgresql-dev mariadb-dev openldap-dev
	cyrus-sasl-dev perl file sqlite-dev linux-headers coreutils"
install="$pkgname.pre-install"
subpackages="$pkgname-doc $pkgname-ldap $pkgname-mysql $pkgname-pcre
	$pkgname-pgsql $pkgname-sqlite $pkgname-stone"
options="suid"
pkgusers="postfix"
pkggroups="postfix postdrop"
source="ftp://ftp.porcupine.org/mirrors/$pkgname-release/official/$pkgname-$pkgver.tar.gz
	$pkgname.initd
	no-glibc.patch
	postfix-install.patch
	libressl.patch
	"

_shared_libs() {
	file --mime-type "$@" | \
		awk -F: '$2 ~ /sharedlib/ {print $1}'
}

builddir="$srcdir"/$pkgname-$pkgver
prepare() {
	cd $builddir
	default_prepare

	sed -i -e "s|#define HAS_NIS|//#define HAS_NIS|g" \
		-e "/^#define ALIAS_DB_MAP/s|:/etc/aliases|:/etc/postfix/aliases|" \
		src/util/sys_defs.h
	sed -i -e "s:/usr/local/:/usr/:g" conf/master.cf
}

build() {
	cd $builddir
	# needed for dynamic maps.
	local ccargs="-DHAS_SHL_LOAD -DDEF_DAEMON_DIR=\\\"/usr/lib/postfix\\\""
	local auxlibs="$LDFLAGS"

	# pcre
	ccargs="$ccargs -DHAS_PCRE $(pkg-config --cflags libpcre)"

	# ssl
	ccargs="$ccargs -DUSE_TLS"
	auxlibs="$auxlibs -lssl -lcrypto"

	# dovecot-sasl
	ccargs="$ccargs -DUSE_SASL_AUTH -DDEF_SASL_SERVER=\\\"dovecot\\\""

	# cyrus sasl
	ccargs="$ccargs -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl"
	auxlibs="$auxlibs -lsasl2"

	# postgresql
	ccargs="$ccargs -DHAS_PGSQL $(pkg-config --cflags libpq)"

	# mysql
	ccargs="$ccargs -DHAS_MYSQL $(mysql_config --include)"

	# ldap
	ccargs="$ccargs -DHAS_LDAP -DUSE_LDAP_SASL"

	# sqlite
	ccargs="$ccargs -DHAS_SQLITE $(pkg-config --cflags sqlite3)"

	#
	#	AUXLIBS_CDB="$cdb_libs" \
	#	AUXLIBS_LMDB="$lmdb_libs" \

	# compile
	make DEBUG="" \
		OPT="$CFLAGS" \
		CCARGS="$ccargs" \
		AUXLIBS="$auxlibs" \
		AUXLIBS_LDAP="-lldap -llber" \
		AUXLIBS_MYSQL="$(mysql_config --libs)" \
		AUXLIBS_PCRE="$(pkg-config --libs libpcre)" \
		AUXLIBS_PGSQL="$(pkg-config --libs libpq)" \
		AUXLIBS_SQLITE="$(pkg-config --libs sqlite3)" \
		dynamicmaps=yes \
		shared=yes \
		makefiles

	make OPT="$CFLAGS"
}

_mvline() {
	local regex="$1"
	local outfile="$3.d/$2"
	local infile="$3"
	sed -i -E -e "\|$regex|{
w $outfile
d
}" $infile
}

package() {
	cd "$builddir"

	make non-interactive-package \
		install_root="$pkgdir" \
		readme_directory=/usr/share/doc/$pkgname/readme \
		manpage_directory=/usr/share/man \
		shlib_directory=/usr/lib/postfix

	for i in postdrop postqueue; do
		chgrp postdrop "$pkgdir"/usr/sbin/$i
		chmod g+s "$pkgdir"/usr/sbin/$i
	done

	mkdir -p "$pkgdir"/usr/share/doc/postfix/defaults/ \
		"$pkgdir"/usr/share/licenses/${pkgname}/
	mv "$pkgdir"/etc/postfix/*.default "$pkgdir"/etc/postfix/*.proto \
		"$pkgdir"/usr/share/doc/postfix/defaults/
	mv "$pkgdir"/etc/postfix/*LICENSE* \
		"$pkgdir"/usr/share/licenses/${pkgname}/

	chown postfix:postfix "$pkgdir"/var/spool/postfix
	install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
	chown postfix "$pkgdir"/var/spool/postfix/* "$pkgdir"/var/lib/postfix
	chgrp postdrop "$pkgdir"/var/spool/postfix/maildrop \
		"$pkgdir"/var/spool/postfix/public

	cd "$pkgdir"/etc/postfix/
	for map in ldap mysql pcre pgsql sqlite; do
		msg "split $map"
		_mvline "^\s*$map" "$map" dynamicmaps.cf
	done
	rm makedefs.out
}

_mv_dict() {
	local m=$1
	shift
	pkgdesc="$m map support for postfix"
	depends=
	mkdir -p "$subpkgdir"/usr/lib/postfix \
		"$subpkgdir"/etc/postfix/dynamicmaps.cf.d
	mv "$pkgdir"/usr/lib/postfix/postfix-${m}.so \
		"$subpkgdir"/usr/lib/postfix/
	mv "$pkgdir"/etc/postfix/dynamicmaps.cf.d/${m} \
		"$subpkgdir"/etc/postfix/dynamicmaps.cf.d/
}

ldap()  { _mv_dict ldap ; }
mysql() { _mv_dict mysql ;}
pcre()  { _mv_dict pcre ; }
pgsql() { _mv_dict pgsql ; }
sqlite() { _mv_dict sqlite ; }

stone() {
	cd $builddir
	pkgdesc="Postfix simulation and testing tools"
	install -Dm755 src/fsstone/fsstone "$subpkgdir"/usr/bin/fsstone
	find src/smtpstone -perm 0755 -exec cp {} "$subpkgdir"/usr/bin \;
}

sha512sums="6dc583d3b1c98f5c8d6486351bee9f92a98b5379cd0d76d26a382379c112317e7a2a58c3a200477a6d0f831c73395257d1a63170df17ea8a65a4048a7df391f8  postfix-3.2.4.tar.gz
2752e69c4e1857bdcf29444ffb458bca818bc60b9c77c20823c5f5b87c36cb5e0f3217a625a7fe5788d5bfcef7570a1f2149e1233fcd23ccf7ee14190aff47a2  postfix.initd
cf9ef0d07e54011107da57e2855cbda10047c100047e2cc2fdede072ace1fc6c060a6b1cfc8c277417a28a23ecd3c6ffdc061da1673e8f61d2ed11899f1efb25  no-glibc.patch
25cd34f23ca909d4e33aaf3239d1e397260abc7796d9a4456dee4f005682fd3a58aab8106126e5218c95bdddae415a3ef7e2223cd3b0d7b1e2bd76158bb7eaf8  postfix-install.patch
7d43dc0d4e44bb3c62b28b4c6dfb9dc49e4d95e948a27e309dc7d7ea6b7fe844f433d908fe87d0fee3e236a32b2e94d37804dba2a4d17cf0c44ab3a8c2d44e62  libressl.patch"