summaryrefslogtreecommitdiffstats
path: root/extra/postfix/APKBUILD
blob: a0a83f46f7789af7fa5751868559d77ca9407f9a (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
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=postfix
pkgver=2.6.1
pkgrel=0
pkgdesc="Secure and fast drop-in replacement for Sendmail (MTA)"
url="http://www.postfix.org/"
license="IPL-1"
depends="db pcre openssl libsasl"
makedepends="db-dev pcre-dev openssl-dev postgresql-dev mysql-dev openldap-dev cyrus-sasl-dev"
install="$pkgname.pre-install $pkgname.post-install"
subpackages="$pkgname-doc $pkgname-ldap $pkgname-mysql $pkgname-pcre
	$pkgname-pgsql"
source="ftp://ftp.porcupine.org/mirrors/$pkgname-release/official/$pkgname-$pkgver.tar.gz
	$pkgname.initd
	$install
	postfix-2.6.1-dynamicmaps.patch
	dynamicmaps.cf
	postfix-ldap.post-install
	postfix-mysql.post-install
	postfix-pcre.post-install
	postfix-pgsql.post-install
	"

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

build () { 
	cd "$srcdir/$pkgname-$pkgver"
	for i in ../*.patch; do
		msg "Applying $i..."
		patch -p1 < $i || return 1
	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

	# 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"

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

	for i in 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 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="postfix uclibc $@"
	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  libldap; }
mysql() { _mv_dict mysql libmysqlclient;}
pcre()  { _mv_dict pcre  pcre; }
pgsql() { _mv_dict pgsql libpq; }

md5sums="737bbc245da9c72c174893397f70ae86  postfix-2.6.1.tar.gz
8416354d402f3be288fa98b60af86240  postfix.initd
2bfc3864183694e5484ac073bb0cb7ef  postfix.pre-install
0064d45c2c8a46c374b55c4abc46cfb2  postfix.post-install
b8812dbf2d076c79cf948ee017e81b39  postfix-2.6.1-dynamicmaps.patch
0efff9b4bb493ad2ff0b9915cb244d14  dynamicmaps.cf
2ebe51a882eb9d6d7866583eb6af3969  postfix-ldap.post-install
2ebe51a882eb9d6d7866583eb6af3969  postfix-mysql.post-install
2ebe51a882eb9d6d7866583eb6af3969  postfix-pcre.post-install
2ebe51a882eb9d6d7866583eb6af3969  postfix-pgsql.post-install"