Subject: [alpine-aports] [PATCH] main/kamailio: upgrade 5.1.2

From: Nathan Angelacos <[email-masked]>
Date: Sun, 8 Apr 2018 17:26:22 -0400

Use slightly modified upstream(?!) APKBUILD
---
 .../0002-remove-spurious-execinfo.patch       |  30 -----
 .../0003-src_modules_tls_tls_init_c.patch     | 111 ----------------
 main/kamailio/APKBUILD                        | 120 +++++++++++-------
 3 files changed, 71 insertions(+), 190 deletions(-)
 delete mode 100644 main/kamailio/0002-remove-spurious-execinfo.patch
 delete mode 100644 main/kamailio/0003-src_modules_tls_tls_init_c.patch

diff --git a/main/kamailio/0002-remove-spurious-execinfo.patch b/main/kamailio/0002-remove-spurious-execinfo.patch
deleted file mode 100644
index d9403bb4c4..0000000000
--- a/main/kamailio/0002-remove-spurious-execinfo.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-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/main/kamailio/0003-src_modules_tls_tls_init_c.patch b/main/kamailio/0003-src_modules_tls_tls_init_c.patch
deleted file mode 100644
index 485b01a6bb..0000000000
--- a/main/kamailio/0003-src_modules_tls_tls_init_c.patch
+++ /dev/null
@@ -1,111 +0,0 @@
-$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_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/main/kamailio/APKBUILD b/main/kamailio/APKBUILD
index 4ff0b2899c..bcf4e7c397 100644
--- a/main/kamailio/APKBUILD
+++ b/main/kamailio/APKBUILD
@@ -2,19 +2,19 @@
 # Contributor: Michael Mason <[email-masked]>
 # Contributor: Leonardo Arena <[email-masked]>
 # Maintainer: Nathan Angelacos <[email-masked]>
+
 pkgname=kamailio
+pkgver=5.1.2
+pkgrel=0
 
 # 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
-
+#_gitcommit=991fe9b28e0e201309048f3b38a135037e40357a
 
-pkgver=5.0.6
-pkgrel=1
-[ -z "${_gitcommit}" ] && _suffix="_src" || _suffix="-${_gitcommit}"
+[ ! -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/"
@@ -22,9 +22,9 @@ arch="all"
 pkgusers="kamailio"
 pkggroups="kamailio"
 arch="all"
-license="GPL-2.0-or-later"
-depends=""
-makedepends="bison flex expat-dev postgresql-dev pcre-dev mariadb-connector-c-dev
+license="GPL2+"
+depends="gawk"
+makedepends="bison db-dev flex freeradius-client-dev expat-dev lksctp-tools-dev perl-dev postgresql-dev python2-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
@@ -58,7 +58,7 @@ _mod_list_extras="auth_diameter call_control cnxcc dmq domainpolicy log_custom \
 		auth_xkeys"
 
 # - common modules depending on database
-_mod_list_db="acc alias_db auth_db avpops cfg_db db_flatstore \
+_mod_list_db="acc alias_db auth_db avpops cfg_db db_berkeley 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 \
@@ -173,13 +173,13 @@ _mod_list_oracle="db_oracle"
 _mod_list_json="json jsonrpcc jsonrpcs"
 
 # - modules depending on redis library
-_mod_list_redis="ndb_redis"
+_mod_list_redis="ndb_redis topos_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 \
+_mod_list_ims="cdp cdp_avp ims_dialog ims_diameter_server ims_auth ims_isc ims_icscf ims_qos \
 		ims_registrar_pcscf ims_registrar_scscf ims_usrloc_pcscf \
 		ims_usrloc_scscf ims_charging"
 
@@ -213,6 +213,15 @@ _mod_list_jansson="jansson janssonrpcc"
 # - modules depending on libm
 _mod_list_jsdt="app_jsdt"
 
+# - modules depending on sqlang
+_mod_list_sqlang="app_sqlang"
+
+# - modules depending on rabbitmq
+_mod_list_rabbitmq="rabbitmq"
+
+# - modules depending on sipdump
+_mod_list_sipdump="sipdump"
+
 
 # Alpine Specific
 _mod_list_debugger="$_mod_list_devel benchmark debugger"
@@ -228,41 +237,30 @@ 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
+	uuid ev memcached redis geoip2 jansson sqlang sipdump \
+	jsdt http_async kazoo rabbitmq sctp radius perl python; 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
+source="${pkgname}-${pkgver}${_suffix}.tar.gz::https://github.com/kamailio/$pkgname/archive/$_gitcommit.tar.gz
 	0001-kamdbctl.base.patch
-	0002-remove-spurious-execinfo.patch
-	0003-src_modules_tls_tls_init_c.patch
 	0004-src_core_tcp_read_c.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
+        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
-        git archive --prefix=$pkgname-$pkgver/ -o "$SRCDEST"/${pkgname}-${pkgver}${_suffix}.tar.gz $_gittag
+        SHA512SUM=$(sha512sum "$SRCDEST"/${pkgname}-${pkgver}${_suffix}.tar.gz | sed -e "s:$SRCDEST/::")
+        sed -i -e "s/^\(sha512sums=.\).*/\1$SHA512SUM/" APKBUILD
 }
 
-
-
-_builddir="$srcdir"/$pkgname-$pkgver
 prepare() {
-	cd "$_builddir"
 	default_prepare
+	cd "$builddir"
 
 	cd utils/kamctl/
 	sed -i -e 's:/var/run/kamailio.pid:/var/run/kamailio/kamailio.pid:g' \
@@ -273,7 +271,7 @@ prepare() {
 }
 
 build() {
-	cd "$_builddir"
+	cd "$builddir"
 	make FLAVOUR=kamailio STUN=1 \
 		PREFIX=/usr \
 		CC_EXTRA_OPTS="$CFLAGS -D_GNU_SOURCE" \
@@ -284,20 +282,13 @@ build() {
 		DESTDIR="$pkgdir" \
 		cfg_prefix="$pkgdir" \
 		cfg
-	make EMBEDDED_UTF8_DECODE=1 STUN=1 \
+	make EMBEDDED_UTF8_DECODE=1 STUN=1 FREERADIUS=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
+	cd "$builddir"
+	make  FREERADIUS=1 -j1 install || return 1
 
 	install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
 	install -d -o kamailio "$pkgdir"/var/run/kamailio
@@ -382,7 +373,7 @@ snmpstats() {
 	_generic_pkg "SNMP statistics support" \
 		"$_mod_list_snmpstats" || return 1
 	mkdir -p "$subpkgdir"/usr/share/snmp
-	mv "$_builddir"/src/modules/snmpstats/mibs \
+	mv "$builddir"/src/modules/snmpstats/mibs \
 		"$subpkgdir"/usr/share/snmp/ || return 1
 }
 
@@ -507,11 +498,42 @@ kazoo() {
 		"$_mod_list_kazoo"
 }
 
+radius() {
+	_generic_pkg "RADIUS modules for Kamailio" \
+		"$_mod_list_radius"
+}
+
+sctp() {
+	_generic_pkg "SCTP transport for Kamailio" \
+		"$_mod_list_sctp"
+}
+
+perl() {
+	_generic_pkg "Perl extensions and database driver for Kamailio" \
+		"$_mod_list_perl"
+}
+
+python() {
+	_generic_pkg "Python extensions for Kamailio" \
+		"$_mod_list_python"
+}
+
+sqlang() {
+	_generic_pkg "Squirrel Language (SQLang) for Kamailio" \
+		"$_mod_list_sqlang"
+}
+
+rabbitmq() {
+	_generic_pkg "RabbitMQ related modules for Kamailio" \
+		"$_mod_list_rabbitmq"
+}
+
+sipdump() {
+	_generic_pkg "This module writes SIP traffic and some associated details into local files" \
+		"$_mod_list_sipdump"
+}
 
-sha512sums="fc37f9f0be7a809d910392201b8b6bc2a3a31ea6ead706c8bedd6d52152635834696918bcd154106ed235b4a0112ee79c458b65ef9d9a32254fec1f9cba2591f  kamailio-5.0.6_src.tar.gz
+sha512sums="3cf6f06a46227114be0bfcc39b6bc766a1951de04e914cd8436c91a08c2a7074774b93455e024fb11419abd3c042ea68670feacdc2d6f6470e03f8eff46b0d8e  kamailio-5.1.2.tar.gz
 6badfb611c02ffcb4c2e9937731162ea1a4b737f042ed52120e2f96ebb80b5b7d240b5612c9ca565e693eec9b8c52c1ee5db04dfc47d204501021f984b4b11db  0001-kamdbctl.base.patch
-e60e8d41e55008f0473e4d645af3b43f2bc097e341bb3bb81daec8bc47abcd6d037cbb56082675c24ffb1c50b2eb93e3c4fc50b0dc2df9cdfe4f28ad7b9fbf9e  0002-remove-spurious-execinfo.patch
-84b8645e551a41737863085dad6c2c865e60bbe505bfdf750dec530cdd0501025a69e60a48b54971f0d0daaf5f52d1cc0aa8d275395f5c110a3563bb269bb6df  0003-src_modules_tls_tls_init_c.patch
 af8362201957eae6b66baf7368c9ca884024209a396d77c5c52180c9aabe13772e9c6513e59721d39503e5bb7a8c1030f5c10301ea9055bddafb7f01ee2f3076  0004-src_core_tcp_read_c.patch
-c1abf69b48847dc8c7ab0d11ef9adb531aa4635f9d44db6933981edc5a47df374664fb24867b19aa64abbcc9777bf1cd0360d9aea54e27b081065928c61e0f0b  kamailio.cfg
 cd6e3b677d803cd78561ad14d9b2589fd35ad0096f48047fdcb4ddc7d9103871357efba3b350946844cb53dbb081210746421fc420c22ac845b90251168a628e  kamailio.initd"
-- 
2.17.0

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---

---

From: Natanael Copa <[email-masked]>
Date: Fri, 20 Apr 2018 16:31:58 +0200

I rebased this and applied with this change (because we use SPDX
license identifiers nowdays):

diff --git a/main/kamailio/APKBUILD b/main/kamailio/APKBUILD
index c5e5efc370..bcf4e7c397 100644https://spdx.org/licenses/
--- a/main/kamailio/APKBUILD
+++ b/main/kamailio/APKBUILD
@@ -22,7 +22,7 @@ arch="all"
 pkgusers="kamailio"
 pkggroups="kamailio"
 arch="all"
-license="GPL-2.0-or-later"
+license="GPL2+"
 depends="gawk"
 makedepends="bison db-dev flex freeradius-client-dev expat-dev lksctp-tools-dev perl-dev postgresql-dev python2-dev pcre-dev mariadb-dev
        libxml2-dev curl-dev unixodbc-dev confuse-dev ncurses-dev
        sqlite-dev

Thanks!

On Sun,  8 Apr 2018 17:26:22 -0400

---