pkg/kamailio/alpine: Added packaging script for Alpine dist. 1240/head
authorSergey Safarov <s.safarov@gmail.com>
Wed, 20 Sep 2017 09:56:59 +0000 (05:56 -0400)
committerSergey Safarov <s.safarov@gmail.com>
Wed, 20 Sep 2017 11:05:35 +0000 (07:05 -0400)
pkg/kamailio/alpine/0001-kamdbctl.base.patch [new file with mode: 0644]
pkg/kamailio/alpine/0002-remove-spurious-execinfo.patch [new file with mode: 0644]
pkg/kamailio/alpine/0003-src_modules_tls_tls_init_c.patch [new file with mode: 0644]
pkg/kamailio/alpine/0004-src_core_tcp_read_c.patch [new file with mode: 0644]
pkg/kamailio/alpine/APKBUILD [new file with mode: 0644]
pkg/kamailio/alpine/kamailio.cfg [new file with mode: 0644]
pkg/kamailio/alpine/kamailio.initd [new file with mode: 0644]
pkg/kamailio/alpine/kamailio.pre-install [new file with mode: 0644]
pkg/kamailio/alpine/kamailio.pre-upgrade [new symlink]
pkg/kamailio/alpine/kamctl_build.patch [new file with mode: 0644]

diff --git a/pkg/kamailio/alpine/0001-kamdbctl.base.patch b/pkg/kamailio/alpine/0001-kamdbctl.base.patch
new file mode 100644 (file)
index 0000000..0ce4bb3
--- /dev/null
@@ -0,0 +1,57 @@
+--- a/utils/kamctl/kamdbctl.base
++++ b/utils/kamctl/kamdbctl.base
+@@ -33,20 +33,20 @@
+ # Used by dbtext and db_berkeley to define tables to be created, used by
+ # postgres to do the grants
+-STANDARD_TABLES=${STANDARD_TABLES:-version acc dbaliases domain domain_attrs
++STANDARD_TABLES=${STANDARD_TABLES:-'version acc dbaliases domain domain_attrs
+               grp uri speed_dial lcr_gw lcr_rule lcr_rule_target pdt subscriber
+               location location_attrs re_grp trusted address missed_calls
+               usr_preferences aliases silo dialog dialog_vars dispatcher dialplan
+-              acc_cdrs topos_d topos_t}
+-EXTRA_TABLES=${EXTRA_TABLES:-imc_members imc_rooms cpl sip_trace domainpolicy
++              acc_cdrs topos_d topos_t'}
++EXTRA_TABLES=${EXTRA_TABLES:-'imc_members imc_rooms cpl sip_trace domainpolicy
+               carrierroute carrier_name domain_name carrierfailureroute userblacklist
+               globalblacklist htable purplemap uacreg pl_pipes mtree mtrees
+               sca_subscriptions mohqcalls mohqueues rtpproxy rtpengine
+-              dr_gateways dr_rules dr_gw_lists dr_groups}
+-PRESENCE_TABLES=${PRESENCE_TABLES:-presentity active_watchers watchers xcap
+-              pua rls_presentity rls_watchers}
+-DBUID_TABLES=${UID_TABLES:-uid_credentials uid_domain uid_domain_attrs
+-              uid_global_attrs uid_uri uid_uri_attrs uid_user_attrs}
++              dr_gateways dr_rules dr_gw_lists dr_groups'}
++PRESENCE_TABLES=${PRESENCE_TABLES:-'presentity active_watchers watchers xcap
++              pua rls_presentity rls_watchers'}
++DBUID_TABLES=${UID_TABLES:-'uid_credentials uid_domain uid_domain_attrs
++              uid_global_attrs uid_uri uid_uri_attrs uid_user_attrs'}
+ # SQL definitions
+ # If you change this definitions here, then you must change them
+@@ -69,18 +69,18 @@
+ SED=${SED:-sed}
+ # define what modules should be installed
+-STANDARD_MODULES=${STANDARD_MODULES:-standard acc lcr domain group
++STANDARD_MODULES=${STANDARD_MODULES:-'standard acc lcr domain group
+               permissions registrar usrloc msilo alias_db uri_db speeddial
+-              avpops auth_db pdt dialog dispatcher dialplan topos}
++              avpops auth_db pdt dialog dispatcher dialplan topos'}
+-PRESENCE_MODULES=${PRESENCE_MODULES:-presence rls}
++PRESENCE_MODULES=${PRESENCE_MODULES:-'presence rls'}
+-EXTRA_MODULES=${EXTRA_MODULES:-imc cpl siptrace domainpolicy carrierroute
++EXTRA_MODULES=${EXTRA_MODULES:-'imc cpl siptrace domainpolicy carrierroute
+               drouting userblacklist htable purple uac pipelimit mtree sca mohqueue
+-              rtpproxy rtpengine}
++              rtpproxy rtpengine'}
+-DBUID_MODULES=${UID_MODULES:-uid_auth_db uid_avp_db uid_domain uid_gflags
+-              uid_uri_db}
++DBUID_MODULES=${UID_MODULES:-'uid_auth_db uid_avp_db uid_domain uid_gflags
++              uid_uri_db'}
+ ############################################################
diff --git a/pkg/kamailio/alpine/0002-remove-spurious-execinfo.patch b/pkg/kamailio/alpine/0002-remove-spurious-execinfo.patch
new file mode 100644 (file)
index 0000000..d9403bb
--- /dev/null
@@ -0,0 +1,30 @@
+diff --git a/src/modules/ims_dialog/dlg_hash.c b/src/modules/ims_dialog/dlg_hash.c
+index 999ae01..4fe4aae 100644
+--- a/src/modules/ims_dialog/dlg_hash.c
++++ b/src/modules/ims_dialog/dlg_hash.c
+@@ -17,7 +17,8 @@
+ #include "dlg_profile.h"
+ #include "dlg_handlers.h"
+ #include "dlg_db_handler.h"
+-#include <execinfo.h>
++
++// #include <execinfo.h>
+ #define MAX_LDG_LOCKS  2048
+ #define MIN_LDG_LOCKS  2
+@@ -70,6 +71,7 @@ static int dlg_hash_size_out = 4096;
+               }\
+       }while(0)
++#ifdef ALPINE_SUPPORTS_BACKTRACE
+ inline static int backtrace2str(char* buf, int size)
+ {
+         void* bt[32];
+@@ -87,6 +89,7 @@ inline static int backtrace2str(char* buf, int size)
+         }
+         return 0;
+ }
++#endif
+ /*!
+  * \brief Initialize the global dialog table
diff --git a/pkg/kamailio/alpine/0003-src_modules_tls_tls_init_c.patch b/pkg/kamailio/alpine/0003-src_modules_tls_tls_init_c.patch
new file mode 100644 (file)
index 0000000..9b70c21
--- /dev/null
@@ -0,0 +1,131 @@
+$OpenBSD: patch-src_modules_tls_tls_init_c,v 1.1 2017/07/03 22:14:20 sthen Exp $
+
+Index: a/src/modules/tls/tls_init.c
+--- a/src/modules/tls/tls_locking.c
++++ b/src/modules/tls/tls_locking.c
+@@ -33,7 +33,7 @@
+ static gen_lock_set_t* static_locks=0;
+ /* OpenSSL is thread-safe since 1.1.0 */
+-#if OPENSSL_VERSION_NUMBER < 0x10100000L
++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
+ /* "dynamic" locks */
+@@ -118,7 +118,7 @@
+       }
+ }
+-#endif /* openssl < 0x10100000L (1.1.0) */
++#endif /* openssl < 0x10100000L (1.1.0) or LibreSSL */
+ void tls_destroy_locks()
+--- a/src/modules/tls/tls_init.c
++++ b/src/modules/tls/tls_init.c
+@@ -139,7 +139,7 @@ const SSL_METHOD* ssl_methods[TLS_METHOD_MAX];
+ */
+-
++#ifndef LIBRESSL_VERSION_NUMBER
+ inline static char* buf_append(char* buf, char* end, char* str, int str_len)
+ {
+       if ( (buf+str_len)<end){
+@@ -317,6 +317,7 @@ static void ser_free(void *ptr, const char *fname, int
+ }
+ #endif
++#endif /* LIBRESSL_VERSION_NUMBER */
+ /*
+  * Initialize TLS socket
+@@ -360,7 +361,7 @@ static void init_ssl_methods(void)
+       ssl_methods[TLS_USE_SSLv23 - 1] = SSLv23_method();
+       /* only specific SSL or TLS version */
+-#if OPENSSL_VERSION_NUMBER < 0x010100000L
++#if OPENSSL_VERSION_NUMBER < 0x010100000L || defined(LIBRESSL_VERSION_NUMBER)
+ #ifndef OPENSSL_NO_SSL2
+       ssl_methods[TLS_USE_SSLv2_cli - 1] = SSLv2_client_method();
+       ssl_methods[TLS_USE_SSLv2_srv - 1] = SSLv2_server_method();
+@@ -378,13 +379,13 @@ static void init_ssl_methods(void)
+       ssl_methods[TLS_USE_TLSv1_srv - 1] = TLSv1_server_method();
+       ssl_methods[TLS_USE_TLSv1 - 1] = TLSv1_method();
+-#if OPENSSL_VERSION_NUMBER >= 0x1000100fL
++#if OPENSSL_VERSION_NUMBER >= 0x1000100fL && !defined(LIBRESSL_VERSION_NUMBER)
+       ssl_methods[TLS_USE_TLSv1_1_cli - 1] = TLSv1_1_client_method();
+       ssl_methods[TLS_USE_TLSv1_1_srv - 1] = TLSv1_1_server_method();
+       ssl_methods[TLS_USE_TLSv1_1 - 1] = TLSv1_1_method();
+ #endif
+-#if OPENSSL_VERSION_NUMBER >= 0x1000105fL
++#if OPENSSL_VERSION_NUMBER >= 0x1000105fL && !defined(LIBRESSL_VERSION_NUMBER)
+       ssl_methods[TLS_USE_TLSv1_2_cli - 1] = TLSv1_2_client_method();
+       ssl_methods[TLS_USE_TLSv1_2_srv - 1] = TLSv1_2_server_method();
+       ssl_methods[TLS_USE_TLSv1_2 - 1] = TLSv1_2_method();
+@@ -393,11 +394,11 @@ static void init_ssl_methods(void)
+       /* ranges of TLS versions (require a minimum TLS version) */
+       ssl_methods[TLS_USE_TLSv1_PLUS - 1] = (void*)TLS_OP_TLSv1_PLUS;
+-#if OPENSSL_VERSION_NUMBER >= 0x1000100fL
++#if OPENSSL_VERSION_NUMBER >= 0x1000100fL && !defined(LIBRESSL_VERSION_NUMBER)
+       ssl_methods[TLS_USE_TLSv1_1_PLUS - 1] = (void*)TLS_OP_TLSv1_1_PLUS;
+ #endif
+-#if OPENSSL_VERSION_NUMBER >= 0x1000105fL
++#if OPENSSL_VERSION_NUMBER >= 0x1000105fL && !defined(LIBRESSL_VERSION_NUMBER)
+       ssl_methods[TLS_USE_TLSv1_2_PLUS - 1] = (void*)TLS_OP_TLSv1_2_PLUS;
+ #endif
+ }
+@@ -408,6 +409,7 @@ static void init_ssl_methods(void)
+  */
+ static int init_tls_compression(void)
+ {
++#ifndef LIBRESSL_VERSION_NUMBER
+ #if OPENSSL_VERSION_NUMBER < 0x010100000L
+ #if OPENSSL_VERSION_NUMBER >= 0x00908000L
+       int n, r;
+@@ -494,6 +496,7 @@ static int init_tls_compression(void)
+ end:
+ #endif /* OPENSSL_VERSION_NUMBER >= 0.9.8 */
+ #endif /* OPENSSL_VERSION_NUMBER < 1.1.0 */
++#endif /* LIBRESSL_VERSION_NUMBER */
+       return 0;
+ }
+@@ -504,6 +507,7 @@ end:
+  */
+ int tls_pre_init(void)
+ {
++#ifndef LIBRESSL_VERSION_NUMBER
+ #if OPENSSL_VERSION_NUMBER < 0x010100000L
+       void *(*mf)(size_t) = NULL;
+       void *(*rf)(void *, size_t) = NULL;
+@@ -530,6 +534,7 @@ int tls_pre_init(void)
+                               " (can be loaded first to be safe)\n");
+               return -1;
+       }
++#endif /* LIBRESSL_VERSION_NUMBER */
+       if (tls_init_locks()<0)
+               return -1;
+@@ -563,7 +568,7 @@ int init_tls_h(void)
+ {
+       /*struct socket_info* si;*/
+       long ssl_version;
+-#if OPENSSL_VERSION_NUMBER < 0x010100000L
++#if OPENSSL_VERSION_NUMBER < 0x010100000L && !defined(LIBRESSL_VERSION_NUMBER)
+       int lib_kerberos;
+       int lib_zlib;
+       int kerberos_support;
+@@ -607,7 +612,7 @@ int init_tls_h(void)
+       }
+       /* check kerberos support using compile flags only for version < 1.1.0 */
+-#if OPENSSL_VERSION_NUMBER < 0x010100000L
++#if OPENSSL_VERSION_NUMBER < 0x010100000L && !defined(LIBRESSL_VERSION_NUMBER)
+ #ifdef TLS_KERBEROS_SUPPORT
+       kerberos_support=1;
diff --git a/pkg/kamailio/alpine/0004-src_core_tcp_read_c.patch b/pkg/kamailio/alpine/0004-src_core_tcp_read_c.patch
new file mode 100644 (file)
index 0000000..08308f7
--- /dev/null
@@ -0,0 +1,20 @@
+$OpenBSD: patch-src_core_tcp_read_c,v 1.1 2017/07/03 22:14:20 sthen Exp $
+
+Index: a/src/core/tcp_read.c
+--- a/src/core/tcp_read.c.orig
++++ a/src/core/tcp_read.c
+@@ -1497,6 +1497,14 @@ void release_tcpconn(struct tcp_connection* c, long st
+                               ip_addr2a(&c->rcv.src_ip), c->rcv.src_port,
+                               ip_addr2a(&c->rcv.dst_ip), c->rcv.dst_port);
+               LM_DBG("extra_data %p\n", c->extra_data);
++
++              /* experimental fix tls crash with libressl */
++              /* add cleanup SSL structure in child process, in parent process SSL structure is empty */
++              if ((c->type==PROTO_TLS || c->type==PROTO_WSS) && (c->extra_data) && c->fd != -1) {
++                      tls_close(c, c->fd);
++                      tls_tcpconn_clean(c);
++              }
++
+               /* release req & signal the parent */
+               c->reader_pid=0; /* reset it */
+               if (c->fd!=-1){
diff --git a/pkg/kamailio/alpine/APKBUILD b/pkg/kamailio/alpine/APKBUILD
new file mode 100644 (file)
index 0000000..a687c8f
--- /dev/null
@@ -0,0 +1,506 @@
+# 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
+pkgver=5.1.0
+pkgrel=0
+
+# If building from a git snapshot, specify the gitcommit
+# If building a proper release, leave gitcommit blank
+#_gitcommit=65ed9b065c497266a4ecd9760e7c168c69b4c6e8
+
+[ ! -z "${_gitcommit}" ] && pkgver="${pkgver}.$(date +%Y%m%d)"
+[ ! -z "${_gitcommit}" ] && _suffix="-${_gitcommit:0:7}"
+[ ! -z "${_gitcommit}" ] && builddir="$srcdir/$pkgname-$_gitcommit" || builddir="$srcdir/$pkgname-$pkgver"
+[ -z "${_gitcommit}" ] && _gitcommit="${pkgver}"
+
+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 libressl-dev net-snmp-dev libuuid libev-dev
+       jansson-dev json-c-dev libevent-dev linux-headers libmemcached-dev
+       rabbitmq-c-dev hiredis-dev libmaxminddb-dev libunistring-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 cfgt cfgutils corex counters \
+               ctl debugger diversion enum exec gzcompress ipops kex mangler \
+               maxfwd mediaproxy mqueue \
+               nat_traversal nathelper path pike pv ratelimit rr rtimer \
+               rtpproxy sanity sdpops siputils sl smsops statsc statistics \
+               textops textopsx tm tmx topoh topos xlog rtpengine stun sipt"
+
+# - extra used modules, with no extra dependency
+_mod_list_extras="auth_diameter call_control cnxcc dmq domainpolicy log_custom \
+               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="cplc"
+
+# - modules depending on xml2 library
+_mod_list_xml="xhttp_pi xmlrpc xmlops"
+
+# - 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 http_client"
+
+# - async http_async_client
+_mod_list_http_async="http_async_client"
+
+# - 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 crypto 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_reginfo \
+                       pua_rpc 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 rabbitmq
+_mod_list_rabbitmq="rabbitmq"
+
+# - 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 jsonrpcc jsonrpcs"
+
+# - 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 ims_dialog 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 janssonrpcc"
+
+# - modules depending on libm
+_mod_list_jsdt="app_jsdt"
+
+
+# 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 \
+       jsdt http_async kazoo; do
+
+   subpackages="$subpackages $pkgname-$_i"
+   eval "_modules=\"\$_modules \$_mod_list_$_i\""
+done
+
+source="${pkgname}-${pkgver}${_suffix}.tar.gz::https://github.com/kamailio/$pkgname/archive/$_gitcommit.tar.gz
+       0001-kamdbctl.base.patch
+       0003-src_modules_tls_tls_init_c.patch
+       0004-src_core_tcp_read_c.patch
+       kamailio.cfg
+       kamailio.initd
+       "
+
+snapshot() {
+        if [ ! -f "$SRCDEST"/${pkgname}-${pkgver}${_suffix}.tar.gz ]; then
+            wget -O "$SRCDEST"/${pkgname}-${pkgver}${_suffix}.tar.gz https://github.com/kamailio/$pkgname/archive/$_gitcommit.tar.gz
+        fi
+        SHA512SUM=$(sha512sum "$SRCDEST"/${pkgname}-${pkgver}${_suffix}.tar.gz | sed -e "s:$SRCDEST/::")
+        sed -i -e "s/^\(sha512sums=.\).*/\1$SHA512SUM/" APKBUILD
+}
+
+prepare() {
+       default_prepare
+       cd "$builddir"
+
+       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
+}
+
+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 EMBEDDED_UTF8_DECODE=1 STUN=1 \
+               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" "$_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"/src/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"
+}
+
+rabbitmq() {
+       _generic_pkg "RabbitMQ client for configuration file" \
+               "$_mod_list_rabbitmq"
+}
+
+jsdt() {
+       _generic_pkg "Support for executing JavaScript" \
+               "$_mod_list_jsdt"
+}
+
+
+redis() {
+       _generic_pkg "Redis NoSQL support" \
+               "$_mod_list_redis"
+}
+
+http_async() {
+       _generic_pkg "Asynchronous HTTP queries support" \
+               "$_mod_list_http_async"
+}
+
+kazoo() {
+       _generic_pkg "Kazoo VoIP platform support" \
+               "$_mod_list_kazoo"
+}
+
+
+sha512sums="e31c99c4300c2db6d324ca4253161bd55d634ec854809e75c3058bdea91caea789ff4b7022bfc60c1c38212d359d960b00908c6e257ce3de379082bc430d7794  kamailio-5.1.0.20170920-65ed9b0.tar.gz
+6badfb611c02ffcb4c2e9937731162ea1a4b737f042ed52120e2f96ebb80b5b7d240b5612c9ca565e693eec9b8c52c1ee5db04dfc47d204501021f984b4b11db  0001-kamdbctl.base.patch
+384216758a9c95f019cbf9b548533ae88e2069a9f1f1730c51a36d1b8fe6b7c41ec51196eccaaaf8a70fcb74443a5cf94ee62cfe39772d7b4cda2aecce25e128  0003-src_modules_tls_tls_init_c.patch
+af8362201957eae6b66baf7368c9ca884024209a396d77c5c52180c9aabe13772e9c6513e59721d39503e5bb7a8c1030f5c10301ea9055bddafb7f01ee2f3076  0004-src_core_tcp_read_c.patch
+c1abf69b48847dc8c7ab0d11ef9adb531aa4635f9d44db6933981edc5a47df374664fb24867b19aa64abbcc9777bf1cd0360d9aea54e27b081065928c61e0f0b  kamailio.cfg
+cd6e3b677d803cd78561ad14d9b2589fd35ad0096f48047fdcb4ddc7d9103871357efba3b350946844cb53dbb081210746421fc420c22ac845b90251168a628e  kamailio.initd"
diff --git a/pkg/kamailio/alpine/kamailio.cfg b/pkg/kamailio/alpine/kamailio.cfg
new file mode 100644 (file)
index 0000000..a8ca999
--- /dev/null
@@ -0,0 +1,108 @@
+# Sample Kamailio Configuration 
+# 23 June 2010 - For Alpine Linux 
+# Accepts all registrations; routes calls to any registered AOR
+
+#--------------------------------------------------------
+# Section 1:  Global Definitions
+#--------------------------------------------------------
+debug          =       2
+fork           =       yes
+log_stderror   =       no
+# listen               =       0.0.0.0
+port           =       5060
+children       =       4
+
+dns            =       no
+rev_dns                =       no
+
+mpath          =       "/usr/lib/kamailio/modules_k/:/usr/lib/kamailio/modules/"
+
+#--------------------------------------------------------
+# Section 2:  Modules
+#--------------------------------------------------------
+
+loadmodule     "tm.so"         
+loadmodule     "sl.so"
+loadmodule     "tmx.so"                
+loadmodule     "rr.so"
+loadmodule     "maxfwd.so"
+loadmodule     "usrloc.so"
+loadmodule     "registrar.so"
+loadmodule     "mi_fifo.so"
+loadmodule     "pv.so"
+loadmodule     "xlog.so"
+
+#--------------------------------------------------------
+# Section 3:  Module Configuration
+#--------------------------------------------------------
+
+modparam ( "usrloc", "db_mode", 0 )
+modparam ( "rr", "enable_full_lr", 1 )
+modparam ( "mi_fifo", "fifo_name", "/var/run/kamailio/kamailio_fifo")
+
+
+#--------------------------------------------------------
+# Section 4:  Main Route Block
+#--------------------------------------------------------
+
+route 
+  {    
+       # Uncomment next line if you  want to see
+       # each incoming message
+       xlog( "L_INFO", "$rm: $fu -> $ru" );
+       
+       if (!mf_process_maxfwd_header("10")) 
+               {       
+               sl_send_reply("483", "Too Many Hops");
+               return;
+               }
+       if (msg:len > 4096)
+               {
+               sl_send_reply("513", "Message too big" );
+               return;
+               }
+       
+       if (method == "REGISTER" )
+               {
+               route(REGISTER);
+               return;
+               }
+
+       loose_route();
+       
+       if (!lookup("location")) {
+               sl_send_reply("404", "User Not Found");
+               return;
+               }
+               
+       route(RELAY);
+               
+}
+#--------------------------------------------------------
+# Section 5:  Secondary Route Blocks
+#--------------------------------------------------------
+
+# - Default message handler
+route[RELAY] {
+       if (!t_relay()) {
+               sl_reply_error();
+               }
+}
+
+#- Registration Request
+route[REGISTER] {
+       if (!save("location")) {
+               sl_reply_error();
+       }
+}
+
+#--------------------------------------------------------
+# Section 6:  Reply Route Block
+#--------------------------------------------------------
+
+
+#--------------------------------------------------------
+# Section 7:  Failure Route Block
+#--------------------------------------------------------
+
diff --git a/pkg/kamailio/alpine/kamailio.initd b/pkg/kamailio/alpine/kamailio.initd
new file mode 100644 (file)
index 0000000..67131dd
--- /dev/null
@@ -0,0 +1,35 @@
+#!/sbin/openrc-run
+
+daemon=/usr/sbin/kamailio
+pidfile=/var/run/kamailio/kamailio.pid
+
+extra_started_commands="reload"
+
+depend() {
+       need net
+       after firewall
+}
+
+start() {
+       ebegin "Starting Kamailio"
+       checkpath -d -o kamailio:kamailio /var/run/kamailio
+       start-stop-daemon --start --quiet --pidfile $pidfile --exec $daemon \
+               -- \
+               -u ${KAMAILIO_USER:-kamailio} \
+               -g ${KAMAILIO_GROUP:-kamailio} \
+               -P $pidfile \
+               ${KAMAILIO_OPTS:-}
+       eend $?
+}
+
+stop() {
+       ebegin "Stopping Kamailio"
+       start-stop-daemon --stop --quiet --pidfile $pidfile
+       eend $?
+}
+
+reload() {
+       ebegin "Reloading Kamailio"
+       echo mi_dg dp_reload | kamcmd 2>/dev/null
+       eend $?
+}
diff --git a/pkg/kamailio/alpine/kamailio.pre-install b/pkg/kamailio/alpine/kamailio.pre-install
new file mode 100644 (file)
index 0000000..1e63e58
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+addgroup -S kamailio 2>/dev/null
+adduser -S -D -H -h /var/empty -s /sbin/nologin -G kamailio -g kamailio kamailio 2>/dev/null
+
+exit 0
diff --git a/pkg/kamailio/alpine/kamailio.pre-upgrade b/pkg/kamailio/alpine/kamailio.pre-upgrade
new file mode 120000 (symlink)
index 0000000..d7cdaa8
--- /dev/null
@@ -0,0 +1 @@
+kamailio.pre-install
\ No newline at end of file
diff --git a/pkg/kamailio/alpine/kamctl_build.patch b/pkg/kamailio/alpine/kamctl_build.patch
new file mode 100644 (file)
index 0000000..3342ec3
--- /dev/null
@@ -0,0 +1,236 @@
+--- a/utils/kamctl/Makefile
++++ b/utils/kamctl/Makefile
+@@ -25,63 +25,63 @@
+               cat kamctl | \
+               sed -e "s#/usr/local/sbin#$(bin_target)#g" | \
+               sed -e "s#/usr/local/lib/kamailio#$(lib_target)#g" | \
+-              sed -e "s#/usr/local/etc/kamailio#$(cfg_target)#g"  >/tmp/kamctl
++              sed -e "s#/usr/local/etc/kamailio#$(cfg_target)#g"  >$(basedir)/kamctl
+               $(INSTALL_TOUCH) $(bin_prefix)/$(bin_dir)/kamctl
+-              $(INSTALL_BIN) /tmp/kamctl $(bin_prefix)/$(bin_dir)
+-              rm -fr /tmp/kamctl
++              $(INSTALL_BIN) $(basedir)/kamctl $(bin_prefix)/$(bin_dir)
++              rm -fr $(basedir)/kamctl
+               sed -e "s#/usr/local/sbin#$(bin_target)#g" \
+-                      < kamctl.base > /tmp/kamctl.base
++                      < kamctl.base > $(basedir)/kamctl.base
+               mkdir -p $(modules_prefix)/$(lib_dir)/kamctl 
+               $(INSTALL_TOUCH) \
+                       $(modules_prefix)/$(lib_dir)/kamctl
+-              $(INSTALL_CFG) /tmp/kamctl.base \
++              $(INSTALL_CFG) $(basedir)/kamctl.base \
+                       $(modules_prefix)/$(lib_dir)/kamctl/kamctl.base
+-              rm -fr /tmp/kamctl.base
++              rm -fr $(basedir)/kamctl.base
+               sed -e "s#/usr/local#$(bin_target)#g" \
+-                      < kamctl.ctlbase > /tmp/kamctl.ctlbase
+-              $(INSTALL_CFG) /tmp/kamctl.ctlbase \
++                      < kamctl.ctlbase > $(basedir)/kamctl.ctlbase
++              $(INSTALL_CFG) $(basedir)/kamctl.ctlbase \
+                       $(modules_prefix)/$(lib_dir)/kamctl/kamctl.ctlbase
+-              rm -fr /tmp/kamctl.ctlbase
++              rm -fr $(basedir)/kamctl.ctlbase
+               sed -e "s#/usr/local#$(bin_target)#g" \
+-                      < kamctl.fifo > /tmp/kamctl.fifo
+-              $(INSTALL_CFG) /tmp/kamctl.fifo \
++                      < kamctl.fifo > $(basedir)/kamctl.fifo
++              $(INSTALL_CFG) $(basedir)/kamctl.fifo \
+                       $(modules_prefix)/$(lib_dir)/kamctl/kamctl.fifo
+-              rm -fr /tmp/kamctl.fifo
++              rm -fr $(basedir)/kamctl.fifo
+               sed -e "s#/usr/local#$(bin_target)#g" \
+-                      < kamctl.ser > /tmp/kamctl.ser
+-              $(INSTALL_CFG) /tmp/kamctl.ser \
++                      < kamctl.ser > $(basedir)/kamctl.ser
++              $(INSTALL_CFG) $(basedir)/kamctl.ser \
+                       $(modules_prefix)/$(lib_dir)/kamctl/kamctl.ser
+-              rm -fr /tmp/kamctl.ser
++              rm -fr $(basedir)/kamctl.ser
+               sed -e "s#/usr/local#$(bin_target)#g" \
+-                      < kamctl.ser_mi > /tmp/kamctl.ser_mi
+-              $(INSTALL_CFG) /tmp/kamctl.ser_mi \
++                      < kamctl.ser_mi > $(basedir)/kamctl.ser_mi
++              $(INSTALL_CFG) $(basedir)/kamctl.ser_mi \
+                       $(modules_prefix)/$(lib_dir)/kamctl/kamctl.ser_mi
+-              rm -fr /tmp/kamctl.ser_mi
++              rm -fr $(basedir)/kamctl.ser_mi
+               sed -e "s#/usr/local#$(bin_target)#g" \
+-                      < kamctl.unixsock > /tmp/kamctl.unixsock
+-              $(INSTALL_CFG) /tmp/kamctl.unixsock \
++                      < kamctl.unixsock > $(basedir)/kamctl.unixsock
++              $(INSTALL_CFG) $(basedir)/kamctl.unixsock \
+                       $(modules_prefix)/$(lib_dir)/kamctl/kamctl.unixsock
+-              rm -fr /tmp/kamctl.unixsock
++              rm -fr $(basedir)/kamctl.unixsock
+               sed -e "s#/usr/local#$(bin_target)#g" \
+-                      < kamctl.sqlbase > /tmp/kamctl.sqlbase
+-              $(INSTALL_CFG) /tmp/kamctl.sqlbase \
++                      < kamctl.sqlbase > $(basedir)/kamctl.sqlbase
++              $(INSTALL_CFG) $(basedir)/kamctl.sqlbase \
+                       $(modules_prefix)/$(lib_dir)/kamctl/kamctl.sqlbase
+-              rm -fr /tmp/kamctl.sqlbase
++              rm -fr $(basedir)/kamctl.sqlbase
+               # install db setup base script
+               sed -e "s#/usr/local/sbin#$(bin_target)#g" \
+                       -e "s#/usr/local/etc/kamailio#$(cfg_target)#g" \
+                       -e "s#/usr/local/share/kamailio#$(data_target)#g" \
+-                      < kamdbctl.base > /tmp/kamdbctl.base
+-              $(INSTALL_CFG) /tmp/kamdbctl.base \
++                      < kamdbctl.base > $(basedir)/kamdbctl.base
++              $(INSTALL_CFG) $(basedir)/kamdbctl.base \
+                       $(modules_prefix)/$(lib_dir)/kamctl/kamdbctl.base
+-              rm -fr /tmp/kamdbctl.base
++              rm -fr $(basedir)/kamdbctl.base
+               cat kamdbctl | \
+               sed -e "s#/usr/local/sbin#$(bin_target)#g" | \
+               sed -e "s#/usr/local/lib/kamailio#$(lib_target)#g" | \
+-              sed -e "s#/usr/local/etc/kamailio#$(cfg_target)#g"  >/tmp/kamdbctl
++              sed -e "s#/usr/local/etc/kamailio#$(cfg_target)#g"  >$(basedir)/kamdbctl
+               $(INSTALL_TOUCH) $(bin_prefix)/$(bin_dir)/kamdbctl
+-              $(INSTALL_BIN) /tmp/kamdbctl $(bin_prefix)/$(bin_dir)
+-              rm -fr /tmp/kamdbctl
++              $(INSTALL_BIN) $(basedir)/kamdbctl $(bin_prefix)/$(bin_dir)
++              rm -fr $(basedir)/kamdbctl
+ install-man: $(man_prefix)/$(man_dir)/man8 $(man_prefix)/$(man_dir)/man5
+               sed -e "s#/etc/$(NAME)/$(NAME)\.cfg#$(cfg_target)$(NAME).cfg#g" \
+@@ -105,15 +105,15 @@
+               if [ "$(MYSQLON)" = "yes" ]; then \
+                       mkdir -p $(modules_prefix)/$(lib_dir)/kamctl ; \
+                       sed -e "s#/usr/local/sbin#$(bin_target)#g" \
+-                              < kamctl.mysql > /tmp/kamctl.mysql ; \
+-                      $(INSTALL_CFG) /tmp/kamctl.mysql \
++                              < kamctl.mysql > $(basedir)/kamctl.mysql ; \
++                      $(INSTALL_CFG) $(basedir)/kamctl.mysql \
+                               $(modules_prefix)/$(lib_dir)/kamctl/kamctl.mysql ; \
+-                      rm -fr /tmp/kamctl.mysql ; \
++                      rm -fr $(basedir)/kamctl.mysql ; \
+                       sed -e "s#/usr/local/share/kamailio#$(data_target)#g" \
+-                      < kamdbctl.mysql > /tmp/kamdbctl.mysql ; \
++                      < kamdbctl.mysql > $(basedir)/kamdbctl.mysql ; \
+                       $(INSTALL_TOUCH) $(modules_prefix)/$(lib_dir)/kamctl/kamdbctl.mysql ; \
+-                      $(INSTALL_CFG) /tmp/kamdbctl.mysql $(modules_prefix)/$(lib_dir)/kamctl/ ; \
+-                      rm -fr /tmp/kamdbctl.mysql ; \
++                      $(INSTALL_CFG) $(basedir)/kamdbctl.mysql $(modules_prefix)/$(lib_dir)/kamctl/ ; \
++                      rm -fr $(basedir)/kamdbctl.mysql ; \
+                       mkdir -p $(data_prefix)/$(data_dir)/mysql ; \
+                       for FILE in $(wildcard mysql/*) ; do \
+                               if [ -f $$FILE ] ; then \
+@@ -128,15 +128,15 @@
+               if [ "$(PGSQLON)" = "yes" ]; then \
+                       mkdir -p $(modules_prefix)/$(lib_dir)/kamctl ; \
+                       sed -e "s#/usr/local/sbin#$(bin_target)#g" \
+-                              < kamctl.pgsql > /tmp/kamctl.pgsql ; \
+-                      $(INSTALL_CFG) /tmp/kamctl.pgsql \
++                              < kamctl.pgsql > $(basedir)/kamctl.pgsql ; \
++                      $(INSTALL_CFG) $(basedir)/kamctl.pgsql \
+                               $(modules_prefix)/$(lib_dir)/kamctl/kamctl.pgsql ; \
+-                      rm -fr /tmp/kamctl.pgsql ; \
++                      rm -fr $(basedir)/kamctl.pgsql ; \
+                       sed -e "s#/usr/local/share/kamailio#$(data_target)#g" \
+-                              < kamdbctl.pgsql > /tmp/kamdbctl.pgsql ; \
++                              < kamdbctl.pgsql > $(basedir)/kamdbctl.pgsql ; \
+                       $(INSTALL_TOUCH) $(modules_prefix)/$(lib_dir)/kamctl/kamdbctl.pgsql ; \
+-                      $(INSTALL_CFG) /tmp/kamdbctl.pgsql $(modules_prefix)/$(lib_dir)/kamctl/ ; \
+-                      rm -fr /tmp/kamdbctl.pgsql ; \
++                      $(INSTALL_CFG) $(basedir)/kamdbctl.pgsql $(modules_prefix)/$(lib_dir)/kamctl/ ; \
++                      rm -fr $(basedir)/kamdbctl.pgsql ; \
+                       mkdir -p $(data_prefix)/$(data_dir)/postgres ; \
+                       for FILE in $(wildcard postgres/*) ; do \
+                               if [ -f $$FILE ] ; then \
+@@ -151,20 +151,20 @@
+               if [ "$(ORACLEON)" = "yes" ]; then \
+                       mkdir -p $(modules_prefix)/$(lib_dir)/kamctl ; \
+                       sed -e "s#/usr/local/sbin#$(bin_target)#g" \
+-                              < kamctl.oracle > /tmp/kamctl.oracle ; \
+-                      $(INSTALL_CFG) /tmp/kamctl.oracle \
++                              < kamctl.oracle > $(basedir)/kamctl.oracle ; \
++                      $(INSTALL_CFG) $(basedir)/kamctl.oracle \
+                               $(modules_prefix)/$(lib_dir)/kamctl/kamctl.oracle ; \
+-                      rm -fr /tmp/kamctl.oracle ; \
++                      rm -fr $(basedir)/kamctl.oracle ; \
+                       sed -e "s#/usr/local/share/kamailio#$(data_target)#g" \
+-                      < kamdbctl.oracle > /tmp/kamdbctl.oracle ; \
++                      < kamdbctl.oracle > $(basedir)/kamdbctl.oracle ; \
+                       $(INSTALL_TOUCH) $(modules_prefix)/$(lib_dir)/kamctl/kamdbctl.oracle ; \
+-                      $(INSTALL_CFG) /tmp/kamdbctl.oracle $(modules_prefix)/$(lib_dir)/kamctl/ ; \
+-                      rm -fr /tmp/kamdbctl.oracle ; \
++                      $(INSTALL_CFG) $(basedir)/kamdbctl.oracle $(modules_prefix)/$(lib_dir)/kamctl/ ; \
++                      rm -fr $(basedir)/kamdbctl.oracle ; \
+                       sed -e "s#/usr/local/share/kamailio#$(data_target)#g" \
+-                      < kamdbfunc.oracle > /tmp/kamdbfunc.oracle ; \
++                      < kamdbfunc.oracle > $(basedir)/kamdbfunc.oracle ; \
+                       $(INSTALL_TOUCH) $(modules_prefix)/$(lib_dir)/kamctl/kamdbfunc.oracle ; \
+-                      $(INSTALL_CFG) /tmp/kamdbfunc.oracle $(modules_prefix)/$(lib_dir)/kamctl/ ; \
+-                      rm -fr /tmp/kamdbfunc.oracle ; \
++                      $(INSTALL_CFG) $(basedir)/kamdbfunc.oracle $(modules_prefix)/$(lib_dir)/kamctl/ ; \
++                      rm -fr $(basedir)/kamdbfunc.oracle ; \
+                       mkdir -p $(data_prefix)/$(data_dir)/oracle ; \
+                       for FILE in $(wildcard oracle/*) ; do \
+                               if [ -f $$FILE ] ; then \
+@@ -199,15 +199,15 @@
+               if [ "$(BERKELEYDBON)" = "yes" ]; then \
+                       mkdir -p $(modules_prefix)/$(lib_dir)/kamctl ; \
+                       sed -e "s#/usr/local/share/kamailio/#$(data_target)#g" \
+-                              < kamctl.db_berkeley > /tmp/kamctl.db_berkeley ; \
+-                      $(INSTALL_CFG) /tmp/kamctl.db_berkeley \
++                              < kamctl.db_berkeley > $(basedir)/kamctl.db_berkeley ; \
++                      $(INSTALL_CFG) $(basedir)/kamctl.db_berkeley \
+                               $(modules_prefix)/$(lib_dir)/kamctl/kamctl.db_berkeley ; \
+-                      rm -fr /tmp/kamctl.db_berkeley ; \
++                      rm -fr $(basedir)/kamctl.db_berkeley ; \
+                       sed -e "s#/usr/local/share/kamailio#$(data_target)#g" \
+-                              < kamdbctl.db_berkeley > /tmp/kamdbctl.db_berkeley ; \
++                              < kamdbctl.db_berkeley > $(basedir)/kamdbctl.db_berkeley ; \
+                       $(INSTALL_TOUCH) $(modules_prefix)/$(lib_dir)/kamctl/kamdbctl.db_berkeley ; \
+-                      $(INSTALL_CFG) /tmp/kamdbctl.db_berkeley $(modules_prefix)/$(lib_dir)/kamctl/ ; \
+-                      rm -fr /tmp/kamdbctl.db_berkeley ; \
++                      $(INSTALL_CFG) $(basedir)/kamdbctl.db_berkeley $(modules_prefix)/$(lib_dir)/kamctl/ ; \
++                      rm -fr $(basedir)/kamdbctl.db_berkeley ; \
+                       mkdir -p $(data_prefix)/$(data_dir)/db_berkeley/kamailio ; \
+                       for FILE in $(wildcard db_berkeley/kamailio/*) ; do \
+                               if [ -f $$FILE ] ; then \
+@@ -224,15 +224,15 @@
+               if [ "$(DBTEXTON)" = "yes" ]; then \
+                       mkdir -p $(modules_prefix)/$(lib_dir)/kamctl ; \
+                       sed -e "s#/usr/local/share/kamailio/#$(data_target)#g" \
+-                              < kamctl.dbtext > /tmp/kamctl.dbtext ; \
+-                      $(INSTALL_CFG) /tmp/kamctl.dbtext \
++                              < kamctl.dbtext > $(basedir)/kamctl.dbtext ; \
++                      $(INSTALL_CFG) $(basedir)/kamctl.dbtext \
+                               $(modules_prefix)/$(lib_dir)/kamctl/kamctl.dbtext ; \
+-                      rm -fr /tmp/kamctl.dbtext ; \
++                      rm -fr $(basedir)/kamctl.dbtext ; \
+                       sed -e "s#/usr/local/share/kamailio#$(data_target)#g" \
+-                              < kamdbctl.dbtext > /tmp/kamdbctl.dbtext ; \
++                              < kamdbctl.dbtext > $(basedir)/kamdbctl.dbtext ; \
+                       $(INSTALL_TOUCH) $(modules_prefix)/$(lib_dir)/kamctl/kamdbctl.dbtext ; \
+-                      $(INSTALL_CFG) /tmp/kamdbctl.dbtext $(modules_prefix)/$(lib_dir)/kamctl/ ; \
+-                      rm -fr /tmp/kamdbctl.dbtext ; \
++                      $(INSTALL_CFG) $(basedir)/kamdbctl.dbtext $(modules_prefix)/$(lib_dir)/kamctl/ ; \
++                      rm -fr $(basedir)/kamdbctl.dbtext ; \
+                       mkdir -p $(modules_prefix)/$(lib_dir)/kamctl/dbtextdb ; \
+                       $(INSTALL_TOUCH) $(modules_prefix)/$(lib_dir)/kamctl/dbtextdb/dbtextdb.py ; \
+                       $(INSTALL_BIN) dbtextdb/dbtextdb.py $(modules_prefix)/$(lib_dir)/kamctl/dbtextdb/ ; \
+@@ -250,15 +250,15 @@
+               if [ "$(SQLITEON)" = "yes" ]; then \
+                       mkdir -p $(modules_prefix)/$(lib_dir)/kamctl ; \
+                       sed -e "s#/usr/local/sbin#$(bin_target)#g" \
+-                              < kamctl.sqlite > /tmp/kamctl.sqlite ; \
+-                      $(INSTALL_CFG) /tmp/kamctl.sqlite \
++                              < kamctl.sqlite > $(basedir)/kamctl.sqlite ; \
++                      $(INSTALL_CFG) $(basedir)/kamctl.sqlite \
+                               $(modules_prefix)/$(lib_dir)/kamctl/kamctl.sqlite ; \
+-                      rm -fr /tmp/kamctl.sqlite ; \
++                      rm -fr $(basedir)/kamctl.sqlite ; \
+                       sed -e "s#/usr/local/share/kamailio#$(data_target)#g" \
+-                              < kamdbctl.sqlite > /tmp/kamdbctl.sqlite ; \
++                              < kamdbctl.sqlite > $(basedir)/kamdbctl.sqlite ; \
+                       $(INSTALL_TOUCH) $(modules_prefix)/$(lib_dir)/kamctl/kamdbctl.sqlite ; \
+-                      $(INSTALL_CFG) /tmp/kamdbctl.sqlite $(modules_prefix)/$(lib_dir)/kamctl/ ; \
+-                      rm -fr /tmp/kamdbctl.sqlite ; \
++                      $(INSTALL_CFG) $(basedir)/kamdbctl.sqlite $(modules_prefix)/$(lib_dir)/kamctl/ ; \
++                      rm -fr $(basedir)/kamdbctl.sqlite ; \
+                       mkdir -p $(data_prefix)/$(data_dir)/db_sqlite ; \
+                       for FILE in $(wildcard db_sqlite/*) ; do \
+                               if [ -f $$FILE ] ; then \