From 7b856acbce94141be6840bda4f8b3fc288a96f51 Mon Sep 17 00:00:00 2001 From: Eivind Uggedal Date: Tue, 4 Aug 2015 16:36:24 +0000 Subject: [PATCH] uwsgi: musl compat with patches from Alpine and disabling ugreen --- ...read-functions-instead-of-the-non-po.patch | 40 ++++++++++++ ...bc-instead-of-linux-for-use-of-execi.patch | 31 +++++++++ ...-always-define-_GNU_SOURCE-for-linux.patch | 64 +++++++++++++++++++ .../0004-define-WAIT_ANY-if-missing.patch | 34 ++++++++++ srcpkgs/uwsgi/patches/musl-fix-python.patch | 13 ++++ srcpkgs/uwsgi/template | 10 ++- 6 files changed, 191 insertions(+), 1 deletion(-) create mode 100644 srcpkgs/uwsgi/patches/0001-use-portable-pthread-functions-instead-of-the-non-po.patch create mode 100644 srcpkgs/uwsgi/patches/0002-Check-for-GNU-libc-instead-of-linux-for-use-of-execi.patch create mode 100644 srcpkgs/uwsgi/patches/0003-always-define-_GNU_SOURCE-for-linux.patch create mode 100644 srcpkgs/uwsgi/patches/0004-define-WAIT_ANY-if-missing.patch create mode 100644 srcpkgs/uwsgi/patches/musl-fix-python.patch diff --git a/srcpkgs/uwsgi/patches/0001-use-portable-pthread-functions-instead-of-the-non-po.patch b/srcpkgs/uwsgi/patches/0001-use-portable-pthread-functions-instead-of-the-non-po.patch new file mode 100644 index 0000000000..41f483bf4a --- /dev/null +++ b/srcpkgs/uwsgi/patches/0001-use-portable-pthread-functions-instead-of-the-non-po.patch @@ -0,0 +1,40 @@ +From 1a09a7264026339d8e0c4899a2f9ff488c0bd97d Mon Sep 17 00:00:00 2001 +From: Natanael Copa +Date: Mon, 10 Feb 2014 12:13:00 +0000 +Subject: [PATCH 1/4] use portable pthread functions instead of the + non-portable + +The pthread functions pthread_mutexattr_setrobust and +pthread_mutex_consistent are in posix nowdays. Use those instead of their +non-portable synonyms. + +Signed-off-by: Natanael Copa +--- + core/lock.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/core/lock.c b/core/lock.c +index d368148..f806b2c 100644 +--- core/lock.c ++++ core/lock.c +@@ -99,7 +99,7 @@ retry: + exit(1); + } + if (uwsgi_pthread_robust_mutexes_enabled) { +- if (pthread_mutexattr_setrobust_np(&attr, PTHREAD_MUTEX_ROBUST)) { ++ if (pthread_mutexattr_setrobust(&attr, PTHREAD_MUTEX_ROBUST)) { + uwsgi_log("unable to make the mutex 'robust'\n"); + exit(1); + } +@@ -161,7 +161,7 @@ void uwsgi_lock_fast(struct uwsgi_lock_item *uli) { + #ifdef EOWNERDEAD + if (pthread_mutex_lock((pthread_mutex_t *) uli->lock_ptr) == EOWNERDEAD) { + uwsgi_log("[deadlock-detector] a process holding a robust mutex died. recovering...\n"); +- pthread_mutex_consistent_np((pthread_mutex_t *) uli->lock_ptr); ++ pthread_mutex_consistent((pthread_mutex_t *) uli->lock_ptr); + } + #else + pthread_mutex_lock((pthread_mutex_t *) uli->lock_ptr); +-- +1.8.5.3 + diff --git a/srcpkgs/uwsgi/patches/0002-Check-for-GNU-libc-instead-of-linux-for-use-of-execi.patch b/srcpkgs/uwsgi/patches/0002-Check-for-GNU-libc-instead-of-linux-for-use-of-execi.patch new file mode 100644 index 0000000000..8826c6c6a6 --- /dev/null +++ b/srcpkgs/uwsgi/patches/0002-Check-for-GNU-libc-instead-of-linux-for-use-of-execi.patch @@ -0,0 +1,31 @@ +From ab68dc90d3a6e3ae660adb65cf8a020d91eb8f09 Mon Sep 17 00:00:00 2001 +From: Natanael Copa +Date: Mon, 10 Feb 2014 12:17:18 +0000 +Subject: [PATCH 2/4] Check for GNU libc instead of linux for use of execinfo.h + +Since execinfo.h is a GNU extension it makes more sense to check for GNU +than to assume that linux is GNU. + +This is needed for building on linux with musl libc. + +Signed-off-by: Natanael Copa +--- + core/uwsgi.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/core/uwsgi.c b/core/uwsgi.c +index 67b175b..b3b25ae 100644 +--- core/uwsgi.c ++++ core/uwsgi.c +@@ -1690,7 +1690,7 @@ void uwsgi_plugins_atexit(void) { + + void uwsgi_backtrace(int depth) { + +-#if defined(__linux__) || (defined(__APPLE__) && !defined(NO_EXECINFO)) || defined(UWSGI_HAS_EXECINFO) ++#if defined(__GLIBC__) || (defined(__APPLE__) && !defined(NO_EXECINFO)) || defined(UWSGI_HAS_EXECINFO) + + #include + +-- +1.8.5.3 + diff --git a/srcpkgs/uwsgi/patches/0003-always-define-_GNU_SOURCE-for-linux.patch b/srcpkgs/uwsgi/patches/0003-always-define-_GNU_SOURCE-for-linux.patch new file mode 100644 index 0000000000..7ed608a43d --- /dev/null +++ b/srcpkgs/uwsgi/patches/0003-always-define-_GNU_SOURCE-for-linux.patch @@ -0,0 +1,64 @@ +From c6ddb3e4ca72f6ec8662f8a18674eb4d861561b8 Mon Sep 17 00:00:00 2001 +From: Natanael Copa +Date: Mon, 10 Feb 2014 13:03:50 +0000 +Subject: [PATCH 3/4] always define _GNU_SOURCE for linux + +We are using various extenstions that the spec say depends on _GNU_SOURCE, +for example unshare, CPU_SET, CPU_ZERO, cpu_set_t. We enable those always +for linux and we never unset it. + +Signed-off-by: Natanael Copa +--- + uwsgi.h | 18 +++++------------- + 1 file changed, 5 insertions(+), 13 deletions(-) + +diff --git a/uwsgi.h b/uwsgi.h +index b3ce4f7..3131a0f 100644 +--- uwsgi.h ++++ uwsgi.h +@@ -149,29 +149,22 @@ extern "C" { + #endif + #endif + ++#ifdef __linux__ + #ifndef _GNU_SOURCE + #define _GNU_SOURCE + #endif +-#include +-#ifdef __UCLIBC__ +-#include ++#ifndef __USE_GNU ++#define __USE_GNU ++#endif + #endif +-#undef _GNU_SOURCE + ++#include + #include + #include + #include + #include + + #include +-#ifdef __linux__ +-#ifndef _GNU_SOURCE +-#define _GNU_SOURCE +-#endif +-#ifndef __USE_GNU +-#define __USE_GNU +-#endif +-#endif + #include + #include + #ifdef __linux__ +@@ -179,7 +172,6 @@ extern "C" { + #define MSG_FASTOPEN 0x20000000 + #endif + #endif +-#undef _GNU_SOURCE + #include + + #include +-- +1.8.5.3 + diff --git a/srcpkgs/uwsgi/patches/0004-define-WAIT_ANY-if-missing.patch b/srcpkgs/uwsgi/patches/0004-define-WAIT_ANY-if-missing.patch new file mode 100644 index 0000000000..6a257c965d --- /dev/null +++ b/srcpkgs/uwsgi/patches/0004-define-WAIT_ANY-if-missing.patch @@ -0,0 +1,34 @@ +From 393de27d01710718ffedf46cbbe20c5a1d559c9e Mon Sep 17 00:00:00 2001 +From: Natanael Copa +Date: Mon, 10 Feb 2014 13:15:07 +0000 +Subject: [PATCH 4/4] define WAIT_ANY if missing + +POSIX uses -1 and does not define WAIT_ANY so we need to define it if +needed. + +See: +http://pubs.opengroup.org/onlinepubs/9699919799/functions/waitpid.html +http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_wait.h.html + +Signed-off-by: Natanael Copa +--- + uwsgi.h | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/uwsgi.h b/uwsgi.h +index 3131a0f..7a0d93e 100644 +--- uwsgi.h ++++ uwsgi.h +@@ -257,6 +257,9 @@ extern int pivot_root(const char *new_root, const char *put_old); + #include + + #include ++#ifndef WAIT_ANY ++#define WAIT_ANY (-1) ++#endif + + #ifdef __APPLE__ + #ifndef MAC_OS_X_VERSION_MIN_REQUIRED +-- +1.8.5.3 + diff --git a/srcpkgs/uwsgi/patches/musl-fix-python.patch b/srcpkgs/uwsgi/patches/musl-fix-python.patch new file mode 100644 index 0000000000..c4f401f2fd --- /dev/null +++ b/srcpkgs/uwsgi/patches/musl-fix-python.patch @@ -0,0 +1,13 @@ +diff --git a/plugins/python/uwsgi_python.h b/plugins/python/uwsgi_python.h +index 0c5c1c8..5c0dc6d 100644 +--- plugins/python/uwsgi_python.h ++++ plugins/python/uwsgi_python.h +@@ -1,4 +1,8 @@ + #include ++/* seems like Python.h explicitlyl redefines _GNU_SOURCE */ ++#ifdef _GNU_SOURCE ++#undef _GNU_SOURCE ++#endif + #include + + #include diff --git a/srcpkgs/uwsgi/template b/srcpkgs/uwsgi/template index 390e57690d..3eb3c65b2f 100644 --- a/srcpkgs/uwsgi/template +++ b/srcpkgs/uwsgi/template @@ -1,7 +1,7 @@ # Template file for 'uwsgi' pkgname=uwsgi version=2.0.11.1 -revision=2 +revision=3 build_style=python-module hostmakedepends="python-devel python-setuptools" makedepends="sqlite-devel python-devel python-setuptools libxml2-devel" @@ -12,3 +12,11 @@ license="GPL-2" homepage="http://projects.unbit.it/uwsgi" distfiles="http://projects.unbit.it/downloads/uwsgi-$version.tar.gz" checksum=75a7d3138cfa9cd81a760c2f8a43f3d80961edc8e4f27043dc1412206c926287 + +pre_configure() { + case "$XBPS_TARGET_MACHINE" in + *-musl) + sed -e 's/ugreen,//' -i buildconf/base.ini + ;; + esac +}