aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2013-12-20 10:41:51 +0000
committerTimo Teräs <timo.teras@iki.fi>2013-12-20 10:43:28 +0000
commit6942ede454725ad4629687a1236ac4b10f551428 (patch)
tree8348e6f0a1f749675d037dbd9b947d9a83374c36 /main
parentbec5f848fc6da2049a160a918524b8987326b70f (diff)
downloadaports-6942ede454725ad4629687a1236ac4b10f551428.tar.bz2
aports-6942ede454725ad4629687a1236ac4b10f551428.tar.xz
main/kamailio: fix musl build
Diffstat (limited to 'main')
-rw-r--r--main/kamailio/0001-websocket-remove-libunistring-dependency.patch141
-rw-r--r--main/kamailio/APKBUILD13
-rw-r--r--main/kamailio/musl-fixes.patch65
3 files changed, 217 insertions, 2 deletions
diff --git a/main/kamailio/0001-websocket-remove-libunistring-dependency.patch b/main/kamailio/0001-websocket-remove-libunistring-dependency.patch
new file mode 100644
index 0000000000..9b84eba5e3
--- /dev/null
+++ b/main/kamailio/0001-websocket-remove-libunistring-dependency.patch
@@ -0,0 +1,141 @@
+From 7cf956836dc20a8f8354e25d018cb5c4eb386187 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi>
+Date: Fri, 20 Dec 2013 11:53:50 +0200
+Subject: [PATCH 1/1] websocket: remove libunistring dependency
+
+libunistring is old, slow, messy code and uncompilable on new systems.
+remove the sole user of it, and replace it with inline utf8 decoder
+implementation from http://bjoern.hoehrmann.de/utf-8/decoder/dfa/.
+
+improves performance and portability as libunistring is not needed.
+---
+ modules/websocket/Makefile | 2 +-
+ modules/websocket/README | 1 -
+ modules/websocket/doc/websocket_admin.xml | 3 --
+ modules/websocket/utf8_decode.h | 52 +++++++++++++++++++++++++++++++
+ modules/websocket/ws_frame.c | 4 +--
+ 5 files changed, 55 insertions(+), 7 deletions(-)
+ create mode 100644 modules/websocket/utf8_decode.h
+
+diff --git a/modules/websocket/Makefile b/modules/websocket/Makefile
+index bb7c809..c686a82 100644
+--- a/modules/websocket/Makefile
++++ b/modules/websocket/Makefile
+@@ -27,7 +27,7 @@ else
+ # E.g.: make TLS_HOOKS=1 TLS_EXTRA_LIBS="-lz -lkrb5"
+ endif
+
+-LIBS+= $(TLS_EXTRA_LIBS) -lunistring
++LIBS+= $(TLS_EXTRA_LIBS)
+
+ # Static linking, if you'd like to use TLS and WEBSOCKET at the same time
+ #
+diff --git a/modules/websocket/README b/modules/websocket/README
+index 49d8693..bdba3e4 100644
+--- a/modules/websocket/README
++++ b/modules/websocket/README
+@@ -316,7 +316,6 @@ onreply_route[WS_REPLY] {
+ The following libraries must be installed before running Kamailio with
+ this module loaded:
+ * OpenSSL.
+- * GNU libunistring.
+
+ 4. Parameters
+
+diff --git a/modules/websocket/doc/websocket_admin.xml b/modules/websocket/doc/websocket_admin.xml
+index fa7d300..e40dc09 100644
+--- a/modules/websocket/doc/websocket_admin.xml
++++ b/modules/websocket/doc/websocket_admin.xml
+@@ -262,9 +262,6 @@ onreply_route[WS_REPLY] {
+ <listitem>
+ <para><emphasis>OpenSSL</emphasis>.</para>
+ </listitem>
+- <listitem>
+- <para><emphasis>GNU libunistring</emphasis>.</para>
+- </listitem>
+ </itemizedlist>
+ </para>
+ </section>
+diff --git a/modules/websocket/utf8_decode.h b/modules/websocket/utf8_decode.h
+new file mode 100644
+index 0000000..b274fe7
+--- /dev/null
++++ b/modules/websocket/utf8_decode.h
+@@ -0,0 +1,52 @@
++#include <stdint.h>
++#include <stddef.h>
++
++// Copyright (c) 2008-2010 Bjoern Hoehrmann <bjoern@hoehrmann.de>
++// See http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ for details.
++
++#define UTF8_ACCEPT 0
++#define UTF8_REJECT 12
++
++static const uint8_t utf8d[] = {
++ // The first part of the table maps bytes to character classes that
++ // to reduce the size of the transition table and create bitmasks.
++ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
++ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
++ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
++ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
++ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
++ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
++ 8,8,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
++ 10,3,3,3,3,3,3,3,3,3,3,3,3,4,3,3, 11,6,6,6,5,8,8,8,8,8,8,8,8,8,8,8,
++
++ // The second part is a transition table that maps a combination
++ // of a state of the automaton and a character class to a state.
++ 0,12,24,36,60,96,84,12,12,12,48,72, 12,12,12,12,12,12,12,12,12,12,12,12,
++ 12, 0,12,12,12,12,12, 0,12, 0,12,12, 12,24,12,12,12,12,12,24,12,24,12,12,
++ 12,12,12,12,12,12,12,24,12,12,12,12, 12,24,12,12,12,12,12,12,12,24,12,12,
++ 12,12,12,12,12,12,12,36,12,36,12,12, 12,36,12,12,12,12,12,36,12,36,12,12,
++ 12,36,12,12,12,12,12,12,12,12,12,12,
++};
++
++static inline uint32_t decode(uint32_t* state, uint32_t* codep, uint32_t byte)
++{
++ uint32_t type = utf8d[byte];
++
++ *codep = (*state != UTF8_ACCEPT) ?
++ (byte & 0x3fu) | (*codep << 6) :
++ (0xff >> type) & (byte);
++
++ *state = utf8d[256 + *state + type];
++ return *state;
++}
++
++static inline int IsUTF8(uint8_t* s, size_t len)
++{
++ uint32_t codepoint, state = 0;
++
++ while (len--)
++ decode(&state, &codepoint, *s++);
++
++ return state == UTF8_ACCEPT;
++}
++
+diff --git a/modules/websocket/ws_frame.c b/modules/websocket/ws_frame.c
+index a3a4cef..3562437 100644
+--- a/modules/websocket/ws_frame.c
++++ b/modules/websocket/ws_frame.c
+@@ -22,7 +22,7 @@
+ */
+
+ #include <limits.h>
+-#include <unistr.h>
++#include "utf8_decode.h"
+ #include "../../events.h"
+ #include "../../receive.h"
+ #include "../../stats.h"
+@@ -695,7 +695,7 @@ int ws_frame_transmit(void *data)
+ frame.fin = 1;
+ /* Can't be sure whether this message is UTF-8 or not so check to see
+ if it "might" be UTF-8 and send as binary if it definitely isn't */
+- frame.opcode = (u8_check((uint8_t *) wsev->buf, wsev->len) == NULL) ?
++ frame.opcode = IsUTF8((uint8_t *) wsev->buf, wsev->len) ?
+ OPCODE_TEXT_FRAME : OPCODE_BINARY_FRAME;
+ frame.payload_len = wsev->len;
+ frame.payload_data = wsev->buf;
+--
+1.8.5.1
+
diff --git a/main/kamailio/APKBUILD b/main/kamailio/APKBUILD
index e08daddf7d..156d1b8a7b 100644
--- a/main/kamailio/APKBUILD
+++ b/main/kamailio/APKBUILD
@@ -2,7 +2,7 @@
# Maintainer: Nathan Angelacos <nangel@alpinelinux.org>
pkgname=kamailio
pkgver=4.0.4
-pkgrel=0
+pkgrel=1
pkgdesc="Open Source SIP Server"
url="http://www.kamailio.org/"
arch="all"
@@ -13,7 +13,7 @@ license="GPL2+"
depends=""
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 libunistring-dev"
+ lua-dev openldap-dev openssl-dev net-snmp-dev"
install="$pkgname.pre-install $pkgname.pre-upgrade"
# See sip-router/Makfile.groups for the list of recommended modules for
@@ -191,6 +191,8 @@ for _i in db postgres sqlite dbtext mysql \
done
source="http://www.kamailio.org/pub/kamailio/$pkgver/src/kamailio-${pkgver}_src.tar.gz
+ 0001-websocket-remove-libunistring-dependency.patch
+ musl-fixes.patch
kamailio-4.0-backslash.patch
kamailio.cfg
kamailio.initd
@@ -233,6 +235,7 @@ build() {
cd "$_builddir"
make FLAVOUR=kamailio STUN=1 \
PREFIX=/usr \
+ CC_EXTRA_OPTS="$CFLAGS -D_GNU_SOURCE" \
cfg_target=/etc/kamailio/ \
include_modules="$_modules" \
LIBDIR=lib \
@@ -400,14 +403,20 @@ websocket() {
}
md5sums="e625f52d53ed00da97a50b3ecd451b8d kamailio-4.0.4_src.tar.gz
+6251a5c33373c5276897c8abbbecc619 0001-websocket-remove-libunistring-dependency.patch
+2f26f821280bc65b77231ec3ba6e0472 musl-fixes.patch
7ca9394c4987c83a27f492c5b6b055f0 kamailio-4.0-backslash.patch
a3c959ec568c43a905710e7d25cd8c25 kamailio.cfg
9c190575e28772a784c4172216d85333 kamailio.initd"
sha256sums="abd6e8a1076d8e58d80a3bb6efc32d784b130796add03961f4bbdbd6f58049a7 kamailio-4.0.4_src.tar.gz
+bbc06f9ae62b2e8df2c58f9a171f0408e075d5a51e2457e85ef3ca01aa972df9 0001-websocket-remove-libunistring-dependency.patch
+46b92e27006c08cc3511d241d2958b720a8b5de650b7d51339b265b4b0a48474 musl-fixes.patch
2cb24070809718deac1a32fd4de73eaea47c685d9608fd06ae6531bd34fe4604 kamailio-4.0-backslash.patch
8024266849033a917147827c3579a382f10f3796989bebc6de3d7c80c965fb72 kamailio.cfg
82612cc107e51de6968568a266de25b98e57257926defab7261fd81cbd624e00 kamailio.initd"
sha512sums="5b486ca72094edef3f617a5285af5519614d3b470babf78db921cf3c321eccc2314e3bbf745e86929fb51249e25c1d55abd519f4559acbd6cfe5cf527485bb0f kamailio-4.0.4_src.tar.gz
+a972e57d8d64c104cb3df329442c746588818ed7f148a409d6050bcbbbb021cc1eeb970b59924e0ffb7f9487faacb99cada0dbfb19b0b87f66ca6b2bcf8b8345 0001-websocket-remove-libunistring-dependency.patch
+443b4b4cfcc6d4c55833185829cc43ed11b922169d9f24d8aecfaf3c59d65cb32a2806cdd2e846261767c7ad7cbca0517d52c7e0bf10e55cbe4b5fab2b62e4e8 musl-fixes.patch
f83ca7e4feaa02ba4c97fe8b3ff72857b334b6ba27f90b1cc4a2819c77bf40a1d6b77cc8d9b9afa045da5a1a4706b737b73f93c39c0cdb57c14088ca691afbf9 kamailio-4.0-backslash.patch
0b666bfa10fd0af97b62749f8691cb3f76d9b40d1abe0a33e810e367bd733d2e8189c89f7f23010ec591116aada6e1a8a403b17449fe775038917617f281ad4d kamailio.cfg
babec2a230daea3c579dc581f9a945c70bd1736cdacaaa7a183d902c8d9fbd4f7958cce03424fb65cdf7a1f6aa077ad8aec7e53525e270f88f856caa374505e7 kamailio.initd"
diff --git a/main/kamailio/musl-fixes.patch b/main/kamailio/musl-fixes.patch
new file mode 100644
index 0000000000..c224335b9a
--- /dev/null
+++ b/main/kamailio/musl-fixes.patch
@@ -0,0 +1,65 @@
+--- kamailio-4.0.4.orig/modules/ldap/ld_session.h
++++ kamailio-4.0.4/modules/ldap/ld_session.h
+@@ -33,6 +33,7 @@
+ #ifndef LD_SESSION_H
+ #define LD_SESSION_H
+
++#include <sys/time.h>
+ #include <ldap.h>
+
+ #include "iniparser.h"
+--- kamailio-4.0.4.orig/modules/xhttp_pi/xhttp_pi_fnc.c
++++ kamailio-4.0.4/modules/xhttp_pi/xhttp_pi_fnc.c
+@@ -836,7 +836,7 @@
+ if(vals==NULL||ids==NULL) {LM_ERR("oom\n"); return -1;}
+ col_vals = vals; col_ids = ids;
+ vals = &col_vals[size]; ids = &col_ids[size];
+- memset(vals, 0, sizeof(str*)); memset(ids, 0, sizeof(str*));
++ memset(vals, 0, sizeof(str)); memset(ids, 0, sizeof(str));
+ /* Retrieve the node attribute */
+ attr.s = ph_xmlNodeGetAttrContentByName(node,
+ XHTTP_PI_XML_ID_ATTR);
+--- kamailio-4.0.4.orig/io_wait.h
++++ kamailio-4.0.4/io_wait.h
+@@ -63,7 +63,7 @@
+ #endif
+
+ #define _GNU_SOURCE /* for POLLRDHUP on linux */
+-#include <sys/poll.h>
++#include <poll.h>
+ #include <fcntl.h>
+
+ #ifdef HAVE_EPOLL
+--- kamailio-4.0.4.orig/modules/tls/tls_server.c
++++ kamailio-4.0.4/modules/tls/tls_server.c
+@@ -35,7 +35,7 @@
+ */
+
+
+-#include <sys/poll.h>
++#include <poll.h>
+ #include <openssl/err.h>
+ #include <openssl/ssl.h>
+ #include "../../dprint.h"
+--- kamailio-4.0.4.orig/stats.h
++++ kamailio-4.0.4/stats.h
+@@ -32,7 +32,7 @@
+
+ #include <ctype.h>
+ #include <sys/mman.h>
+-#include <sys/fcntl.h>
++#include <fcntl.h>
+ #include <sys/time.h>
+ #include <time.h>
+ #include <sys/utsname.h>
+--- kamailio-4.0.4.orig/tcp_main.c
++++ kamailio-4.0.4/tcp_main.c
+@@ -150,7 +150,7 @@
+ #ifdef HAVE_SELECT
+ #include <sys/select.h>
+ #endif
+-#include <sys/poll.h>
++#include <poll.h>
+
+
+ #include "ip_addr.h"