aboutsummaryrefslogtreecommitdiffstats
path: root/main/kamailio/APKBUILD
blob: 13b03c6fc4135d1a92cd8049edde3d6ee80b0c5a (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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# Contributor: Michael Mason <ms13sp@gmail.com>
# Maintainer: Nathan Angelacos <nangel@alpinelinux.org>
pkgname=kamailio
pkgver=4.0.1
pkgrel=0
pkgdesc="Open Source SIP Server"
url="http://www.kamailio.org/"
pkgusers="kamailio"
pkggroups="kamailio"
arch="all"
license="GPL"
depends=
arch=all
makedepends="bison flex expat-dev postgresql-dev pcre-dev mysql-dev
	libxml2-dev curl-dev unixodbc-dev confuse-dev ncurses-dev sqlite-dev
	lua-dev openldap-dev openssl-dev net-snmp-dev"
install="$pkgname.pre-install $pkgname.pre-upgrade"

# Source the kamailio.groups file for the definition of all the various modules
. ./kamailio.groups

subpackages="$pkgname-doc"
_modules="$module_group_kstandard"
for i in db postgres sqlite dbtext mysql \
    cpl xml unixodbc snmpstats xmpp carrierroute \
    ldap utils tls presence lua ims outbound dbg \
    extra; do
   
   subpackages="$subpackages $pkgname-$i"
   _modules="$_modules `eval echo $\module_group_k$i`"
done

source="http://www.kamailio.org/pub/kamailio/$pkgver/src/kamailio-${pkgver}_src.tar.gz
	fix-sql-module-loading-order.patch
	kamailio.cfg
	kamailio.initd
    kamailio.groups
	"

_builddir="$srcdir"/$pkgname-$pkgver




prepare() {
	cd "$_builddir"
	for i in $source; do
		case $i in
		*.patch)
			msg "Applying $i"
			patch -p1 -i "$srcdir"/$i || return 1
			;;
		esac
	done

	sed -i \
		-e "s:-O9 -funroll-loops:$CFLAGS:g" \
		Makefile.defs \
		|| return 1

#		-e 's:^cfg-target.*:cfg-target = $(cfg-dir):' \
#		-e 's:^cfg-prefix.*:cfg-prefix = $(basedir):' \

	cd utils/kamctl/
	sed -i -e 's:/var/run/kamailio.pid:/var/run/kamailio/kamailio.pid:g' \
		kamctl.base kamctlrc || return 1
	# we actually dont need bash
	sed -i -e 's:/bin/bash:/bin/sh:' kamctl kamdbctl \
		|| return 1
	# Set email_address field as not required field (could be null)
	cd dbtext/kamailio
	sed -i -e 's:email_address(string):email_address(string,null):' subscriber \
		|| return 1

}

build() {
	cd "$_builddir"
	make FLAVOUR=kamailio STUN=1 \
		PREFIX=/usr \
		cfg_target=/etc/kamailio/ \
		include_modules="$_modules" \
		LIBDIR=lib \
		DESTDIR="$pkgdir" \
		cfg_prefix="$pkgdir" \
		cfg
	make all || return 1
}

package() {
	cd "$_builddir"
	make  -j1 install || return 1

	# move default config to -doc package and use our own default config

	mv "$pkgdir"/etc/kamailio/kamailio.cfg \
		"$pkgdir"/usr/share/doc/kamailio/
	install -m644 -D "$srcdir"/kamailio.cfg \
		"$pkgdir"/etc/kamailio/kamailio.cfg 

	install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
	install -d -o kamailio "$pkgdir"/var/run/kamailio
}

_mv_mod() {
	local moddir=usr/lib/kamailio/modules i=
	mkdir -p "$subpkgdir"/$moddir
	for i in $@; do
		mv "$pkgdir"/$moddir/$i.so "$subpkgdir"/$moddir/ || return 1
	done
}

_generic_pkg() {
	pkgdesc="Kamailio $1"
	depends="$pkgname"
	_mv_mod $2
}


_db_driver() {
	pkgdesc="Database drivers for $1"
	depends="$pkgname $pkgname-db"
	_mv_mod db_$2 || return 1
	mkdir -p "$subpkgdir"/usr/share/kamailio \
		"$subpkgdir"/usr/lib/kamailio/kamctl
	mv "$pkgdir"/usr/share/kamailio/$3 \
		"$subpkgdir"/usr/share/kamailio/ || return 1
	mv "$pkgdir"/usr/lib/kamailio/kamctl/*.$4 \
		"$subpkgdir"/usr/lib/kamailio/kamctl/ || return 1
}

db() {
    _generic_pkg "modules using a database backend" "$module_group_db"
}

postgres() {
    _db_driver Postgres postgres postgres pgsql
}

mysql() {
    _db_driver Mysql mysql mysql mysql
}

sqlite() {
    _db_driver SQlite sqlite db_sqlite sqlite
}

dbtext() {
    _db_driver DBText text dbtext dbtext || return 1
    depends="$depends python"
    mkdir -p "$subpkgdir"/usr/lib/kamailio/kamctl
    mv "$pkgdir"/usr/lib/kamailio/kamctl/dbtextdb \
        "$subpkgdir"/usr/lib/kamailio/kamctl/
}


cpl() {
    _generic_pkg "CPL (Call Processing Language) interpreter" \
        "$module_group_kcpl"
}

xml() {
    _generic_pkg "XML related modules: $module_group_kxml" \
        "$module_group_kxml" || return 1
    mkdir -p "$subpkgdir"/usr/share/kamailio
    mv "$pkgdir"/usr/share/kamailio/xhttp_pi \
        "$subpkgdir"/usr/share/kamailio || return 1
    mkdir -p "$subpkgdir"/etc/kamailio/
    mv "$pkgdir"/etc/kamailio/pi_framework.xml \
        "$subpkgdir"/etc/kamailio || return 1
}

unixodbc() {
    _generic_pkg "Database drivers for unixodbc" \
        "$module_group_kunixodbc"
}

snmpstats() {
    _generic_pkg "SNMP statistics support" \
        "$module_group_ksnmpstats" || return 1
    mkdir -p "$subpkgdir"/usr/share/snmp
    mv "$_builddir"/modules/snmpstats/mibs \
       "$subpkgdir"/usr/share/snmp/ || return 1
}

xmpp() {
    _generic_pkg "XMPP (Jabber) gateway" \
        "$module_group_kxmpp"
}

carrierroute() {
    _generic_pkg "carrier grade routing functions" \
        "$module_group_kcarrierroute"
}

ldap() {
    _generic_pkg "LDAP search functions" \
        "$module_group_kldap"
}

utils() {
    _generic_pkg "miscelaneous utility functions" \
        "$module_group_kutils"
}

tls() {
    _generic_pkg "TLS support" \
        "$module_group_ktls"
}

presence() {
    _generic_pkg "SIP Notify (Presence) support" \
        "$module_group_kpresence"
}

lua() {
	_generic_pkg "Lua script support" \
        "$module_group_klua"
}

ims() {
    _generic_pkg "IP Multimedia Subsystem (IMS) support" \
        "$module_group_kims"
}

outbound() {
    _generic_pkg "RFC 5626 section 5 Outbound suppport" \
        "$module_group_koutbound"
}

dbg() {
    _generic_pkg "debugging modules" \
        "$module_group_kdbg"
}

extra() {
    _generic_pkg "extra modules" \
        "$mod_list_extra"
}


md5sums="ab57fcb1eb1195fa45f5c0935810e42a  kamailio-4.0.1_src.tar.gz
53cca39c47399eb2df20a1044d1e29eb  fix-sql-module-loading-order.patch
a3c959ec568c43a905710e7d25cd8c25  kamailio.cfg
9c190575e28772a784c4172216d85333  kamailio.initd
56a85be6c8e1b2c30d72a9b4acbdb5da  kamailio.groups"