summaryrefslogtreecommitdiffstats
path: root/main/postfix/APKBUILD
blob: 6adbbab17d5d34610dfb8efd4a9080ffa14e6951 (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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=postfix
pkgver=2.10.0
pkgrel=0
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 openssl-dev postgresql-dev mysql-dev openldap-dev
	cyrus-sasl-dev perl file sqlite-dev"
install="$pkgname.pre-install"
subpackages="$pkgname-doc $pkgname-ldap $pkgname-mysql $pkgname-pcre
	$pkgname-pgsql $pkgname-sqlite"
source="ftp://ftp.porcupine.org/mirrors/$pkgname-release/official/$pkgname-$pkgver.tar.gz
	$pkgname.initd
	dynamic-maps3.patch
	dynamicmaps.cf
	postfix-ldap.post-install
	postfix-mysql.post-install
	postfix-pcre.post-install
	postfix-pgsql.post-install
	postfix-sqlite.post-install
	"

# the dynamic maps patch is taken from mandriva
# http://svn.mandriva.com/cgi-bin/viewvc.cgi/packages/cooker/postfix/current/SOURCES

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

prepare() {
	cd "$srcdir/$pkgname-$pkgver"
	for i in $source; do
		case $i in
		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
		esac
	done
	cp ../dynamicmaps.cf conf/

	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 || return 1
	sed -i -e "s:/usr/local/:/usr/:g" conf/master.cf || return 1
}

build () { 
	cd "$srcdir/$pkgname-$pkgver"
	# needed for dynamic maps.
	local ccargs="-DHAS_DLOPEN -DHAS_SHL_LOAD"
	local auxlibs="$LDFLAGS -lpthread -lcrypt"

	ccargs="$ccargs -DDEF_DAEMON_DIR=\\\"/usr/lib/postfix\\\""

	# pcre
	ccargs="$ccargs -DHAS_PCRE"
	#auxlibs="$auxlibs -lpcre"

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

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

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

	# postgresql
	ccargs="$ccargs -DHAS_PGSQL -I$(pg_config --includedir)"
	#auxlibs="$auxlibs -lpq -L$(pg_config --libdir)"

	# mysql
	ccargs="$ccargs -DHAS_MYSQL $(mysql_config --include)"
	#auxlibs="$auxlibs -lmysqlclient -lm -lz"

	# ldap
	ccargs="$ccargs -DHAS_LDAP"
	#auxlibs="$auxlibs -lldap -llber"
	
	# sqlite
	ccargs="$ccargs -DHAS_SQLITE"

	# compile
	make DEBUG="" \
		OPT="$CFLAGS" \
		CCARGS="$ccargs" \
		AUXLIBS="$auxlibs" \
		makefiles || return 1
	
	make OPT="$CFLAGS" || return 1
}

package() {
	cd "$srcdir/$pkgname-$pkgver"
	for i in $(_shared_libs lib/*.a); do
		j=${i#lib/lib}
		ln -s ${i#lib/} lib/libpostfix-${j%.a}.so.1
	done

	# install to pkgdir
	LD_LIBRARY_PATH=$PWD/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} make \
		non-interactive-package \
		install_root="$pkgdir" \
		config_directory=/usr/share/doc/$pkgname/defaults \
		readme_directory=/usr/share/doc/$pkgname/readme \
		manpage_directory=/usr/share/man \
		|| return 1

	install -d "$pkgdir"/usr/lib
	for i in $(_shared_libs lib/*.a); do
		j=${i#lib/lib}
		install $i "$pkgdir"/usr/lib/libpostfix-${j%.a}.so.1 || return 1
	done

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

	mkdir -p "$pkgdir"/etc/postfix
	mv "$pkgdir"/usr/share/doc/$pkgname/defaults/*.cf \
		"$pkgdir"/usr/share/doc/$pkgname/defaults/aliases \
		"$pkgdir"/usr/share/doc/$pkgname/defaults/canonical \
		"$pkgdir"/usr/share/doc/$pkgname/defaults/generic \
		"$pkgdir"/usr/share/doc/$pkgname/defaults/header_checks \
		"$pkgdir"/usr/share/doc/$pkgname/defaults/relocated \
		"$pkgdir"/usr/share/doc/$pkgname/defaults/transport \
		"$pkgdir"/usr/share/doc/$pkgname/defaults/virtual \
		"$pkgdir"/etc/postfix/ || return 1

	install -d -o postfix -g postfix "$pkgdir"/var/spool/postfix
	install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
	install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/${pkgname}/LICENSE
	chown postfix "$pkgdir"/var/spool/postfix/* "$pkgdir"/var/lib/postfix \
		|| return 1
	chgrp postdrop "$pkgdir"/var/spool/postfix/maildrop \
		"$pkgdir"/var/spool/postfix/public || return 1
}

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

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

md5sums="b2a563b2d5c53462952886e6fc4e4b7b  postfix-2.10.0.tar.gz
d773f01dcc965d219a8a37b88f89c5bf  postfix.initd
8de3f108639eda995162c590053a1278  dynamic-maps3.patch
442efd1a95b0c061dfb8ab75456e0f24  dynamicmaps.cf
2ebe51a882eb9d6d7866583eb6af3969  postfix-ldap.post-install
2ebe51a882eb9d6d7866583eb6af3969  postfix-mysql.post-install
fd16ec00b60269c4ede4a0a0a514cefa  postfix-pcre.post-install
2ebe51a882eb9d6d7866583eb6af3969  postfix-pgsql.post-install
2ebe51a882eb9d6d7866583eb6af3969  postfix-sqlite.post-install"
sha256sums="4a42a6029af418cbd4a8668b4f8c7e1ea9975cbe9756df760649c0a941bfeb7b  postfix-2.10.0.tar.gz
6b3fe71542ab783c7adddbfa161f7e2dcb2325913ad5d611ca56f730876ce4ab  postfix.initd
a0e1d4c1622a7a7696461012831ea6c0fd57bd00182935692cf91ed6b4819f5f  dynamic-maps3.patch
2041ff6cd71fe16f3d75603ff40d90a08a8b97f0883e1de1d58563ab1521b5ea  dynamicmaps.cf
fbd75ef31a5d78d5f82b67e08e5bf5ada380afa58a69ef4a07d756c47b3bb498  postfix-ldap.post-install
fbd75ef31a5d78d5f82b67e08e5bf5ada380afa58a69ef4a07d756c47b3bb498  postfix-mysql.post-install
8dbe9339aeac4932e5ee383bfe497512607cd819fe67c38cbf7273118c4b0f71  postfix-pcre.post-install
fbd75ef31a5d78d5f82b67e08e5bf5ada380afa58a69ef4a07d756c47b3bb498  postfix-pgsql.post-install
fbd75ef31a5d78d5f82b67e08e5bf5ada380afa58a69ef4a07d756c47b3bb498  postfix-sqlite.post-install"
sha512sums="88689c2b18aeecd6e363525955c8e3506acf7702eb7fabe148b72a149020c29a76b3f6ed57109380ebb2106cf798a0ce78d470bc4a104a8ecde6c1c4cd0da07e  postfix-2.10.0.tar.gz
c179534a7243bcf8c19b5367a703b54fcc88b7587ce7ef07ec111cfe00053779eed23b3ccda81eb20059599b857cae0a57cc02613526209f3dd966d65abd9a3f  postfix.initd
8bf5a62658e069b72a7d65bd381d7d3be6f531747b0e5e55760d9fb9f42706bb1bd010ec1a4ca4836d67502a7273d8300644a51015accf21c419403ffddfdb2d  dynamic-maps3.patch
49b8205166f575e5fb9bdaaaaa042dc1be9b556331bf659a55b1115c9fa48486896941f18ca9fb633dd54675079f29a9d69d53c214170731c2127862456ec90b  dynamicmaps.cf
b35931865eb15b5cd6a2b95bbf486cd064d1447eac1a91d507a7d23155229ac7e7fdf6b8518e663c5c7072b201786c72aead0d95e94d8708a9b5a7c3f37be138  postfix-ldap.post-install
b35931865eb15b5cd6a2b95bbf486cd064d1447eac1a91d507a7d23155229ac7e7fdf6b8518e663c5c7072b201786c72aead0d95e94d8708a9b5a7c3f37be138  postfix-mysql.post-install
845871cacebb8c4d2073783db06a704c993d258f3113ac6c416e742f87649e8eababceb5f8426849256e7815c492e24654468ee76e7607d91b506e8cba78f2ed  postfix-pcre.post-install
b35931865eb15b5cd6a2b95bbf486cd064d1447eac1a91d507a7d23155229ac7e7fdf6b8518e663c5c7072b201786c72aead0d95e94d8708a9b5a7c3f37be138  postfix-pgsql.post-install
b35931865eb15b5cd6a2b95bbf486cd064d1447eac1a91d507a7d23155229ac7e7fdf6b8518e663c5c7072b201786c72aead0d95e94d8708a9b5a7c3f37be138  postfix-sqlite.post-install"