aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpsykose <alice@ayaya.dev>2022-11-22 22:16:47 +0000
committerpsykose <alice@ayaya.dev>2022-11-22 23:16:48 +0100
commitf1ea3e929055cac727b65d4c46bdd0b0475622af (patch)
treeb079acd72e03ba9c6a3ebad697e3045f1576c480
parent3d22424e7178b20100447d99cc45b783fbf73263 (diff)
downloadaports-f1ea3e929055cac727b65d4c46bdd0b0475622af.tar.gz
aports-f1ea3e929055cac727b65d4c46bdd0b0475622af.tar.bz2
aports-f1ea3e929055cac727b65d4c46bdd0b0475622af.tar.xz
main/kamailio: fix build with python3.11
-rw-r--r--main/kamailio/APKBUILD2
-rw-r--r--main/kamailio/python3.11.patch78
2 files changed, 80 insertions, 0 deletions
diff --git a/main/kamailio/APKBUILD b/main/kamailio/APKBUILD
index 63c4dea36d..db7426381f 100644
--- a/main/kamailio/APKBUILD
+++ b/main/kamailio/APKBUILD
@@ -33,6 +33,7 @@ makedepends="bison flex freeradius-client-dev expat-dev
# These are in testing / community - can't enable for kamailio in main
# librdkafka-dev dnssec-tools-dev
source="kamailio-${pkgver}$_suffix.tar.gz::https://github.com/kamailio/kamailio/archive/$_gitcommit.tar.gz
+ python3.11.patch
kamailio.initd
"
@@ -556,5 +557,6 @@ sipdump() {
sha512sums="
051a886f448d723dddda082d88df4627ad1139383af56f02e23c94d0fffbc7bf4eb887eb54d63674b1a22e4b88b5bd2fca6407657635dd43bda3e8d3f48d2d15 kamailio-5.6.2.tar.gz
+ac030f2a7b4f2334255d356b6c32ae6cf4247b138781a3e7607389fcab9fc42831ff8fbc96d219f766546a7c15e7c6f1376c1240fd71a667938f581a5f6193b0 python3.11.patch
ebf8de786f29e3f9c35ea92f5e87d3c428998aae9f854b42ed3db7dd16f86d85977b14777adb106f71e2e2eea16349c9dcd962556612472d4c339ebf885015b0 kamailio.initd
"
diff --git a/main/kamailio/python3.11.patch b/main/kamailio/python3.11.patch
new file mode 100644
index 0000000000..dc509bf607
--- /dev/null
+++ b/main/kamailio/python3.11.patch
@@ -0,0 +1,78 @@
+Patch-Source: https://github.com/kamailio/kamailio/commit/b8bf86eb11a17c853450e5c7f81d2446cf719fbc
+modified to pass the version check, and to fix Py_TYPE
+--
+From b8bf86eb11a17c853450e5c7f81d2446cf719fbc Mon Sep 17 00:00:00 2001
+From: Daniel-Constantin Mierla <miconda@gmail.com>
+Date: Thu, 21 Jul 2022 20:15:29 +0200
+Subject: [PATCH] app_python3: use new Python 3.10+ API functions for tracking
+ execution
+
+- GH #3187
+---
+ src/modules/app_python3/apy_kemi.c | 23 ++++++++++++++++++++++-
+ 1 file changed, 22 insertions(+), 1 deletion(-)
+
+diff --git a/src/modules/app_python3/apy_kemi.c b/src/modules/app_python3/apy_kemi.c
+index 421db19..4e685d1 100644
+--- a/src/modules/app_python3/apy_kemi.c
++++ b/src/modules/app_python3/apy_kemi.c
+@@ -1810,6 +1810,9 @@ PyObject *sr_apy_kemi_exec_func(PyObject *self, PyObject *args, int idx)
+ PyObject *ret = NULL;
+ PyThreadState *pstate = NULL;
+ PyFrameObject *pframe = NULL;
++#if PY_VERSION_HEX >= 0x03010000
++ PyCodeObject *pcode = NULL;
++#endif
+ struct timeval tvb = {0}, tve = {0};
+ struct timezone tz;
+ unsigned int tdiff;
+@@ -1832,10 +1835,27 @@ PyObject *sr_apy_kemi_exec_func(PyObject *self, PyObject *args, int idx)
+ + (tve.tv_usec - tvb.tv_usec);
+ if(tdiff >= cfg_get(core, core_cfg, latency_limit_action)) {
+ pstate = PyThreadState_GET();
+- if (pstate != NULL && pstate->frame != NULL) {
++ if (pstate != NULL) {
++#if PY_VERSION_HEX >= 0x03010000
++ pframe = PyThreadState_GetFrame(pstate);
++ if(pframe != NULL) {
++ pcode = PyFrame_GetCode(pframe);
++ }
++#else
+ pframe = pstate->frame;
++#endif
+ }
+
++#if PY_VERSION_HEX >= 0x03010000
++ LOG(cfg_get(core, core_cfg, latency_log),
++ "alert - action KSR.%s%s%s(...)"
++ " took too long [%u ms] (file:%s func:%s line:%d)\n",
++ (ket->mname.len>0)?ket->mname.s:"",
++ (ket->mname.len>0)?".":"", ket->fname.s, tdiff,
++ (pcode)?PyBytes_AsString(pcode->co_filename):"",
++ (pcode)?PyBytes_AsString(pcode->co_name):"",
++ (pframe)?PyFrame_GetLineNumber(pframe):0);
++#else
+ LOG(cfg_get(core, core_cfg, latency_log),
+ "alert - action KSR.%s%s%s(...)"
+ " took too long [%u ms] (file:%s func:%s line:%d)\n",
+@@ -1844,6 +1864,7 @@ PyObject *sr_apy_kemi_exec_func(PyObject *self, PyObject *args, int idx)
+ (pframe && pframe->f_code)?PyBytes_AsString(pframe->f_code->co_filename):"",
+ (pframe && pframe->f_code)?PyBytes_AsString(pframe->f_code->co_name):"",
+ (pframe && pframe->f_code)?PyCode_Addr2Line(pframe->f_code, pframe->f_lasti):0);
++#endif
+ }
+ }
+
+diff --git a/src/modules/app_python3/python_msgobj.c b/src/modules/app_python3/python_msgobj.c
+index db6da6a..5b421e9 100644
+--- a/src/modules/app_python3/python_msgobj.c
++++ b/src/modules/app_python3/python_msgobj.c
+@@ -507,7 +507,7 @@ static PyTypeObject MSGtype = {
+
+ int python_msgobj_init(void)
+ {
+- Py_TYPE(&MSGtype) = &PyType_Type;
++ Py_SET_TYPE(&MSGtype, &PyType_Type);
+ if (PyType_Ready(&MSGtype) < 0)
+ return -1;
+ return 0;