aboutsummaryrefslogtreecommitdiffstats
path: root/main/postfix/APKBUILD
blob: 4757cfd0faa0300ca71b0121e66bdae0ae58dce1 (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
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=postfix
pkgver=2.9.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 $pkgname.post-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 '$2 == "application/x-sharedlib" {print $1}' | \
		tr -d :
}

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
}

_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="43a5ea2d6fb39185a60b4635e016967e  postfix-2.9.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"