All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v2 1/3] uwsgi: new package
@ 2018-02-02 14:05 Adam Duskett
  2018-02-02 14:06 ` [Buildroot] [PATCH v2 2/3] php: add SAPI API librari option Adam Duskett
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Adam Duskett @ 2018-02-02 14:05 UTC (permalink / raw)
  To: buildroot

Uwsgi is a web server gateway interface written in python that is
meant to be flexible and plugin oriented.

To get it to cross compile, 2 small patches had to be created:

The first fixes the build system attempting to link against /usr/lib
instead of sysconfig.PREFIX.

The second adds a way to specify a location for xml2-config, as the
build-system currently just blindly calls out xml2-config which
can be on the host machine.

Signed-off-by: Adam Duskett <aduskett@gmail.com>
---
Changes v1 -> v2:
  - Changed python-uwsgi to just uwsgi as this isn't a python module.
  - Updated dependencies to reflect above change.
  - Added 0001-Add-fallthrough-comments.patch from upstream and reordered
    the other patches.
  - Changed source URL from PyPI to GitHub as that is the official project
    location.
    
 DEVELOPERS                                         |  1 +
 package/Config.in                                  |  1 +
 package/uwsgi/0001-Add-fallthrough-comments.patch  | 53 +++++++++++++++++++++
 package/uwsgi/0002-fix-libxml2-paths.patch         | 54 ++++++++++++++++++++++
 .../0003-set-libdir-to-sysconfig-PREFIX.patch      | 32 +++++++++++++
 package/uwsgi/Config.in                            | 21 +++++++++
 package/uwsgi/uwsgi.hash                           |  3 ++
 package/uwsgi/uwsgi.mk                             | 31 +++++++++++++
 8 files changed, 196 insertions(+)
 create mode 100644 package/uwsgi/0001-Add-fallthrough-comments.patch
 create mode 100644 package/uwsgi/0002-fix-libxml2-paths.patch
 create mode 100644 package/uwsgi/0003-set-libdir-to-sysconfig-PREFIX.patch
 create mode 100644 package/uwsgi/Config.in
 create mode 100644 package/uwsgi/uwsgi.hash
 create mode 100644 package/uwsgi/uwsgi.mk

diff --git a/DEVELOPERS b/DEVELOPERS
index 9048d45b16..2ddb4099fd 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -58,6 +58,7 @@ F:	package/selinux-python/
 F:	package/semodule-utils/
 F:	package/setools/
 F:	package/sngrep/
+F:	package/uwsgi/
 
 N:	Adrian Perez de Castro <aperez@igalia.com>
 F:	package/libepoxy/
diff --git a/package/Config.in b/package/Config.in
index 9a6b199f40..3eb4addf50 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1837,6 +1837,7 @@ endif
 	source "package/ulogd/Config.in"
 	source "package/ushare/Config.in"
 	source "package/ussp-push/Config.in"
+	source "package/uwsgi/Config.in"
 	source "package/vde2/Config.in"
 	source "package/vdr/Config.in"
 	source "package/vdr-plugin-vnsiserver/Config.in"
diff --git a/package/uwsgi/0001-Add-fallthrough-comments.patch b/package/uwsgi/0001-Add-fallthrough-comments.patch
new file mode 100644
index 0000000000..01c0e54f65
--- /dev/null
+++ b/package/uwsgi/0001-Add-fallthrough-comments.patch
@@ -0,0 +1,53 @@
+From d640610e4ba5c4cf246e5c915c37d9dbcc9741df Mon Sep 17 00:00:00 2001
+From: Adam Duskett <aduskett@gmail.com>
+Date: Fri, 2 Feb 2018 08:30:52 -0500
+Subject: [PATCH] Add fallthrough comments
+
+Add comments that GCC will recognise, as documented:
+https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
+
+Upstream status: fixed
+
+Signed-off-by: Adam Duskett <aduskett@gmail.com>
+---
+ core/hash.c    | 2 ++
+ core/routing.c | 8 ++++----
+ 2 files changed, 6 insertions(+), 4 deletions(-)
+
+diff --git a/core/hash.c b/core/hash.c
+index a1288fa..ccd0a4c 100644
+--- a/core/hash.c
++++ b/core/hash.c
+@@ -42,8 +42,10 @@ static uint32_t murmur2_hash(char *key, uint64_t keylen) {
+ 	switch (keylen) {
+ 		case 3:
+         		h ^= key[2] << 16;
++        		/* fallthrough */
+     		case 2:
+         		h ^= key[1] << 8;
++        		/* fallthrough */
+     		case 1:
+         		h ^= key[0];
+         		h *= 0x5bd1e995;
+diff --git a/core/routing.c b/core/routing.c
+index 42310ca..6d6fb08 100644
+--- a/core/routing.c
++++ b/core/routing.c
+@@ -1792,10 +1792,10 @@ static int uwsgi_route_condition_ipv6in(struct wsgi_request *wsgi_req, struct uw
+ 
+ 	int i = (pfxlen / 32);
+ 	switch (i) {
+-	case 0: mask[0] = 0;
+-	case 1: mask[1] = 0;
+-	case 2: mask[2] = 0;
+-	case 3: mask[3] = 0;
++	case 0: mask[0] = 0; /* fallthrough */
++	case 1: mask[1] = 0; /* fallthrough */
++	case 2: mask[2] = 0; /* fallthrough */
++	case 3: mask[3] = 0; /* fallthrough */
+ 	}
+ 
+ 	if (pfxlen % 32)
+-- 
+2.14.3
+
diff --git a/package/uwsgi/0002-fix-libxml2-paths.patch b/package/uwsgi/0002-fix-libxml2-paths.patch
new file mode 100644
index 0000000000..de3e47c01c
--- /dev/null
+++ b/package/uwsgi/0002-fix-libxml2-paths.patch
@@ -0,0 +1,54 @@
+From b9cf6c65e3cabdea249604497b8d34fe1c35da6f Mon Sep 17 00:00:00 2001
+From: Adam Duskett <Adamduskett@outlook.com>
+Date: Sun, 28 Jan 2018 14:17:59 -0500
+Subject: [PATCH] fix libxml2 paths
+
+instead of blindly calling out xml2-config, check to see if a path for
+xml2-config is provided, and use that if it is.
+
+This prevents python-uwsgi from trying to use the host machines include paths.
+
+Signed-off-by: Adam Duskett <Adamduskett@outlook.com>
+---
+ uwsgiconfig.py | 9 +++++----
+ 1 file changed, 5 insertions(+), 4 deletions(-)
+
+diff --git a/uwsgiconfig.py b/uwsgiconfig.py
+index 17b25b9..0c33491 100644
+--- a/uwsgiconfig.py
++++ b/uwsgiconfig.py
+@@ -1292,12 +1292,13 @@ class uConf(object):
+                 self.gcc_list.append('core/legion')
+                 report['ssl'] = True
+ 
++        xml2config = os.environ.get('XML2_CONFIG','xml2-config')
+         if self.get('xml'):
+             if self.get('xml') == 'auto':
+-                xmlconf = spcall('xml2-config --libs')
++                xmlconf = spcall(xml2config + ' --libs')
+                 if xmlconf:
+                     self.libs.append(xmlconf)
+-                    xmlconf = spcall("xml2-config --cflags")
++                    xmlconf = spcall(xml2config + " --cflags")
+                     self.cflags.append(xmlconf)
+                     self.cflags.append("-DUWSGI_XML -DUWSGI_XML_LIBXML2")
+                     self.gcc_list.append('core/xmlconf')
+@@ -1308,13 +1309,13 @@ class uConf(object):
+                     self.gcc_list.append('core/xmlconf')
+                     report['xml'] = 'expat'
+             elif self.get('xml') == 'libxml2':
+-                xmlconf = spcall('xml2-config --libs')
++                xmlconf = spcall(xml2config + ' --libs')
+                 if xmlconf is None:
+                     print("*** libxml2 headers unavailable. uWSGI build is interrupted. You have to install libxml2 development package or use libexpat or disable XML")
+                     sys.exit(1)
+                 else:
+                     self.libs.append(xmlconf)
+-                    xmlconf = spcall("xml2-config --cflags")
++                    xmlconf = spcall(xml2config + " --cflags")
+                     if xmlconf is None:
+                         print("*** libxml2 headers unavailable. uWSGI build is interrupted. You have to install libxml2 development package or use libexpat or disable XML")
+                         sys.exit(1)
+-- 
+2.14.3
+
diff --git a/package/uwsgi/0003-set-libdir-to-sysconfig-PREFIX.patch b/package/uwsgi/0003-set-libdir-to-sysconfig-PREFIX.patch
new file mode 100644
index 0000000000..b5881e80f5
--- /dev/null
+++ b/package/uwsgi/0003-set-libdir-to-sysconfig-PREFIX.patch
@@ -0,0 +1,32 @@
+From 742e370cc7d9bb75b83805683a4cc0f92f72850b Mon Sep 17 00:00:00 2001
+From: Adam Duskett <Adamduskett@outlook.com>
+Date: Sun, 28 Jan 2018 11:44:04 -0500
+Subject: [PATCH] set libdir to sysconfig.PREFIX.
+
+LIBDIR is currently set to /usr/lib which causes cross-compiling to fail.
+Instead, force the libdir to sysconfig.PREFIX.
+
+Signed-off-by: Adam Duskett <Adamduskett@outlook.com>
+---
+ plugins/python/uwsgiplugin.py | 5 +----
+ 1 file changed, 1 insertion(+), 4 deletions(-)
+
+diff --git a/plugins/python/uwsgiplugin.py b/plugins/python/uwsgiplugin.py
+index 843876f..9c75c9b 100644
+--- a/plugins/python/uwsgiplugin.py
++++ b/plugins/python/uwsgiplugin.py
+@@ -50,10 +50,7 @@ if not 'UWSGI_PYTHON_NOLIB' in os.environ:
+         if '-lutil' in LIBS:
+             LIBS.append('-lutil')
+     else:
+-        try:
+-            libdir = sysconfig.get_config_var('LIBDIR')
+-        except:
+-            libdir = "%s/lib" % sysconfig.PREFIX
++        libdir = "%s/lib" % sysconfig.PREFIX
+ 
+         LDFLAGS.append("-L%s" % libdir)
+         LDFLAGS.append("-Wl,-rpath,%s" % libdir)
+-- 
+2.14.3
+
diff --git a/package/uwsgi/Config.in b/package/uwsgi/Config.in
new file mode 100644
index 0000000000..96e7bc13c2
--- /dev/null
+++ b/package/uwsgi/Config.in
@@ -0,0 +1,21 @@
+config BR2_PACKAGE_UWSGI
+	bool "uwsgi"
+	depends on BR2_USE_MMU
+	depends on BR2_USE_WCHAR
+	depends on BR2_TOOLCHAIN_HAS_THREADS
+	depends on !BR2_STATIC_LIBS
+	select BR2_PACKAGE_JANSSON
+	select BR2_PACKAGE_PCRE
+	select BR2_PACKAGE_LIBXML2
+	select BR2_PACKAGE_UTIL_LINUX
+	select BR2_PACKAGE_UTIL_LINUX_LIBUUID
+	select BR2_PACKAGE_PYTHON3 if !BR2_PACKAGE_PYTHON
+	select BR2_PACKAGE_PYTHON_SETUPTOOLS # runtime dependency
+	help
+	  The uWSGI server.
+	  https://uwsgi-docs.readthedocs.io/en/latest/
+
+comment "uwsgi needs a toolchain w/ wchar, threads, dynamic library"
+	depends on BR2_USE_MMU
+	depends on !BR2_USE_WCHAR || !BR2_TOOLCHAIN_HAS_THREADS || \
+		BR2_STATIC_LIBS
diff --git a/package/uwsgi/uwsgi.hash b/package/uwsgi/uwsgi.hash
new file mode 100644
index 0000000000..eca39a6484
--- /dev/null
+++ b/package/uwsgi/uwsgi.hash
@@ -0,0 +1,3 @@
+# Locally computed
+sha256	251f0670628ce9b9f4c2b4288a7ea921e2ddb3d5e886b6aa2358273573e6fdcf  uwsgi-2.0.15.tar.gz
+sha256	ca495399f5da3ce2724649b47eb118f7549344ba58c0cf350d94c3390e435897  LICENSE
diff --git a/package/uwsgi/uwsgi.mk b/package/uwsgi/uwsgi.mk
new file mode 100644
index 0000000000..f63b37816e
--- /dev/null
+++ b/package/uwsgi/uwsgi.mk
@@ -0,0 +1,31 @@
+################################################################################
+#
+# uwsgi
+#
+################################################################################
+
+UWSGI_VERSION = 2.0.15
+UWSGI_SITE = $(call github,unbit,uwsgi,$(UWSGI_VERSION))
+UWSGI_SETUP_TYPE = setuptools
+UWSGI_LICENSE = GPL2
+UWSGI_LICENSE_FILES = LICENSE
+UWSGI_DEPENDENCIES = libxml2 jansson util-linux pcre
+
+ifeq ($(BR2_PACKAGE_PYTHON),y)
+UWSGI_DEPENDENCIES += python
+else
+UWSGI_DEPENDENCIES += python3
+endif
+
+# Remove static includes that point to the host machine include directory.
+UWSGI_ENV += \
+	UWSGI_REMOVE_INCLUDES="/usr/include,/usr/local/include" \
+	UWSGI_INCLUDES="$(STAGING_DIR)/usr/include" \
+	XML2_CONFIG="$(STAGING_DIR)/usr/bin/xml2-config" \
+	UWSGICONFIG_PHPDIR=$(STAGING_DIR)/usr
+
+ifeq ($(BR2_PACKAGE_OPENSSL),y)
+    UWSGI_DEPENDENCIES += openssl
+endif
+
+$(eval $(python-package))
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Buildroot] [PATCH v2 2/3] php: add SAPI API librari option
  2018-02-02 14:05 [Buildroot] [PATCH v2 1/3] uwsgi: new package Adam Duskett
@ 2018-02-02 14:06 ` Adam Duskett
  2018-02-02 14:06 ` [Buildroot] [PATCH v2 3/3] uwsgi: add plugin support Adam Duskett
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Adam Duskett @ 2018-02-02 14:06 UTC (permalink / raw)
  To: buildroot

This option forces PHP to build libphp7.so. The size of the library is around
3.5MB, which is why this is a configuration option and not something that
is enabled or disabled automatically.

Signed-off-by: Adam Duskett <aduskett@gmail.com>
---
Changes v1 -> v2:
  - Changed BR2_PACKAGE_PHP_EMBED_SAPI to BR2_PACKAGE_PHP_ENABLE_EMBED to
    reflect the configure option name change in PHP 7.2.
  - Updated approximate library size from 4MB to 3.5MB.
  - Changed --embed-sapi to --enable-embed to reflect the configure option
    name change in PHP 7.2.
  - Added a check for static libs as the SAPI API library can be built either
    static or shared.
  - Updated wording in the help section of Config.in

 package/php/Config.in | 7 +++++++
 package/php/php.mk    | 8 ++++++++
 2 files changed, 15 insertions(+)

diff --git a/package/php/Config.in b/package/php/Config.in
index 0fb80063af..d327d08366 100644
--- a/package/php/Config.in
+++ b/package/php/Config.in
@@ -41,6 +41,13 @@ config BR2_PACKAGE_PHP_SAPI_FPM
 	help
 	  PHP-FPM (FastCGI Process Manager)
 
+config BR2_PACKAGE_PHP_ENABLE_EMBED
+	bool "SAPI API library"
+	help
+	  Enable building of embedded SAPI library. The name of the
+	  library on the target is libphp7.so and is approximately
+	  3.5MB in size.
+
 source "package/php/Config.ext"
 
 endif
diff --git a/package/php/php.mk b/package/php/php.mk
index 152ec7d780..511cdfa8cc 100644
--- a/package/php/php.mk
+++ b/package/php/php.mk
@@ -82,6 +82,14 @@ PHP_CONF_OPTS += $(if $(BR2_PACKAGE_PHP_SAPI_CLI),--enable-cli,--disable-cli)
 PHP_CONF_OPTS += $(if $(BR2_PACKAGE_PHP_SAPI_CGI),--enable-cgi,--disable-cgi)
 PHP_CONF_OPTS += $(if $(BR2_PACKAGE_PHP_SAPI_FPM),--enable-fpm,--disable-fpm)
 
+ifeq ($(BR2_PACKAGE_PHP_ENABLE_EMBED),y)
+ifeq ($(BR2_STATIC_LIBS),)
+PHP_CONF_OPTS += --enable-embed=shared
+else
+PHP_CONF_OPTS += --enable-embed=static
+endif
+endif
+
 ifeq ($(BR2_PACKAGE_PHP_SAPI_APACHE),y)
 PHP_DEPENDENCIES += apache
 PHP_CONF_OPTS += --with-apxs2=$(STAGING_DIR)/usr/bin/apxs
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Buildroot] [PATCH v2 3/3] uwsgi: add plugin support
  2018-02-02 14:05 [Buildroot] [PATCH v2 1/3] uwsgi: new package Adam Duskett
  2018-02-02 14:06 ` [Buildroot] [PATCH v2 2/3] php: add SAPI API librari option Adam Duskett
@ 2018-02-02 14:06 ` Adam Duskett
  2018-05-20 21:46 ` [Buildroot] [PATCH v2 1/3] uwsgi: new package Thomas Petazzoni
  2018-05-20 21:50 ` Thomas Petazzoni
  3 siblings, 0 replies; 7+ messages in thread
From: Adam Duskett @ 2018-02-02 14:06 UTC (permalink / raw)
  To: buildroot

To add plugin support, a new patch 0004-add-plugin_base_dir-variable.patch adds
a PLUGIN_DIR_BASE variable to uwsgiconfig.py

Currently, uwsgiconfig.py sets the plugin_dir to the full target directory
path, which embeds the path into the uwsgi binary. This results in uwsgi
trying to load output/target/usr/lib/uwsgi/ instead of
/usr/lib/uwsgi when running on the target.

Creating a new PLUGIN_BASE_DIR variable and attaching it to the plugin_dir
allows the plugin to be installed to the appropriate directory but still
have uwsgi load the plugins from the correct folder when ran from the target.

Also introduced is buildroot.ini.in, this is a base configuration file that
uwsgi uses to build plugins at the end of the build step.

Currently, the only two plugins that have been added and have been tested are
PHP and PAM. However, this sets up the framework to add more the future as
needed.

Signed-off-by: Adam Duskett <aduskett@gmail.com>
---
Changes v1 -> v2:
  - Changed python-uwsgi to just uwsgi as this isn't a python module.
  - Added missing menuconfig change in Config.in
  - Changed 0003-add-plugin_base_dir-variable.patch to
    0004-add-plugin_base_dir-variable.patch because of the new
    0001-Add-fallthrough-comments.patch.
  - Changed the wording of the commit message to be more clear as to why the
    new patch is needed and to be more grammatically correct. 

 .../uwsgi/0004-add-plugin_base_dir-variable.patch  | 45 ++++++++++++++++++++++
 package/uwsgi/Config.in                            | 19 ++++++++-
 package/uwsgi/buildroot.ini.in                     |  6 +++
 package/uwsgi/uwsgi.mk                             | 27 ++++++++++++-
 4 files changed, 95 insertions(+), 2 deletions(-)
 create mode 100644 package/uwsgi/0004-add-plugin_base_dir-variable.patch
 create mode 100644 package/uwsgi/buildroot.ini.in

diff --git a/package/uwsgi/0004-add-plugin_base_dir-variable.patch b/package/uwsgi/0004-add-plugin_base_dir-variable.patch
new file mode 100644
index 0000000000..90e9f71bce
--- /dev/null
+++ b/package/uwsgi/0004-add-plugin_base_dir-variable.patch
@@ -0,0 +1,45 @@
+From 2b15d1c4d48a431a92d76486818a84d9653e549b Mon Sep 17 00:00:00 2001
+From: Adam Duskett <Adamduskett@outlook.com>
+Date: Mon, 29 Jan 2018 11:40:52 -0500
+Subject: [PATCH] add plugin_base_dir variable
+
+Currently, if the plugin_dir is set to the target directory, uwsgi will
+embed the full path during compiling. This results in uwsgi trying to load
+output/target/usr/lib/uwsgi/ instead of /usr/lib/uwsgi when running on the 
+target.
+
+Creating a new PLUGIN_BASE_DIR variable and attaching it to the plugin_dir 
+allows the plugin to be installed to the appropriate directory but still
+have uwsgi load the plugins from the correct folder when ran from the
+target.
+
+Signed-off-by: Adam Duskett <Adamduskett@outlook.com>
+---
+ uwsgiconfig.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/uwsgiconfig.py b/uwsgiconfig.py
+index 0c33491..5b356ec 100644
+--- a/uwsgiconfig.py
++++ b/uwsgiconfig.py
+@@ -27,7 +27,7 @@ try:
+ except:
+     import configparser as ConfigParser
+ 
+-
++plugindir_base = os.environ.get('PLUGIN_DIR_BASE', '/')
+ PY3 = sys.version_info[0] == 3
+ 
+ if uwsgi_os == 'Darwin':
+@@ -1425,7 +1425,7 @@ def build_plugin(path, uc, cflags, ldflags, libs, name = None):
+         pass
+ 
+     if uc:
+-        plugin_dest = uc.get('plugin_build_dir', uc.get('plugin_dir')) + '/' + name + '_plugin'
++        plugin_dest = plugindir_base + uc.get('plugin_build_dir', uc.get('plugin_dir')) + '/' + name + '_plugin'
+     else:
+         plugin_dest = name + '_plugin'
+ 
+-- 
+2.14.3
+
diff --git a/package/uwsgi/Config.in b/package/uwsgi/Config.in
index 96e7bc13c2..fa63842e72 100644
--- a/package/uwsgi/Config.in
+++ b/package/uwsgi/Config.in
@@ -1,4 +1,4 @@
-config BR2_PACKAGE_UWSGI
+menuconfig BR2_PACKAGE_UWSGI
 	bool "uwsgi"
 	depends on BR2_USE_MMU
 	depends on BR2_USE_WCHAR
@@ -15,6 +15,23 @@ config BR2_PACKAGE_UWSGI
 	  The uWSGI server.
 	  https://uwsgi-docs.readthedocs.io/en/latest/
 
+if BR2_PACKAGE_UWSGI
+
+comment "plugins"
+
+config BR2_PACKAGE_UWSGI_PAM
+	bool "pam"
+	depends on BR2_ENABLE_LOCALE
+	depends on !BR2_TOOLCHAIN_USES_MUSL
+	select BR2_PACKAGE_LINUX_PAM
+
+config BR2_PACKAGE_UWSGI_PHP
+	bool "php"
+	select BR2_PACKAGE_PHP
+	select BR2_PACKAGE_PHP_ENABLE_EMBED
+
+endif
+
 comment "uwsgi needs a toolchain w/ wchar, threads, dynamic library"
 	depends on BR2_USE_MMU
 	depends on !BR2_USE_WCHAR || !BR2_TOOLCHAIN_HAS_THREADS || \
diff --git a/package/uwsgi/buildroot.ini.in b/package/uwsgi/buildroot.ini.in
new file mode 100644
index 0000000000..b83e765f42
--- /dev/null
+++ b/package/uwsgi/buildroot.ini.in
@@ -0,0 +1,6 @@
+[uwsgi]
+main_plugin =
+inherit = base
+embedded_plugins = null
+plugin_dir = /usr/lib/uwsgi
+plugins = 
diff --git a/package/uwsgi/uwsgi.mk b/package/uwsgi/uwsgi.mk
index f63b37816e..6f063ca263 100644
--- a/package/uwsgi/uwsgi.mk
+++ b/package/uwsgi/uwsgi.mk
@@ -22,10 +22,35 @@ UWSGI_ENV += \
 	UWSGI_REMOVE_INCLUDES="/usr/include,/usr/local/include" \
 	UWSGI_INCLUDES="$(STAGING_DIR)/usr/include" \
 	XML2_CONFIG="$(STAGING_DIR)/usr/bin/xml2-config" \
-	UWSGICONFIG_PHPDIR=$(STAGING_DIR)/usr
+	UWSGICONFIG_PHPDIR=$(STAGING_DIR)/usr \
+	PLUGIN_DIR_BASE="$(TARGET_DIR)" \
+	UWSGI_PROFILE=$(@D)/buildroot.ini
 
 ifeq ($(BR2_PACKAGE_OPENSSL),y)
     UWSGI_DEPENDENCIES += openssl
 endif
 
+ifeq ($(BR2_PACKAGE_UWSGI_PAM),y)
+UWSGI_DEPENDENCIES += linux-pam
+UWSGI_PLUGINS += pam
+endif
+
+ifeq ($(BR2_PACKAGE_UWSGI_PHP),y)
+UWSGI_DEPENDENCIES += php
+UWSGI_PLUGINS += php
+endif
+
+define UWSGI_SETUP_PROFILE
+	$(INSTALL) -D -m 755 package/uwsgi/buildroot.ini.in \
+		$(@D)/buildroot.ini
+	mkdir -p $(TARGET_DIR)/usr/lib/uwsgi
+	$(foreach f,$(UWSGI_PLUGINS), \
+		echo "    $(f)," >> $(@D)/buildroot.ini
+	)
+	# Remove the trailing comma in buildroot.ini.
+	# This prevents uwsgi from trying to compile a blank plugin.
+	$(SED) '$$ s/.$$//' $(@D)/buildroot.ini
+endef
+UWSGI_POST_PATCH_HOOKS = UWSGI_SETUP_PROFILE
+
 $(eval $(python-package))
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Buildroot] [PATCH v2 1/3] uwsgi: new package
  2018-02-02 14:05 [Buildroot] [PATCH v2 1/3] uwsgi: new package Adam Duskett
  2018-02-02 14:06 ` [Buildroot] [PATCH v2 2/3] php: add SAPI API librari option Adam Duskett
  2018-02-02 14:06 ` [Buildroot] [PATCH v2 3/3] uwsgi: add plugin support Adam Duskett
@ 2018-05-20 21:46 ` Thomas Petazzoni
  2018-05-20 21:50 ` Thomas Petazzoni
  3 siblings, 0 replies; 7+ messages in thread
From: Thomas Petazzoni @ 2018-05-20 21:46 UTC (permalink / raw)
  To: buildroot

Hello,

On Fri,  2 Feb 2018 09:05:59 -0500, Adam Duskett wrote:
> Uwsgi is a web server gateway interface written in python that is
> meant to be flexible and plugin oriented.
> 
> To get it to cross compile, 2 small patches had to be created:
> 
> The first fixes the build system attempting to link against /usr/lib
> instead of sysconfig.PREFIX.
> 
> The second adds a way to specify a location for xml2-config, as the
> build-system currently just blindly calls out xml2-config which
> can be on the host machine.
> 
> Signed-off-by: Adam Duskett <aduskett@gmail.com>

I am sorry, but this is again not up to the level of quality that I
would expect from an experienced contributor like you.

 (1) It fails to build with uClibc, first because it includes
     <execinfo.h> when __GLIBC__ is defined. I've fixed that.

 (2) It still fails to build with uClibc, because a workaround for a
     glibc 2.2.3 bug gets enabled with uClibc and doesn't build. I've
     fixed that.

 (3) You make util-linux, pcre, jansson and libxml2 mandatory
     dependencies, but they are not. You can customize
     buildconf/base.ini to disable these. I was able to do a uwsgi
     build with none of those dependencies enabled.

 (4) I've done a build with python-setuptools on the target, and uwsgi
     works just fine.

So this clearly needs to be reworked. Could you have another look at
this package, and make an improved submission ?

Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Buildroot] [PATCH v2 1/3] uwsgi: new package
  2018-02-02 14:05 [Buildroot] [PATCH v2 1/3] uwsgi: new package Adam Duskett
                   ` (2 preceding siblings ...)
  2018-05-20 21:46 ` [Buildroot] [PATCH v2 1/3] uwsgi: new package Thomas Petazzoni
@ 2018-05-20 21:50 ` Thomas Petazzoni
  3 siblings, 0 replies; 7+ messages in thread
From: Thomas Petazzoni @ 2018-05-20 21:50 UTC (permalink / raw)
  To: buildroot

Hello,

On Fri,  2 Feb 2018 09:05:59 -0500, Adam Duskett wrote:
> Uwsgi is a web server gateway interface written in python that is
> meant to be flexible and plugin oriented.
> 
> To get it to cross compile, 2 small patches had to be created:
> 
> The first fixes the build system attempting to link against /usr/lib
> instead of sysconfig.PREFIX.
> 
> The second adds a way to specify a location for xml2-config, as the
> build-system currently just blindly calls out xml2-config which
> can be on the host machine.
> 
> Signed-off-by: Adam Duskett <aduskett@gmail.com>

A few minor nits below.

> +UWSGI_LICENSE = GPL2

This is not a valid SPDX license code.

> +ifeq ($(BR2_PACKAGE_OPENSSL),y)
> +    UWSGI_DEPENDENCIES += openssl

Don't indent such lines.

(This is the type of minor nits I would have fixed myself when
applying, but considering the other issues pointed out in my other
e-mail, I can't apply this patch for the moment.)

Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Buildroot] [PATCH v2 1/3] uwsgi: new package
  2019-11-23 20:20 ` [Buildroot] [PATCH v2 1/3] " aduskett at gmail.com
@ 2020-02-04 12:54   ` Yann E. MORIN
  0 siblings, 0 replies; 7+ messages in thread
From: Yann E. MORIN @ 2020-02-04 12:54 UTC (permalink / raw)
  To: buildroot

Adam, All,

On 2019-11-23 12:20 -0800, aduskett at gmail.com spake thusly:
> From: Adam Duskett <Aduskett@gmail.com>
> 
> The uWSGI project aims at developing a full stack for building hosting services.
> Application servers (for various programming languages and protocols), proxies,
> process managers and monitors are all implemented using a common API and a
> standard configuration style. Thanks to its pluggable architecture, it can be
> extended to support more platforms and languages.

As seen IRL, this does not seem to be building on current master...  :-(

So, I've marked as changes requested on patchwork. Sorry for the
delay... :-(

Regards,
Yann E. MORIN.

> There are five patches currently required to properly cross-compile uWSGI, all
> but one of which are pending upstream:
> 
> 1) add-plugin_base_dir-variable.patch
>   - uWSGI appends the full path of the plugin directory to the binary when
>     compiling, which results in plugins failing to load on the target filing
>     system.
> 
> 2) add-a-xml2_config-environment-variable-for-cross-co.patch
>   - uWSGI calls out to xml2-config with no way to define a path for xml2-config,
>     thus resulting in the hosts xml2-config cflags and library paths used, add
>     the XML2_CONFIG environment variable which overwrites the default
>     xml2-config path.
> 
> 3) add-a-pcre_config-environment-variable-for-cross-co.patch
>   - This patch is the same as the above, except the variable name is
>     PCRE_CONFIG.
> 
> 4) adjust-python-library-header-paths-for-cross-compila.patch
>   - uWSGI calls sysconfig.get_config_var('LIBDIR') which return the host header
>     and library paths. To fix this, prefix the LIBDIR path with _python_sysroot
>     taken from the sysconfigdata module.
> 
> 5) fix-building-with-uClibc.patch
>   - There are two issues building uwsgi with uClibc:
>     1) core/uwsgi.c includes <execinfo.h> when __GLIBC__  is defined, but does
>        not check if __UCLIBC__ is also defined.
>     2) plugins/router_basicauth/router_basicauth.c checks if __GLIBC__ is
>        defined for <crypt.h> and to enable a workaround for a bug in
>        Glibc-2.2.5, both of which do not apply to uClibc. Adding a check for
>        __UCLIBC__ for both of these conditions fixes the issue.
> 
> Even though PCRE is not technically required, the official documentation
> recommends always building with PCRE support, and many of the embedded plugins
> require PCRE to be present. As such, PCRE is set as a dependency.
> https://uwsgi-docs.readthedocs.io/en/latest/SNI.html?highlight=sni-regexp
> 
> The "Main application type" prompt in the Config.in is to set the main_plugin
> variable in the buildroot.ini file.
> 
> There is a "buildroot.ini.in" file which is used to overwrite the default
> settings in buildconf/base.ini. The following settings that explicitly set:
>  - json: Allow a config file to be in JSON format
>  - pcre: Explicitly set to True
>  - ssl: Allow SSL connections
>  - xml: Allow a config file to be in XML format.
>  - yaml: Allow a config file to be in YAML format.
>  - main_plugin: Set to Python.
>  - plugin_dir: The plugin directory for the target.
> 
> The .ini file does not have a standard value for each option; because of this,
> each option is a key/value pair with a colon set as a delimiter. A for loop
> set's each setting appropriately by splitting the key/value into two variables
> and running SED against the .ini file.
> 
> Tested with every option enabled:
> 
> br-arm-full [1/6]: OK
> br-arm-cortex-a9-glibc [2/6]: OK
> br-arm-cortex-m4-full [3/6]: SKIPPED
> br-x86-64-musl [4/6]: OK
> br-arm-full-static [5/6]: SKIPPED
> sourcery-arm [6/6]: OK
> 
> Signed-off-by: Adam Duskett <Aduskett@gmail.com>
> ---
>  DEVELOPERS                                    |   1 +
>  package/Config.in                             |   1 +
>  .../0001-add-plugin_base_dir-variable.patch   |  47 ++++++++
>  ...ig-environment-variable-for-cross-co.patch |  60 +++++++++++
>  ...ig-environment-variable-for-cross-co.patch |  58 ++++++++++
>  ...brary-header-paths-for-cross-compila.patch |  34 ++++++
>  .../uwsgi/0005-fix-building-with-uClibc.patch |  61 +++++++++++
>  package/uwsgi/Config.in                       |  65 ++++++++++++
>  package/uwsgi/buildroot.ini.in                |   9 ++
>  package/uwsgi/uwsgi.hash                      |   3 +
>  package/uwsgi/uwsgi.mk                        | 100 ++++++++++++++++++
>  11 files changed, 439 insertions(+)
>  create mode 100644 package/uwsgi/0001-add-plugin_base_dir-variable.patch
>  create mode 100644 package/uwsgi/0002-add-a-xml2_config-environment-variable-for-cross-co.patch
>  create mode 100644 package/uwsgi/0003-add-a-pcre_config-environment-variable-for-cross-co.patch
>  create mode 100644 package/uwsgi/0004-adjust-python-library-header-paths-for-cross-compila.patch
>  create mode 100644 package/uwsgi/0005-fix-building-with-uClibc.patch
>  create mode 100644 package/uwsgi/Config.in
>  create mode 100644 package/uwsgi/buildroot.ini.in
>  create mode 100644 package/uwsgi/uwsgi.hash
>  create mode 100644 package/uwsgi/uwsgi.mk
> 
> diff --git a/DEVELOPERS b/DEVELOPERS
> index 991be89849..19fbf6254d 100644
> --- a/DEVELOPERS
> +++ b/DEVELOPERS
> @@ -74,6 +74,7 @@ F:	package/semodule-utils/
>  F:	package/setools/
>  F:	package/sngrep/
>  F:	package/systemd/
> +F:	package/uwsgi/
>  
>  N:	Adam Heinrich <adam@adamh.cz>
>  F:	package/jack1/
> diff --git a/package/Config.in b/package/Config.in
> index f72c77b416..53a01fbe08 100644
> --- a/package/Config.in
> +++ b/package/Config.in
> @@ -2129,6 +2129,7 @@ endif
>  	source "package/vpnc/Config.in"
>  	source "package/vsftpd/Config.in"
>  	source "package/vtun/Config.in"
> +	source "package/uwsgi/Config.in"
>  	source "package/wavemon/Config.in"
>  	source "package/wget/Config.in"
>  	source "package/whois/Config.in"
> diff --git a/package/uwsgi/0001-add-plugin_base_dir-variable.patch b/package/uwsgi/0001-add-plugin_base_dir-variable.patch
> new file mode 100644
> index 0000000000..ace1df09a4
> --- /dev/null
> +++ b/package/uwsgi/0001-add-plugin_base_dir-variable.patch
> @@ -0,0 +1,47 @@
> +From 2b15d1c4d48a431a92d76486818a84d9653e549b Mon Sep 17 00:00:00 2001
> +From: Adam Duskett <Adamduskett@outlook.com>
> +Date: Mon, 29 Jan 2018 11:40:52 -0500
> +Subject: [PATCH] add plugin_base_dir variable
> +
> +Currently, when cross-compiling, if the plugin_dir points to the target
> +directory, uwsgi will embed the full path during compiling.
> +This whole path results in uwsgi trying to load a full target path instead of
> +/usr/lib/uwsgi when running on the target.
> +
> +Creating a new PLUGIN_BASE_DIR variable and prefixing plugin_dir allows the
> +plugin to be installed to the appropriate directory but still have uwsgi load
> +the plugins from the correct folder when ran from on the cross-compiled target.
> +
> +Current status: Pending
> +https://github.com/unbit/uwsgi/pull/2052
> +
> +Signed-off-by: Adam Duskett <Adamduskett@outlook.com>
> +---
> + uwsgiconfig.py | 4 ++--
> + 1 file changed, 2 insertions(+), 2 deletions(-)
> +
> +diff --git a/uwsgiconfig.py b/uwsgiconfig.py
> +index 0c33491..5b356ec 100644
> +--- a/uwsgiconfig.py
> ++++ b/uwsgiconfig.py
> +@@ -27,7 +27,7 @@ try:
> + except:
> +     import configparser as ConfigParser
> + 
> +-
> ++PLUGIN_BASE_DIR = os.environ.get('PLUGIN_BASE_DIR', '')
> + PY3 = sys.version_info[0] == 3
> + 
> + if uwsgi_os == 'Darwin':
> +@@ -1435,7 +1435,7 @@ def build_plugin(path, uc, cflags, ldflags, libs, name = None):
> +         pass
> + 
> +     if uc:
> +-        plugin_dest = uc.get('plugin_build_dir', uc.get('plugin_dir')) + '/' + name + '_plugin'
> ++        plugin_dest = PLUGIN_BASE_DIR + uc.get('plugin_build_dir', uc.get('plugin_dir')) + '/' + name + '_plugin'
> +     else:
> +         plugin_dest = name + '_plugin'
> + 
> +-- 
> +2.14.3
> +
> diff --git a/package/uwsgi/0002-add-a-xml2_config-environment-variable-for-cross-co.patch b/package/uwsgi/0002-add-a-xml2_config-environment-variable-for-cross-co.patch
> new file mode 100644
> index 0000000000..014494e5cb
> --- /dev/null
> +++ b/package/uwsgi/0002-add-a-xml2_config-environment-variable-for-cross-co.patch
> @@ -0,0 +1,60 @@
> +From b98241acc633396dc7f4ab9e4153af552ac6d4a0 Mon Sep 17 00:00:00 2001
> +From: Adam Duskett <Aduskett@gmail.com>
> +Date: Sat, 3 Aug 2019 14:59:18 -0400
> +Subject: [PATCH] add a XML2_CONFIG environment variable for cross-compiling
> +
> +Currently, xml2-config is called out with no way to define an xml2-config path,
> +which causes uwsgi to use the host xml2-config which will cause the xml2
> +library and CFlag directories to point to the host instead of
> +the cross-environment.
> +
> +Add a check for the XML2_CONFIG environment variable, and if it exists, use the
> +resulting path instead.
> +
> +Current-status: pending
> +https://github.com/unbit/uwsgi/pull/2050
> +
> +Signed-off-by: Adam Duskett <aduskett@gmail.com>
> +---
> + uwsgiconfig.py | 9 +++++----
> + 1 file changed, 5 insertions(+), 4 deletions(-)
> +
> +diff --git a/uwsgiconfig.py b/uwsgiconfig.py
> +index 22c9dd3..26403f1 100644
> +--- a/uwsgiconfig.py
> ++++ b/uwsgiconfig.py
> +@@ -1303,12 +1303,13 @@ class uConf(object):
> +                 self.gcc_list.append('core/legion')
> +                 report['ssl'] = True
> + 
> ++        xml2config = os.environ.get('XML2_CONFIG','xml2-config')
> +         if self.get('xml'):
> +             if self.get('xml') == 'auto':
> +-                xmlconf = spcall('xml2-config --libs')
> ++                xmlconf = spcall(xml2config + ' --libs')
> +                 if xmlconf and uwsgi_os != 'Darwin':
> +                     self.libs.append(xmlconf)
> +-                    xmlconf = spcall("xml2-config --cflags")
> ++                    xmlconf = spcall(xml2config + " --cflags")
> +                     self.cflags.append(xmlconf)
> +                     self.cflags.append("-DUWSGI_XML -DUWSGI_XML_LIBXML2")
> +                     self.gcc_list.append('core/xmlconf')
> +@@ -1319,13 +1320,13 @@ class uConf(object):
> +                     self.gcc_list.append('core/xmlconf')
> +                     report['xml'] = 'expat'
> +             elif self.get('xml') == 'libxml2':
> +-                xmlconf = spcall('xml2-config --libs')
> ++                xmlconf = spcall(xml2config + ' --libs')
> +                 if xmlconf is None:
> +                     print("*** libxml2 headers unavailable. uWSGI build is interrupted. You have to install libxml2 development package or use libexpat or disable XML")
> +                     sys.exit(1)
> +                 else:
> +                     self.libs.append(xmlconf)
> +-                    xmlconf = spcall("xml2-config --cflags")
> ++                    xmlconf = spcall(xml2config + " --cflags")
> +                     if xmlconf is None:
> +                         print("*** libxml2 headers unavailable. uWSGI build is interrupted. You have to install libxml2 development package or use libexpat or disable XML")
> +                         sys.exit(1)
> +-- 
> +2.21.0
> +
> diff --git a/package/uwsgi/0003-add-a-pcre_config-environment-variable-for-cross-co.patch b/package/uwsgi/0003-add-a-pcre_config-environment-variable-for-cross-co.patch
> new file mode 100644
> index 0000000000..88fca366b4
> --- /dev/null
> +++ b/package/uwsgi/0003-add-a-pcre_config-environment-variable-for-cross-co.patch
> @@ -0,0 +1,58 @@
> +From 170cbd7226c1a0774da3c19733c2f473befc8eed Mon Sep 17 00:00:00 2001
> +From: Adam Duskett <Aduskett@gmail.com>
> +Date: Sat, 3 Aug 2019 15:32:41 -0400
> +Subject: [PATCH] Add a PCRE_CONFIG environment variable for cross-compiling
> +
> +Currently, pcre-config is called out with no way to define a pcre-config path,
> +which causes uwsgi to use the host pcre-config, which will cause the pcre
> +library and cflag directories to point to the host.
> +
> +Add a check for the PCRE_CONFIG environment variable, and if it exists,
> +use the resulting path instead.
> +
> +upstream-status: pending
> +https://github.com/unbit/uwsgi/pull/2051
> +
> +Signed-off-by: Adam Duskett <Aduskett@gmail.com>
> +---
> + uwsgiconfig.py | 9 +++++----
> + 1 file changed, 5 insertions(+), 4 deletions(-)
> +
> +diff --git a/uwsgiconfig.py b/uwsgiconfig.py
> +index 26403f1..b800cdb 100644
> +--- a/uwsgiconfig.py
> ++++ b/uwsgiconfig.py
> +@@ -1072,25 +1072,26 @@ class uConf(object):
> +         has_pcre = False
> + 
> +         # re-enable after pcre fix
> ++        pcreconfig = os.environ.get('PCRE_CONFIG','pcre-config')
> +         if self.get('pcre'):
> +             if self.get('pcre') == 'auto':
> +-                pcreconf = spcall('pcre-config --libs')
> ++                pcreconf = spcall(pcreconfig + ' --libs')
> +                 if pcreconf:
> +                     self.libs.append(pcreconf)
> +-                    pcreconf = spcall("pcre-config --cflags")
> ++                    pcreconf = spcall(pcreconfig + ' --cflags')
> +                     self.cflags.append(pcreconf)
> +                     self.gcc_list.append('core/regexp')
> +                     self.cflags.append("-DUWSGI_PCRE")
> +                     has_pcre = True
> + 
> +             else:
> +-                pcreconf = spcall('pcre-config --libs')
> ++                pcreconf = spcall(pcreconfig + ' --libs')
> +                 if pcreconf is None:
> +                     print("*** libpcre headers unavailable. uWSGI build is interrupted. You have to install pcre development package or disable pcre")
> +                     sys.exit(1)
> +                 else:
> +                     self.libs.append(pcreconf)
> +-                    pcreconf = spcall("pcre-config --cflags")
> ++                    pcreconf = spcall(pcreconfig + ' --cflags')
> +                     self.cflags.append(pcreconf)
> +                     self.gcc_list.append('core/regexp')
> +                     self.cflags.append("-DUWSGI_PCRE")
> +-- 
> +2.21.0
> +
> diff --git a/package/uwsgi/0004-adjust-python-library-header-paths-for-cross-compila.patch b/package/uwsgi/0004-adjust-python-library-header-paths-for-cross-compila.patch
> new file mode 100644
> index 0000000000..9eb39b1212
> --- /dev/null
> +++ b/package/uwsgi/0004-adjust-python-library-header-paths-for-cross-compila.patch
> @@ -0,0 +1,34 @@
> +From 8bf43f727d34619773d826357f49e172876f8a30 Mon Sep 17 00:00:00 2001
> +From: Adam Duskett <Aduskett@gmail.com>
> +Date: Sat, 3 Aug 2019 17:12:09 -0400
> +Subject: [PATCH] Adjust python library/header paths for cross-compilation
> +
> +uWSGI calls sysconfig.get_config_var('LIBDIR') which return the host header and
> +library paths.
> +
> +To fix this, prefix the LIBDIR path with _python_sysroot taken
> +from the sysconfigdata module.
> +
> +upstream status: Not submitted, Buildroot specific.
> +
> +Signed-off-by: Adam Duskett <Aduskett@gmail.com>
> +---
> + plugins/python/uwsgiplugin.py | 2 ++
> + 1 file changed, 2 insertions(+)
> +
> +diff --git a/plugins/python/uwsgiplugin.py b/plugins/python/uwsgiplugin.py
> +index 843876f..a74de7d 100644
> +--- a/plugins/python/uwsgiplugin.py
> ++++ b/plugins/python/uwsgiplugin.py
> +@@ -52,6 +52,8 @@ if not 'UWSGI_PYTHON_NOLIB' in os.environ:
> +     else:
> +         try:
> +             libdir = sysconfig.get_config_var('LIBDIR')
> ++            if "_python_sysroot" in os.environ:
> ++                libdir = os.environ.get("_python_sysroot") + libdir
> +         except:
> +             libdir = "%s/lib" % sysconfig.PREFIX
> + 
> +-- 
> +2.21.0
> +
> diff --git a/package/uwsgi/0005-fix-building-with-uClibc.patch b/package/uwsgi/0005-fix-building-with-uClibc.patch
> new file mode 100644
> index 0000000000..1f546fa412
> --- /dev/null
> +++ b/package/uwsgi/0005-fix-building-with-uClibc.patch
> @@ -0,0 +1,61 @@
> +From 98c616be6bb745cc5178de3b1a3a84d1f86d6e34 Mon Sep 17 00:00:00 2001
> +From: Adam Duskett <Aduskett@gmail.com>
> +Date: Wed, 7 Aug 2019 15:10:46 -0400
> +Subject: [PATCH] fix building with uClibc
> +
> +There are two issues building uwsgi with uClibc:
> +1) core/uwsgi.c includes <execinfo.h> when __GLIBC__  is defined, but does not
> +check if __UCLIBC__ is also defined.
> +
> +2) plugins/router_basicauth/router_basicauth.c checks if __GLIBC__ is defined
> +for <crypt.h> and to enable a workaround for a bug in glibc-2.2.5, both of which
> +do not apply to uClibc.
> +Add a check for __UCLIBC__ for both of these conditions.
> +
> +Upstream status: Merged.
> +https://github.com/unbit/uwsgi/pull/2054
> +
> +Signed-off-by: Adam Duskett <Aduskett@gmail.com>
> +---
> + core/uwsgi.c                                | 2 +-
> + plugins/router_basicauth/router_basicauth.c | 4 ++--
> + 2 files changed, 3 insertions(+), 3 deletions(-)
> +
> +diff --git a/core/uwsgi.c b/core/uwsgi.c
> +index ef9e310..523bf45 100644
> +--- a/core/uwsgi.c
> ++++ b/core/uwsgi.c
> +@@ -1820,7 +1820,7 @@ void uwsgi_plugins_atexit(void) {
> + 
> + void uwsgi_backtrace(int depth) {
> + 
> +-#if defined(__GLIBC__) || (defined(__APPLE__) && !defined(NO_EXECINFO)) || defined(UWSGI_HAS_EXECINFO)
> ++#if (!defined(__UCLIBC__) && defined __GLIBC__) || (defined(__APPLE__) && !defined(NO_EXECINFO)) || defined(UWSGI_HAS_EXECINFO)
> + 
> + #include <execinfo.h>
> + 
> +diff --git a/plugins/router_basicauth/router_basicauth.c b/plugins/router_basicauth/router_basicauth.c
> +index 429bade..0b7161e 100644
> +--- a/plugins/router_basicauth/router_basicauth.c
> ++++ b/plugins/router_basicauth/router_basicauth.c
> +@@ -3,7 +3,7 @@
> + #ifdef UWSGI_ROUTING
> + 
> + // TODO: Add more crypt_r supported platfroms here
> +-#if defined(__linux__) && defined(__GLIBC__)
> ++#if defined(__linux__) && defined(__GLIBC__) && !defined(__UCLIBC__)
> + #include <crypt.h>
> + #elif defined(__CYGWIN__)
> + #include <crypt.h>
> +@@ -67,7 +67,7 @@ static uint16_t htpasswd_check(char *filename, char *auth) {
> + 
> + 		if (clen > 13) cpwd[13] = 0;
> + 
> +-#if defined(__linux__) && defined(__GLIBC__)
> ++#if defined(__linux__) && defined(__GLIBC__) && !defined(__UCLIBC__)
> + 		struct crypt_data cd;
> + 		memset(&cd, 0, sizeof(struct crypt_data));
> +     /* work around glibc-2.2.5 bug,
> +-- 
> +2.21.0
> +
> diff --git a/package/uwsgi/Config.in b/package/uwsgi/Config.in
> new file mode 100644
> index 0000000000..f0de3093a4
> --- /dev/null
> +++ b/package/uwsgi/Config.in
> @@ -0,0 +1,65 @@
> +menuconfig BR2_PACKAGE_UWSGI
> +	bool "uwsgi"
> +	depends on !BR2_STATIC_LIBS # dlfcn.h
> +	depends on BR2_USE_MMU # python
> +	depends on BR2_USE_WCHAR # python
> +	depends on BR2_TOOLCHAIN_HAS_THREADS # python
> +	# While it's possible to build uwsgi without PCRE, it would require not to
> +	# build Python or PHP or several of the embedded plugins.
> +	# The official documentation also recommends building PCRE support.
> +	# https://uwsgi-docs.readthedocs.io/en/latest/SNI.html?highlight=sni-regexp
> +	select BR2_PACKAGE_PCRE
> +	select BR2_PACKAGE_PYTHON3 if !BR2_PACKAGE_PYTHON
> +	help
> +	  The uWSGI server.
> +	  The uWSGI project aims at developing a full stack for
> +	  building hosting services. Application servers
> +	  (for various programming languages and protocols), proxies,
> +	  process managers and monitors are all implemented using a
> +	  common API and a standard configuration style. Thanks to
> +	  its pluggable architecture, it can be extended to support
> +	  more platforms and languages.
> +
> +	  https://uwsgi-docs.readthedocs.io/en/latest/
> +
> +if BR2_PACKAGE_UWSGI
> +
> +comment "plugins"
> +
> +config BR2_PACKAGE_UWSGI_PLUGINS_CAPABILITIES
> +	bool "POSIX capability support"
> +	select BR2_PACKAGE_LIBCAP
> +	help
> +	  POSIX capabilities allow fine-grained permissions for
> +	  processes. In addition to the standard UNIX permission scheme,
> +	  they define a new set of privileges for system resources.
> +
> +config BR2_PACKAGE_UWSGI_PLUGINS_JSON
> +	bool "JSON"
> +	select BR2_PACKAGE_JANSSON if !BR2_PACKAGE_YAJL
> +	help
> +	  Load the config from a json file.
> +
> +config BR2_PACKAGE_UWSGI_PLUGINS_SSL
> +	bool "SSL"
> +	select BR2_PACKAGE_OPENSSL
> +	help
> +	  SSL Support
> +
> +config BR2_PACKAGE_UWSGI_PLUGINS_XML
> +	bool "XML"
> +	select BR2_PACKAGE_LIBXML2 if !BR2_PACKAGE_EXPAT
> +	help
> +	  Load the config from a XML file.
> +
> +config BR2_PACKAGE_UWSGI_PLUGINS_YAML
> +	bool "YAML"
> +	select BR2_PACKAGE_LIBYAML
> +	help
> +	  Load the config from a YAML file.
> +
> +endif
> +
> +comment "uwsgi needs a toolchain w/ dynamic library, wchar, threads"
> +	depends on BR2_USE_MMU
> +	depends on !BR2_USE_WCHAR || !BR2_TOOLCHAIN_HAS_THREADS || BR2_STATIC_LIBS
> diff --git a/package/uwsgi/buildroot.ini.in b/package/uwsgi/buildroot.ini.in
> new file mode 100644
> index 0000000000..75ad8afa32
> --- /dev/null
> +++ b/package/uwsgi/buildroot.ini.in
> @@ -0,0 +1,9 @@
> +[uwsgi]
> +inherit = base
> +json = false
> +pcre = true
> +ssl = false
> +xml = false
> +yaml = false
> +main_plugin = python
> +plugin_dir = /usr/lib/uwsgi
> diff --git a/package/uwsgi/uwsgi.hash b/package/uwsgi/uwsgi.hash
> new file mode 100644
> index 0000000000..bbdfe3b9ea
> --- /dev/null
> +++ b/package/uwsgi/uwsgi.hash
> @@ -0,0 +1,3 @@
> +# Locally computed
> +sha256	4972ac538800fb2d421027f49b4a1869b66048839507ccf0aa2fda792d99f583  uwsgi-2.0.18.tar.gz
> +sha256	ca495399f5da3ce2724649b47eb118f7549344ba58c0cf350d94c3390e435897  LICENSE
> diff --git a/package/uwsgi/uwsgi.mk b/package/uwsgi/uwsgi.mk
> new file mode 100644
> index 0000000000..add75c04b9
> --- /dev/null
> +++ b/package/uwsgi/uwsgi.mk
> @@ -0,0 +1,100 @@
> +################################################################################
> +#
> +# uwsgi
> +#
> +################################################################################
> +
> +UWSGI_VERSION = 2.0.18
> +UWSGI_SITE = $(call github,unbit,uwsgi,$(UWSGI_VERSION))
> +UWSGI_LICENSE = GPL-2.0+
> +UWSGI_LICENSE_FILES = LICENSE
> +UWSGI_DEPENDENCIES += pcre
> +
> +UWSGI_ENV += \
> +	CC="$(TARGET_CC)" \
> +	UWSGI_REMOVE_INCLUDES="/usr/include,/usr/local/include" \
> +	UWSGI_INCLUDES="$(STAGING_DIR)/usr/include" \
> +	PLUGIN_BASE_DIR="$(TARGET_DIR)" \
> +	PCRE_CONFIG="$(STAGING_DIR)/usr/bin/pcre-config" \
> +	UWSGI_PROFILE=$(@D)/buildroot.ini \
> +	PYTHON_LIBDIR="$(STAGING_DIR)/usr/lib"
> +
> +ifeq ($(BR2_PACKAGE_PYTHON),y)
> +UWSGI_DEPENDENCIES += host-python host-python-setuptools python
> +else
> +UWSGI_DEPENDENCIES += host-python3 host-python3-setuptools python3
> +endif
> +
> +ifeq ($(BR2_PACKAGE_LIBZLIB),y)
> +UWSGI_DEPENDENCIES += libzlib
> +endif
> +
> +ifeq ($(BR2_PACKAGE_UTIL_LINUX_LIBUUID),y)
> +UWSGI_DEPENDENCIES += util-linux
> +endif
> +
> +# Plugins
> +ifeq ($(BR2_PACKAGE_UWSGI_PLUGINS_CAPABILITIES),y)
> +UWSGI_DEPENDENCIES += libcap
> +endif
> +
> +# The uwsgi config.ini file does not use the same values for every option.
> +# Use a key/value with a colon as a delimiter to set the appropriate setting.
> +ifeq ($(BR2_PACKAGE_UWSGI_PLUGINS_JSON),y)
> +ifeq ($(BR2_PACKAGE_JANSSON),y)
> +UWSGI_DEPENDENCIES += jansson
> +UWSGI_INI_OPTS += "json:jansson"
> +else
> +UWSGI_DEPENDENCIES += yajl
> +UWSGI_INI_OPTS += "json:yajl"
> +endif
> +endif
> +
> +ifeq ($(BR2_PACKAGE_UWSGI_PLUGINS_SSL),y)
> +UWSGI_DEPENDENCIES += openssl
> +UWSGI_INI_OPTS += "ssl:true"
> +endif
> +
> +ifeq ($(BR2_PACKAGE_UWSGI_PLUGINS_XML),y)
> +ifeq ($(BR2_PACKAGE_LIBXML2),y)
> +UWSGI_DEPENDENCIES += libxml2
> +UWSGI_INI_OPTS += "xml:libxml2"
> +UWSGI_ENV += XML2_CONFIG="$(STAGING_DIR)/usr/bin/xml2-config"
> +else
> +UWSGI_DEPENDENCIES += expat
> +UWSGI_INI_OPTS += "xml:expat"
> +endif
> +endif
> +
> +ifeq ($(BR2_PACKAGE_UWSGI_PLUGINS_YAML),y)
> +UWSGI_DEPENDENCIES += libyaml
> +UWSGI_INI_OPTS += "yaml:libyaml"
> +endif
> +
> +define UWSGI_SETUP_PROFILE
> +	mkdir -p $(TARGET_DIR)/usr/lib/uwsgi
> +
> +	$(INSTALL) -D -m 755 $(UWSGI_PKGDIR)/buildroot.ini.in \
> +		$(@D)/buildroot.ini
> +
> +	$(foreach f,$(UWSGI_INI_OPTS), \
> +		$(eval option=$(shell echo $f | cut -d: -f 1)) \
> +		$(eval value=$(shell echo $f | cut -d: -f 2)) \
> +		$(SED) "s%$(option).*%$(option) = $(value)%g" $(@D)/buildroot.ini
> +	)
> +endef
> +UWSGI_POST_PATCH_HOOKS = UWSGI_SETUP_PROFILE
> +
> +define UWSGI_BUILD_CMDS
> +	cd $(@D); \
> +	$(TARGET_MAKE_ENV) $(UWSGI_ENV) $(HOST_DIR)/bin/python3 \
> +		./setup.py build
> +endef
> +
> +define UWSGI_INSTALL_TARGET_CMDS
> +	cd $(@D); \
> +	$(TARGET_MAKE_ENV) $(UWSGI_ENV) $(HOST_DIR)/bin/python3 \
> +		./setup.py install $(PKG_PYTHON_SETUPTOOLS_INSTALL_TARGET_OPTS)
> +endef
> +
> +$(eval $(generic-package))
> -- 
> 2.23.0
> 
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Buildroot] [PATCH v2 1/3] uwsgi: new package
  2019-11-23 20:20 [Buildroot] [PATCH v2 0/3] " aduskett at gmail.com
@ 2019-11-23 20:20 ` aduskett at gmail.com
  2020-02-04 12:54   ` Yann E. MORIN
  0 siblings, 1 reply; 7+ messages in thread
From: aduskett at gmail.com @ 2019-11-23 20:20 UTC (permalink / raw)
  To: buildroot

From: Adam Duskett <Aduskett@gmail.com>

The uWSGI project aims at developing a full stack for building hosting services.
Application servers (for various programming languages and protocols), proxies,
process managers and monitors are all implemented using a common API and a
standard configuration style. Thanks to its pluggable architecture, it can be
extended to support more platforms and languages.

There are five patches currently required to properly cross-compile uWSGI, all
but one of which are pending upstream:

1) add-plugin_base_dir-variable.patch
  - uWSGI appends the full path of the plugin directory to the binary when
    compiling, which results in plugins failing to load on the target filing
    system.

2) add-a-xml2_config-environment-variable-for-cross-co.patch
  - uWSGI calls out to xml2-config with no way to define a path for xml2-config,
    thus resulting in the hosts xml2-config cflags and library paths used, add
    the XML2_CONFIG environment variable which overwrites the default
    xml2-config path.

3) add-a-pcre_config-environment-variable-for-cross-co.patch
  - This patch is the same as the above, except the variable name is
    PCRE_CONFIG.

4) adjust-python-library-header-paths-for-cross-compila.patch
  - uWSGI calls sysconfig.get_config_var('LIBDIR') which return the host header
    and library paths. To fix this, prefix the LIBDIR path with _python_sysroot
    taken from the sysconfigdata module.

5) fix-building-with-uClibc.patch
  - There are two issues building uwsgi with uClibc:
    1) core/uwsgi.c includes <execinfo.h> when __GLIBC__  is defined, but does
       not check if __UCLIBC__ is also defined.
    2) plugins/router_basicauth/router_basicauth.c checks if __GLIBC__ is
       defined for <crypt.h> and to enable a workaround for a bug in
       Glibc-2.2.5, both of which do not apply to uClibc. Adding a check for
       __UCLIBC__ for both of these conditions fixes the issue.

Even though PCRE is not technically required, the official documentation
recommends always building with PCRE support, and many of the embedded plugins
require PCRE to be present. As such, PCRE is set as a dependency.
https://uwsgi-docs.readthedocs.io/en/latest/SNI.html?highlight=sni-regexp

The "Main application type" prompt in the Config.in is to set the main_plugin
variable in the buildroot.ini file.

There is a "buildroot.ini.in" file which is used to overwrite the default
settings in buildconf/base.ini. The following settings that explicitly set:
 - json: Allow a config file to be in JSON format
 - pcre: Explicitly set to True
 - ssl: Allow SSL connections
 - xml: Allow a config file to be in XML format.
 - yaml: Allow a config file to be in YAML format.
 - main_plugin: Set to Python.
 - plugin_dir: The plugin directory for the target.

The .ini file does not have a standard value for each option; because of this,
each option is a key/value pair with a colon set as a delimiter. A for loop
set's each setting appropriately by splitting the key/value into two variables
and running SED against the .ini file.

Tested with every option enabled:

br-arm-full [1/6]: OK
br-arm-cortex-a9-glibc [2/6]: OK
br-arm-cortex-m4-full [3/6]: SKIPPED
br-x86-64-musl [4/6]: OK
br-arm-full-static [5/6]: SKIPPED
sourcery-arm [6/6]: OK

Signed-off-by: Adam Duskett <Aduskett@gmail.com>
---
 DEVELOPERS                                    |   1 +
 package/Config.in                             |   1 +
 .../0001-add-plugin_base_dir-variable.patch   |  47 ++++++++
 ...ig-environment-variable-for-cross-co.patch |  60 +++++++++++
 ...ig-environment-variable-for-cross-co.patch |  58 ++++++++++
 ...brary-header-paths-for-cross-compila.patch |  34 ++++++
 .../uwsgi/0005-fix-building-with-uClibc.patch |  61 +++++++++++
 package/uwsgi/Config.in                       |  65 ++++++++++++
 package/uwsgi/buildroot.ini.in                |   9 ++
 package/uwsgi/uwsgi.hash                      |   3 +
 package/uwsgi/uwsgi.mk                        | 100 ++++++++++++++++++
 11 files changed, 439 insertions(+)
 create mode 100644 package/uwsgi/0001-add-plugin_base_dir-variable.patch
 create mode 100644 package/uwsgi/0002-add-a-xml2_config-environment-variable-for-cross-co.patch
 create mode 100644 package/uwsgi/0003-add-a-pcre_config-environment-variable-for-cross-co.patch
 create mode 100644 package/uwsgi/0004-adjust-python-library-header-paths-for-cross-compila.patch
 create mode 100644 package/uwsgi/0005-fix-building-with-uClibc.patch
 create mode 100644 package/uwsgi/Config.in
 create mode 100644 package/uwsgi/buildroot.ini.in
 create mode 100644 package/uwsgi/uwsgi.hash
 create mode 100644 package/uwsgi/uwsgi.mk

diff --git a/DEVELOPERS b/DEVELOPERS
index 991be89849..19fbf6254d 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -74,6 +74,7 @@ F:	package/semodule-utils/
 F:	package/setools/
 F:	package/sngrep/
 F:	package/systemd/
+F:	package/uwsgi/
 
 N:	Adam Heinrich <adam@adamh.cz>
 F:	package/jack1/
diff --git a/package/Config.in b/package/Config.in
index f72c77b416..53a01fbe08 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -2129,6 +2129,7 @@ endif
 	source "package/vpnc/Config.in"
 	source "package/vsftpd/Config.in"
 	source "package/vtun/Config.in"
+	source "package/uwsgi/Config.in"
 	source "package/wavemon/Config.in"
 	source "package/wget/Config.in"
 	source "package/whois/Config.in"
diff --git a/package/uwsgi/0001-add-plugin_base_dir-variable.patch b/package/uwsgi/0001-add-plugin_base_dir-variable.patch
new file mode 100644
index 0000000000..ace1df09a4
--- /dev/null
+++ b/package/uwsgi/0001-add-plugin_base_dir-variable.patch
@@ -0,0 +1,47 @@
+From 2b15d1c4d48a431a92d76486818a84d9653e549b Mon Sep 17 00:00:00 2001
+From: Adam Duskett <Adamduskett@outlook.com>
+Date: Mon, 29 Jan 2018 11:40:52 -0500
+Subject: [PATCH] add plugin_base_dir variable
+
+Currently, when cross-compiling, if the plugin_dir points to the target
+directory, uwsgi will embed the full path during compiling.
+This whole path results in uwsgi trying to load a full target path instead of
+/usr/lib/uwsgi when running on the target.
+
+Creating a new PLUGIN_BASE_DIR variable and prefixing plugin_dir allows the
+plugin to be installed to the appropriate directory but still have uwsgi load
+the plugins from the correct folder when ran from on the cross-compiled target.
+
+Current status: Pending
+https://github.com/unbit/uwsgi/pull/2052
+
+Signed-off-by: Adam Duskett <Adamduskett@outlook.com>
+---
+ uwsgiconfig.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/uwsgiconfig.py b/uwsgiconfig.py
+index 0c33491..5b356ec 100644
+--- a/uwsgiconfig.py
++++ b/uwsgiconfig.py
+@@ -27,7 +27,7 @@ try:
+ except:
+     import configparser as ConfigParser
+ 
+-
++PLUGIN_BASE_DIR = os.environ.get('PLUGIN_BASE_DIR', '')
+ PY3 = sys.version_info[0] == 3
+ 
+ if uwsgi_os == 'Darwin':
+@@ -1435,7 +1435,7 @@ def build_plugin(path, uc, cflags, ldflags, libs, name = None):
+         pass
+ 
+     if uc:
+-        plugin_dest = uc.get('plugin_build_dir', uc.get('plugin_dir')) + '/' + name + '_plugin'
++        plugin_dest = PLUGIN_BASE_DIR + uc.get('plugin_build_dir', uc.get('plugin_dir')) + '/' + name + '_plugin'
+     else:
+         plugin_dest = name + '_plugin'
+ 
+-- 
+2.14.3
+
diff --git a/package/uwsgi/0002-add-a-xml2_config-environment-variable-for-cross-co.patch b/package/uwsgi/0002-add-a-xml2_config-environment-variable-for-cross-co.patch
new file mode 100644
index 0000000000..014494e5cb
--- /dev/null
+++ b/package/uwsgi/0002-add-a-xml2_config-environment-variable-for-cross-co.patch
@@ -0,0 +1,60 @@
+From b98241acc633396dc7f4ab9e4153af552ac6d4a0 Mon Sep 17 00:00:00 2001
+From: Adam Duskett <Aduskett@gmail.com>
+Date: Sat, 3 Aug 2019 14:59:18 -0400
+Subject: [PATCH] add a XML2_CONFIG environment variable for cross-compiling
+
+Currently, xml2-config is called out with no way to define an xml2-config path,
+which causes uwsgi to use the host xml2-config which will cause the xml2
+library and CFlag directories to point to the host instead of
+the cross-environment.
+
+Add a check for the XML2_CONFIG environment variable, and if it exists, use the
+resulting path instead.
+
+Current-status: pending
+https://github.com/unbit/uwsgi/pull/2050
+
+Signed-off-by: Adam Duskett <aduskett@gmail.com>
+---
+ uwsgiconfig.py | 9 +++++----
+ 1 file changed, 5 insertions(+), 4 deletions(-)
+
+diff --git a/uwsgiconfig.py b/uwsgiconfig.py
+index 22c9dd3..26403f1 100644
+--- a/uwsgiconfig.py
++++ b/uwsgiconfig.py
+@@ -1303,12 +1303,13 @@ class uConf(object):
+                 self.gcc_list.append('core/legion')
+                 report['ssl'] = True
+ 
++        xml2config = os.environ.get('XML2_CONFIG','xml2-config')
+         if self.get('xml'):
+             if self.get('xml') == 'auto':
+-                xmlconf = spcall('xml2-config --libs')
++                xmlconf = spcall(xml2config + ' --libs')
+                 if xmlconf and uwsgi_os != 'Darwin':
+                     self.libs.append(xmlconf)
+-                    xmlconf = spcall("xml2-config --cflags")
++                    xmlconf = spcall(xml2config + " --cflags")
+                     self.cflags.append(xmlconf)
+                     self.cflags.append("-DUWSGI_XML -DUWSGI_XML_LIBXML2")
+                     self.gcc_list.append('core/xmlconf')
+@@ -1319,13 +1320,13 @@ class uConf(object):
+                     self.gcc_list.append('core/xmlconf')
+                     report['xml'] = 'expat'
+             elif self.get('xml') == 'libxml2':
+-                xmlconf = spcall('xml2-config --libs')
++                xmlconf = spcall(xml2config + ' --libs')
+                 if xmlconf is None:
+                     print("*** libxml2 headers unavailable. uWSGI build is interrupted. You have to install libxml2 development package or use libexpat or disable XML")
+                     sys.exit(1)
+                 else:
+                     self.libs.append(xmlconf)
+-                    xmlconf = spcall("xml2-config --cflags")
++                    xmlconf = spcall(xml2config + " --cflags")
+                     if xmlconf is None:
+                         print("*** libxml2 headers unavailable. uWSGI build is interrupted. You have to install libxml2 development package or use libexpat or disable XML")
+                         sys.exit(1)
+-- 
+2.21.0
+
diff --git a/package/uwsgi/0003-add-a-pcre_config-environment-variable-for-cross-co.patch b/package/uwsgi/0003-add-a-pcre_config-environment-variable-for-cross-co.patch
new file mode 100644
index 0000000000..88fca366b4
--- /dev/null
+++ b/package/uwsgi/0003-add-a-pcre_config-environment-variable-for-cross-co.patch
@@ -0,0 +1,58 @@
+From 170cbd7226c1a0774da3c19733c2f473befc8eed Mon Sep 17 00:00:00 2001
+From: Adam Duskett <Aduskett@gmail.com>
+Date: Sat, 3 Aug 2019 15:32:41 -0400
+Subject: [PATCH] Add a PCRE_CONFIG environment variable for cross-compiling
+
+Currently, pcre-config is called out with no way to define a pcre-config path,
+which causes uwsgi to use the host pcre-config, which will cause the pcre
+library and cflag directories to point to the host.
+
+Add a check for the PCRE_CONFIG environment variable, and if it exists,
+use the resulting path instead.
+
+upstream-status: pending
+https://github.com/unbit/uwsgi/pull/2051
+
+Signed-off-by: Adam Duskett <Aduskett@gmail.com>
+---
+ uwsgiconfig.py | 9 +++++----
+ 1 file changed, 5 insertions(+), 4 deletions(-)
+
+diff --git a/uwsgiconfig.py b/uwsgiconfig.py
+index 26403f1..b800cdb 100644
+--- a/uwsgiconfig.py
++++ b/uwsgiconfig.py
+@@ -1072,25 +1072,26 @@ class uConf(object):
+         has_pcre = False
+ 
+         # re-enable after pcre fix
++        pcreconfig = os.environ.get('PCRE_CONFIG','pcre-config')
+         if self.get('pcre'):
+             if self.get('pcre') == 'auto':
+-                pcreconf = spcall('pcre-config --libs')
++                pcreconf = spcall(pcreconfig + ' --libs')
+                 if pcreconf:
+                     self.libs.append(pcreconf)
+-                    pcreconf = spcall("pcre-config --cflags")
++                    pcreconf = spcall(pcreconfig + ' --cflags')
+                     self.cflags.append(pcreconf)
+                     self.gcc_list.append('core/regexp')
+                     self.cflags.append("-DUWSGI_PCRE")
+                     has_pcre = True
+ 
+             else:
+-                pcreconf = spcall('pcre-config --libs')
++                pcreconf = spcall(pcreconfig + ' --libs')
+                 if pcreconf is None:
+                     print("*** libpcre headers unavailable. uWSGI build is interrupted. You have to install pcre development package or disable pcre")
+                     sys.exit(1)
+                 else:
+                     self.libs.append(pcreconf)
+-                    pcreconf = spcall("pcre-config --cflags")
++                    pcreconf = spcall(pcreconfig + ' --cflags')
+                     self.cflags.append(pcreconf)
+                     self.gcc_list.append('core/regexp')
+                     self.cflags.append("-DUWSGI_PCRE")
+-- 
+2.21.0
+
diff --git a/package/uwsgi/0004-adjust-python-library-header-paths-for-cross-compila.patch b/package/uwsgi/0004-adjust-python-library-header-paths-for-cross-compila.patch
new file mode 100644
index 0000000000..9eb39b1212
--- /dev/null
+++ b/package/uwsgi/0004-adjust-python-library-header-paths-for-cross-compila.patch
@@ -0,0 +1,34 @@
+From 8bf43f727d34619773d826357f49e172876f8a30 Mon Sep 17 00:00:00 2001
+From: Adam Duskett <Aduskett@gmail.com>
+Date: Sat, 3 Aug 2019 17:12:09 -0400
+Subject: [PATCH] Adjust python library/header paths for cross-compilation
+
+uWSGI calls sysconfig.get_config_var('LIBDIR') which return the host header and
+library paths.
+
+To fix this, prefix the LIBDIR path with _python_sysroot taken
+from the sysconfigdata module.
+
+upstream status: Not submitted, Buildroot specific.
+
+Signed-off-by: Adam Duskett <Aduskett@gmail.com>
+---
+ plugins/python/uwsgiplugin.py | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/plugins/python/uwsgiplugin.py b/plugins/python/uwsgiplugin.py
+index 843876f..a74de7d 100644
+--- a/plugins/python/uwsgiplugin.py
++++ b/plugins/python/uwsgiplugin.py
+@@ -52,6 +52,8 @@ if not 'UWSGI_PYTHON_NOLIB' in os.environ:
+     else:
+         try:
+             libdir = sysconfig.get_config_var('LIBDIR')
++            if "_python_sysroot" in os.environ:
++                libdir = os.environ.get("_python_sysroot") + libdir
+         except:
+             libdir = "%s/lib" % sysconfig.PREFIX
+ 
+-- 
+2.21.0
+
diff --git a/package/uwsgi/0005-fix-building-with-uClibc.patch b/package/uwsgi/0005-fix-building-with-uClibc.patch
new file mode 100644
index 0000000000..1f546fa412
--- /dev/null
+++ b/package/uwsgi/0005-fix-building-with-uClibc.patch
@@ -0,0 +1,61 @@
+From 98c616be6bb745cc5178de3b1a3a84d1f86d6e34 Mon Sep 17 00:00:00 2001
+From: Adam Duskett <Aduskett@gmail.com>
+Date: Wed, 7 Aug 2019 15:10:46 -0400
+Subject: [PATCH] fix building with uClibc
+
+There are two issues building uwsgi with uClibc:
+1) core/uwsgi.c includes <execinfo.h> when __GLIBC__  is defined, but does not
+check if __UCLIBC__ is also defined.
+
+2) plugins/router_basicauth/router_basicauth.c checks if __GLIBC__ is defined
+for <crypt.h> and to enable a workaround for a bug in glibc-2.2.5, both of which
+do not apply to uClibc.
+Add a check for __UCLIBC__ for both of these conditions.
+
+Upstream status: Merged.
+https://github.com/unbit/uwsgi/pull/2054
+
+Signed-off-by: Adam Duskett <Aduskett@gmail.com>
+---
+ core/uwsgi.c                                | 2 +-
+ plugins/router_basicauth/router_basicauth.c | 4 ++--
+ 2 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/core/uwsgi.c b/core/uwsgi.c
+index ef9e310..523bf45 100644
+--- a/core/uwsgi.c
++++ b/core/uwsgi.c
+@@ -1820,7 +1820,7 @@ void uwsgi_plugins_atexit(void) {
+ 
+ void uwsgi_backtrace(int depth) {
+ 
+-#if defined(__GLIBC__) || (defined(__APPLE__) && !defined(NO_EXECINFO)) || defined(UWSGI_HAS_EXECINFO)
++#if (!defined(__UCLIBC__) && defined __GLIBC__) || (defined(__APPLE__) && !defined(NO_EXECINFO)) || defined(UWSGI_HAS_EXECINFO)
+ 
+ #include <execinfo.h>
+ 
+diff --git a/plugins/router_basicauth/router_basicauth.c b/plugins/router_basicauth/router_basicauth.c
+index 429bade..0b7161e 100644
+--- a/plugins/router_basicauth/router_basicauth.c
++++ b/plugins/router_basicauth/router_basicauth.c
+@@ -3,7 +3,7 @@
+ #ifdef UWSGI_ROUTING
+ 
+ // TODO: Add more crypt_r supported platfroms here
+-#if defined(__linux__) && defined(__GLIBC__)
++#if defined(__linux__) && defined(__GLIBC__) && !defined(__UCLIBC__)
+ #include <crypt.h>
+ #elif defined(__CYGWIN__)
+ #include <crypt.h>
+@@ -67,7 +67,7 @@ static uint16_t htpasswd_check(char *filename, char *auth) {
+ 
+ 		if (clen > 13) cpwd[13] = 0;
+ 
+-#if defined(__linux__) && defined(__GLIBC__)
++#if defined(__linux__) && defined(__GLIBC__) && !defined(__UCLIBC__)
+ 		struct crypt_data cd;
+ 		memset(&cd, 0, sizeof(struct crypt_data));
+     /* work around glibc-2.2.5 bug,
+-- 
+2.21.0
+
diff --git a/package/uwsgi/Config.in b/package/uwsgi/Config.in
new file mode 100644
index 0000000000..f0de3093a4
--- /dev/null
+++ b/package/uwsgi/Config.in
@@ -0,0 +1,65 @@
+menuconfig BR2_PACKAGE_UWSGI
+	bool "uwsgi"
+	depends on !BR2_STATIC_LIBS # dlfcn.h
+	depends on BR2_USE_MMU # python
+	depends on BR2_USE_WCHAR # python
+	depends on BR2_TOOLCHAIN_HAS_THREADS # python
+	# While it's possible to build uwsgi without PCRE, it would require not to
+	# build Python or PHP or several of the embedded plugins.
+	# The official documentation also recommends building PCRE support.
+	# https://uwsgi-docs.readthedocs.io/en/latest/SNI.html?highlight=sni-regexp
+	select BR2_PACKAGE_PCRE
+	select BR2_PACKAGE_PYTHON3 if !BR2_PACKAGE_PYTHON
+	help
+	  The uWSGI server.
+	  The uWSGI project aims at developing a full stack for
+	  building hosting services. Application servers
+	  (for various programming languages and protocols), proxies,
+	  process managers and monitors are all implemented using a
+	  common API and a standard configuration style. Thanks to
+	  its pluggable architecture, it can be extended to support
+	  more platforms and languages.
+
+	  https://uwsgi-docs.readthedocs.io/en/latest/
+
+if BR2_PACKAGE_UWSGI
+
+comment "plugins"
+
+config BR2_PACKAGE_UWSGI_PLUGINS_CAPABILITIES
+	bool "POSIX capability support"
+	select BR2_PACKAGE_LIBCAP
+	help
+	  POSIX capabilities allow fine-grained permissions for
+	  processes. In addition to the standard UNIX permission scheme,
+	  they define a new set of privileges for system resources.
+
+config BR2_PACKAGE_UWSGI_PLUGINS_JSON
+	bool "JSON"
+	select BR2_PACKAGE_JANSSON if !BR2_PACKAGE_YAJL
+	help
+	  Load the config from a json file.
+
+config BR2_PACKAGE_UWSGI_PLUGINS_SSL
+	bool "SSL"
+	select BR2_PACKAGE_OPENSSL
+	help
+	  SSL Support
+
+config BR2_PACKAGE_UWSGI_PLUGINS_XML
+	bool "XML"
+	select BR2_PACKAGE_LIBXML2 if !BR2_PACKAGE_EXPAT
+	help
+	  Load the config from a XML file.
+
+config BR2_PACKAGE_UWSGI_PLUGINS_YAML
+	bool "YAML"
+	select BR2_PACKAGE_LIBYAML
+	help
+	  Load the config from a YAML file.
+
+endif
+
+comment "uwsgi needs a toolchain w/ dynamic library, wchar, threads"
+	depends on BR2_USE_MMU
+	depends on !BR2_USE_WCHAR || !BR2_TOOLCHAIN_HAS_THREADS || BR2_STATIC_LIBS
diff --git a/package/uwsgi/buildroot.ini.in b/package/uwsgi/buildroot.ini.in
new file mode 100644
index 0000000000..75ad8afa32
--- /dev/null
+++ b/package/uwsgi/buildroot.ini.in
@@ -0,0 +1,9 @@
+[uwsgi]
+inherit = base
+json = false
+pcre = true
+ssl = false
+xml = false
+yaml = false
+main_plugin = python
+plugin_dir = /usr/lib/uwsgi
diff --git a/package/uwsgi/uwsgi.hash b/package/uwsgi/uwsgi.hash
new file mode 100644
index 0000000000..bbdfe3b9ea
--- /dev/null
+++ b/package/uwsgi/uwsgi.hash
@@ -0,0 +1,3 @@
+# Locally computed
+sha256	4972ac538800fb2d421027f49b4a1869b66048839507ccf0aa2fda792d99f583  uwsgi-2.0.18.tar.gz
+sha256	ca495399f5da3ce2724649b47eb118f7549344ba58c0cf350d94c3390e435897  LICENSE
diff --git a/package/uwsgi/uwsgi.mk b/package/uwsgi/uwsgi.mk
new file mode 100644
index 0000000000..add75c04b9
--- /dev/null
+++ b/package/uwsgi/uwsgi.mk
@@ -0,0 +1,100 @@
+################################################################################
+#
+# uwsgi
+#
+################################################################################
+
+UWSGI_VERSION = 2.0.18
+UWSGI_SITE = $(call github,unbit,uwsgi,$(UWSGI_VERSION))
+UWSGI_LICENSE = GPL-2.0+
+UWSGI_LICENSE_FILES = LICENSE
+UWSGI_DEPENDENCIES += pcre
+
+UWSGI_ENV += \
+	CC="$(TARGET_CC)" \
+	UWSGI_REMOVE_INCLUDES="/usr/include,/usr/local/include" \
+	UWSGI_INCLUDES="$(STAGING_DIR)/usr/include" \
+	PLUGIN_BASE_DIR="$(TARGET_DIR)" \
+	PCRE_CONFIG="$(STAGING_DIR)/usr/bin/pcre-config" \
+	UWSGI_PROFILE=$(@D)/buildroot.ini \
+	PYTHON_LIBDIR="$(STAGING_DIR)/usr/lib"
+
+ifeq ($(BR2_PACKAGE_PYTHON),y)
+UWSGI_DEPENDENCIES += host-python host-python-setuptools python
+else
+UWSGI_DEPENDENCIES += host-python3 host-python3-setuptools python3
+endif
+
+ifeq ($(BR2_PACKAGE_LIBZLIB),y)
+UWSGI_DEPENDENCIES += libzlib
+endif
+
+ifeq ($(BR2_PACKAGE_UTIL_LINUX_LIBUUID),y)
+UWSGI_DEPENDENCIES += util-linux
+endif
+
+# Plugins
+ifeq ($(BR2_PACKAGE_UWSGI_PLUGINS_CAPABILITIES),y)
+UWSGI_DEPENDENCIES += libcap
+endif
+
+# The uwsgi config.ini file does not use the same values for every option.
+# Use a key/value with a colon as a delimiter to set the appropriate setting.
+ifeq ($(BR2_PACKAGE_UWSGI_PLUGINS_JSON),y)
+ifeq ($(BR2_PACKAGE_JANSSON),y)
+UWSGI_DEPENDENCIES += jansson
+UWSGI_INI_OPTS += "json:jansson"
+else
+UWSGI_DEPENDENCIES += yajl
+UWSGI_INI_OPTS += "json:yajl"
+endif
+endif
+
+ifeq ($(BR2_PACKAGE_UWSGI_PLUGINS_SSL),y)
+UWSGI_DEPENDENCIES += openssl
+UWSGI_INI_OPTS += "ssl:true"
+endif
+
+ifeq ($(BR2_PACKAGE_UWSGI_PLUGINS_XML),y)
+ifeq ($(BR2_PACKAGE_LIBXML2),y)
+UWSGI_DEPENDENCIES += libxml2
+UWSGI_INI_OPTS += "xml:libxml2"
+UWSGI_ENV += XML2_CONFIG="$(STAGING_DIR)/usr/bin/xml2-config"
+else
+UWSGI_DEPENDENCIES += expat
+UWSGI_INI_OPTS += "xml:expat"
+endif
+endif
+
+ifeq ($(BR2_PACKAGE_UWSGI_PLUGINS_YAML),y)
+UWSGI_DEPENDENCIES += libyaml
+UWSGI_INI_OPTS += "yaml:libyaml"
+endif
+
+define UWSGI_SETUP_PROFILE
+	mkdir -p $(TARGET_DIR)/usr/lib/uwsgi
+
+	$(INSTALL) -D -m 755 $(UWSGI_PKGDIR)/buildroot.ini.in \
+		$(@D)/buildroot.ini
+
+	$(foreach f,$(UWSGI_INI_OPTS), \
+		$(eval option=$(shell echo $f | cut -d: -f 1)) \
+		$(eval value=$(shell echo $f | cut -d: -f 2)) \
+		$(SED) "s%$(option).*%$(option) = $(value)%g" $(@D)/buildroot.ini
+	)
+endef
+UWSGI_POST_PATCH_HOOKS = UWSGI_SETUP_PROFILE
+
+define UWSGI_BUILD_CMDS
+	cd $(@D); \
+	$(TARGET_MAKE_ENV) $(UWSGI_ENV) $(HOST_DIR)/bin/python3 \
+		./setup.py build
+endef
+
+define UWSGI_INSTALL_TARGET_CMDS
+	cd $(@D); \
+	$(TARGET_MAKE_ENV) $(UWSGI_ENV) $(HOST_DIR)/bin/python3 \
+		./setup.py install $(PKG_PYTHON_SETUPTOOLS_INSTALL_TARGET_OPTS)
+endef
+
+$(eval $(generic-package))
-- 
2.23.0

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-02-04 12:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-02 14:05 [Buildroot] [PATCH v2 1/3] uwsgi: new package Adam Duskett
2018-02-02 14:06 ` [Buildroot] [PATCH v2 2/3] php: add SAPI API librari option Adam Duskett
2018-02-02 14:06 ` [Buildroot] [PATCH v2 3/3] uwsgi: add plugin support Adam Duskett
2018-05-20 21:46 ` [Buildroot] [PATCH v2 1/3] uwsgi: new package Thomas Petazzoni
2018-05-20 21:50 ` Thomas Petazzoni
2019-11-23 20:20 [Buildroot] [PATCH v2 0/3] " aduskett at gmail.com
2019-11-23 20:20 ` [Buildroot] [PATCH v2 1/3] " aduskett at gmail.com
2020-02-04 12:54   ` Yann E. MORIN

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.