summaryrefslogtreecommitdiffstats
path: root/main/kamailio/APKBUILD
blob: d108e6315dc7d4dc05307e9ba5f52cc60e0f4acf (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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
# Contributor: Łukasz Jendrysik <scadu@yandex.com>
# Contributor: Michael Mason <ms13sp@gmail.com>
# Contributor: Leonardo Arena <rnalrd@gmail.com>
# Maintainer: Nathan Angelacos <nangel@alpinelinux.org>
pkgname=kamailio

# If building from a git snapshot, specify the gitcommit
# run "abuild snapshot", then abuild as normal
# If building a proper release, leave gitcommit blank
#_gitcommit=e27802533cee
_giturl="git://github.com/$pkgname/$pkgname.git"
_gittag=HEAD


pkgver=4.3.5
pkgrel=1
[ -z "${_gitcommit}" ] && _suffix="_src" || _suffix="-${_gitcommit}"

pkgdesc="Open Source SIP Server"
url="http://www.kamailio.org/"
arch="all"
pkgusers="kamailio"
pkggroups="kamailio"
arch="all"
license="GPL2+"
depends=""
makedepends="bison flex expat-dev postgresql-dev pcre-dev mariadb-dev
	libxml2-dev curl-dev unixodbc-dev confuse-dev ncurses-dev sqlite-dev
	lua-dev openldap-dev openssl-dev net-snmp-dev libuuid libev-dev
	jansson-dev json-c-dev libevent-dev linux-headers libmemcached-dev
	hiredis-dev libmaxminddb-dev"
install="$pkgname.pre-install $pkgname.pre-upgrade"

# See Makefile.groups for the list of recommended modules for
# each package.  What follows is a simplified version of Makefile.groups
#
# Alpine specific changes:
#
# _mod_list_debugger is not defined in the orginal
#
# Move avp from _mod_list_extras to _mod_list_basic, so that we can create
# a kamailio-extras package
#
# Remove db_text from _mod_list_db because we create a separate dbtext package
#
# - basic used modules, with no extra dependency (widespread usage)
_mod_list_basic="avp async auth benchmark blst cfg_rpc cfgutils corex counters \
		ctl debugger diversion enum exec gzcompress ipops kex mangler \
		maxfwd mediaproxy mi_datagram mi_fifo mi_rpc mqueue \
		nat_traversal nathelper path pike pv ratelimit rr rtimer \
		rtpproxy sanity sdpops siputils sl statistics textops \
		textopsx tm tmx topoh xlog rtpengine stun sipt"

# - extra used modules, with no extra dependency
_mod_list_extras="auth_diameter call_control cnxcc dmq domainpolicy msrp pdb \
		qos sca seas sms sst timer tmrec tsilo uac_redirect xhttp \
		xhttp_rpc xprint nosip dmq_usrloc statsd rtjson tcpops \
		auth_xkeys"

# - common modules depending on database
_mod_list_db="acc alias_db auth_db avpops cfg_db db_flatstore \
		db_cluster dialog dispatcher domain drouting group \
		htable imc matrix mohqueue msilo mtree p_usrloc pdt permissions \
		pipelimit prefix_route registrar sipcapture siptrace speeddial \
		sqlops uac uri_db userblacklist usrloc"

# - common modules depending on database, using UID db schema
_mod_list_dbuid="db2_ops uid_auth_db uid_avp_db uid_domain uid_gflags \
		uid_uri_db"

# - modules for devel purposes
_mod_list_devel="malloc_test print print_lib"

# - modules depending on pcre3 library
_mod_list_pcre="dialplan lcr regex"

# - modules depending on radius client library
_mod_list_radius="acc_radius auth_radius misc_radius peering"

# - modules depending on ldap client library
_mod_list_ldap="db2_ldap h350 ldap"

# - modules depending on mysql client library
_mod_list_mysql="db_mysql"

# - modules depending on postgres client library
_mod_list_postgres="db_postgres"

# - modules depending on unixodbc library
_mod_list_unixodbc="db_unixodbc"

# - modules depending on mysql cassandra library
_mod_list_cassandra="db_cassandra ndb_cassandra"

# - modules depending on xml2 library
_mod_list_cpl="cpl-c"

# - modules depending on xml2 library
_mod_list_xml="xhttp_pi xmlrpc xmlops"

# - modules depending on xml c rpc library
_mod_list_mi_xmlrpc="mi_xmlrpc"

# - modules depending on net-snmp library
_mod_list_snmpstats="snmpstats"

# - modules depending on expat library
_mod_list_xmpp="xmpp"

# - modules depending on confuse library
_mod_list_carrierroute="carrierroute"

# - modules depending on bdb (db4) library
_mod_list_berkeley="db_berkeley"

# - modules depending on curl library
_mod_list_utils="utils"

# - modules depending on purple library
_mod_list_purple="purple"

# - modules depending on memcache library
_mod_list_memcached="memcached"

# - modules depending on openssl library
_mod_list_tls="auth_identity tls"

# - modules depending on openssl library
_mod_list_outbound="outbound"

# - modules depending on unistring library
_mod_list_websocket="websocket"

# - modules depending on libval-threads libcrypto libsres libpthread
_mod_list_dnssec="dnssec"

# - modules depending on libsctp
_mod_list_sctp="sctp"

# - modules depending on openssl library
_mod_list_authephemeral="auth_ephemeral"

# - modules related to SIMPLE presence extensions
_mod_list_presence="presence presence_conference presence_dialoginfo \
			presence_mwi presence_profile presence_reginfo \
			presence_xml \
			pua pua_bla pua_dialoginfo pua_mi pua_reginfo \
			pua_usrloc pua_xmpp \
			rls xcap_client xcap_server"

# - modules depending on lua library
_mod_list_lua="app_lua"

# - modules depending on perl library
_mod_list_perl="app_perl db_perlvdb"

# - modules depending on python library
_mod_list_python="app_python"

# - modules depending on geoip2 library
_mod_list_geoip2="geoip2"

# - modules depending on sqlite library
_mod_list_sqlite="db_sqlite"

# - modules depending on oracle library
_mod_list_oracle="db_oracle"

# - modules depending on json library
_mod_list_json="json jsonrpc-c jsonrpc-s"

# - modules depending on redis library
_mod_list_redis="ndb_redis"

# - modules depending on mono library
_mod_list_mono="app_mono"

# - modules related to IMS extensions
_mod_list_ims="cdp cdp_avp dialog_ng ims_auth ims_isc ims_icscf ims_qos \
		ims_registrar_pcscf ims_registrar_scscf ims_usrloc_pcscf \
		ims_usrloc_scscf ims_charging"

# - modules depending on osp toolkit library
_mod_list_osp="osp"

# - modules depending on java library
_mod_list_java="app_java"

# - modules depending on iptables library
_mod_list_iptrtpproxy="iptrtpproxy"

# - modules depending on gzip library                                                         
_mod_list_gzcompress="gzcompress" 

# - modules depending on uuid library
_mod_list_uuid="uuid"

# - modules depending on ev library
_mod_list_ev="evapi"

# - modules depending on kazoo/rabbitmq
_mod_list_kazoo="kazoo"

# - modules depending on mongodb
_mod_list_mongodb="db_mongodb ndb_mongodb"

# - modules depending on jansson library
_mod_list_jansson="jansson janssonrpc-c"


# Alpine Specific
_mod_list_debugger="$_mod_list_devel benchmark debugger"

# Standard modules in main pkg
_module_group_kstandard="$_mod_list_basic $_mod_list_dbuid $_mod_list_pcre"

# END Makefile.groups #############################################################

subpackages="$pkgname-doc $pkgname-dbg"
_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 debugger \
	extras json websocket authephemeral \
	uuid ev memcached redis geoip2 jansson; do

   subpackages="$subpackages $pkgname-$_i"
   eval "_modules=\"\$_modules \$_mod_list_$_i\""
done

source="http://www.kamailio.org/pub/kamailio/$pkgver/src/${pkgname}-${pkgver}${_suffix}.tar.gz
	0001-musl-fixes.patch
	0002-mohqueue-v0-12.patch
	0003-kamdbctl-backslash.patch
	core-improve-to-header-check-guards.patch
	kamailio.cfg
	kamailio.initd
	"

snapshot() {
        mkdir -p "$srcdir"
        cd "${SRCDEST:-$srcdir}"
        if ! [ -d $pkgname.git ]; then
                git clone --bare  $_giturl || return 1
                cd $pkgname.git
        else
                cd $pkgname.git
                git fetch || return 1
        fi
        git archive --prefix=$pkgname-$pkgver/ -o "$SRCDEST"/${pkgname}-${pkgver}${_suffix}.tar.gz $_gittag
}



_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 \
		CC_EXTRA_OPTS="$CFLAGS -D_GNU_SOURCE" \
		cfg_target=/etc/kamailio/ \
		run_prefix="" \
		include_modules="$_modules" \
		LIBDIR=lib \
		DESTDIR="$pkgdir" \
		cfg_prefix="$pkgdir" \
		cfg
	make all EMBEDDED_UTF8_DECODE=1 || return 1
}

package() {
	cd "$_builddir"
	make  -j1 install EMBEDDED_UTF8_DECODE=1 || 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" "$_mod_list_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
	# kamdbctl.dbtext is a python script - but we will not make python 
	# a dependency because kamdbctl is not normaly used
	depends="$depends"
	mkdir -p "$subpkgdir"/usr/lib/kamailio/kamctl || return 1
	mv "$pkgdir"/usr/lib/kamailio/kamctl/dbtextdb \
		"$subpkgdir"/usr/lib/kamailio/kamctl/ || return 1
}

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

xml() {
	_generic_pkg "XML related modules: $_mod_list_xml" \
		"$_mod_list_xml" || 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" \
		"$_mod_list_unixodbc"
}

snmpstats() {
	_generic_pkg "SNMP statistics support" \
		"$_mod_list_snmpstats" || 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" \
		"$_mod_list_xmpp"
}

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

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

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

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

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

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

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

outbound() {
	_generic_pkg "RFC 5626 section 5 Outbound support" \
		"$_mod_list_outbound"
}

debugger() {
	_generic_pkg "debugging modules" \
		"$_mod_list_debugger"
}

extras() {
	_generic_pkg "extra modules" \
		"$_mod_list_extras"
}

websocket() {
	_generic_pkg "websocket support" \
		"$_mod_list_websocket"
}

authephemeral() {
	_generic_pkg "auth ephemeral (webrtc)" \
		"$_mod_list_authephemeral"
}

json() {
	_generic_pkg "Operations on json strings" \
		"$_mod_list_json"
}

jansson() {
	_generic_pkg "Operations on json strings using jansson library" \
		"$_mod_list_jansson"
}

geoip2() {
	_generic_pkg "MaxMind GeoIP lookup support" \
		"$_mod_list_geoip2"
}

ev() {
	_generic_pkg "Network event broadcast API" \
		"$_mod_list_ev"
}

uuid() {
	_generic_pkg "UUID generator using libuuid" \
		"$_mod_list_uuid"
}

memcached() {
	_generic_pkg "memcached support" \
		"$_mod_list_memcached"
}

redis() {
	_generic_pkg "Redis NoSQL support" \
		"$_mod_list_redis"
}

md5sums="117e08e69a973cc0c0d63662d2f47109  kamailio-4.3.5_src.tar.gz
18863791d386659eae6ef0c82a2517ae  0001-musl-fixes.patch
324ce879bceac05b30aa9466bb74916d  0002-mohqueue-v0-12.patch
fe8f61c73264cd1c360f3876f664464d  0003-kamdbctl-backslash.patch
7e4ec3df07c11701dee9277a5598ed8c  core-improve-to-header-check-guards.patch
299706d97e30a4f0d9b4c873df422866  kamailio.cfg
39dc9355fa7d8fec425d3b17c2fb26e0  kamailio.initd"
sha256sums="2c8c963a2cd0c997c66ccc65b8d5de01fd7f4b6b6053bcf10bf746d814b313d5  kamailio-4.3.5_src.tar.gz
254ea5d4699417aec49e1aae45398a802067a8967060f2a469e278779d876d22  0001-musl-fixes.patch
93e8ed5bbe16535286ab4cb586caf01cdf11f405492d36271108333210f0c58b  0002-mohqueue-v0-12.patch
46026949a3a367ebaf0c8a7d1ffeeaa3dc67588c94dd8d558991a54996877c1f  0003-kamdbctl-backslash.patch
35777009ffeaffcec73beb25ffb28f1dcb2b192a16d0283e75671146e991accc  core-improve-to-header-check-guards.patch
8b742ff710ef67ff59ec07a260690ebcdda24fb6f0b7b64dc50433a1bacf99f2  kamailio.cfg
ba928fa914feea2b95b8c659832e3fbea25eb6ac1ce56e4c23ff58c09f1ec3b8  kamailio.initd"
sha512sums="73b28c0c8bfa8998091c6a40d74c5be057e1d8ad9838ac073bd8769fbf93448daf695040b49c432b87a38725a6debb3bd89a1080554e1f88e6fe8e305b535a87  kamailio-4.3.5_src.tar.gz
32c8e723ee858b24a3bd1313537e9348bdd895e709041d52199b7d2c4054565f3f8d203458b5a7bd5f4b09a782a972cf87f931de5bb8199e6f9786a3c9bfb3ba  0001-musl-fixes.patch
782e70cd6c17f37ca613b05c86a2ddca71b1f0d58361345ddecede2743de65095f058916e049db98e4033b937bcb7a94df77f4b5e1a78e1346d07c8d22dd51d5  0002-mohqueue-v0-12.patch
d96600f1047eac65c0eba34030baa26ee6ee953434ae5808b203cba979fbed616289d40fc588939222371d832f54cbda0a5e8ba9baa16913363e204490758167  0003-kamdbctl-backslash.patch
4c199996bf848b2efdc6552bc48d576dd8c0f3cd0b8499f4f2e8a8695a1e7348c58828651ee971751876e97b06b358147ad0a807158d1c6af7e42770e2360a65  core-improve-to-header-check-guards.patch
c1abf69b48847dc8c7ab0d11ef9adb531aa4635f9d44db6933981edc5a47df374664fb24867b19aa64abbcc9777bf1cd0360d9aea54e27b081065928c61e0f0b  kamailio.cfg
cd6e3b677d803cd78561ad14d9b2589fd35ad0096f48047fdcb4ddc7d9103871357efba3b350946844cb53dbb081210746421fc420c22ac845b90251168a628e  kamailio.initd"