Skip to contentSkip to conversation

uwsgi: new package

PATCH New Adam Duskett 2 participants 5 messages Feb 2, 2018 – May 20, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/3 uwsgi: new package

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.

---
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
DEVELOPERS +1 -0
index 9048d45b16..2ddb4099fd 100644
@@ -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 <[email protected]>
 F:	package/libepoxy/
package/Config.in +1 -0
index 9a6b199f40..3eb4addf50 100644
@@ -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"
package/uwsgi/0001-Add-fallthrough-comments.patch new file +53 -0

53 lines not on this page · raw message

package/uwsgi/0002-fix-libxml2-paths.patch new file +54 -0

54 lines not on this page · raw message

package/uwsgi/0003-set-libdir-to-sysconfig-PREFIX.patch new file +32 -0
new file mode 100644
index 0000000000..b5881e80f5
@@ -0,0 +1,32 @@
+From 742e370cc7d9bb75b83805683a4cc0f92f72850b Mon Sep 17 00:00:00 2001
+From: Adam Duskett <[email protected]>
+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 <[email protected]>
+---
+ 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
+
package/uwsgi/Config.in new file +21 -0
new file mode 100644
index 0000000000..96e7bc13c2
@@ -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
package/uwsgi/uwsgi.hash new file +3 -0
new file mode 100644
index 0000000000..eca39a6484
@@ -0,0 +1,3 @@
+# Locally computed
+sha256	251f0670628ce9b9f4c2b4288a7ea921e2ddb3d5e886b6aa2358273573e6fdcf  uwsgi-2.0.15.tar.gz
+sha256	ca495399f5da3ce2724649b47eb118f7549344ba58c0cf350d94c3390e435897  LICENSE
package/uwsgi/uwsgi.mk new file +31 -0
new file mode 100644
index 0000000000..f63b37816e
@@ -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))
Signature · 1 line
2.14.3
#1 lore raw

PATCH v2 2/3 php: add SAPI API librari option

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.

---
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(+)
package/php/Config.in +7 -0
index 0fb80063af..d327d08366 100644
@@ -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
package/php/php.mk +8 -0
index 152ec7d780..511cdfa8cc 100644
@@ -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
Signature · 1 line
2.14.3
#2 lore raw

PATCH v2 3/3 uwsgi: add plugin support

In reply to Adam Duskett

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.

---
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
package/uwsgi/0004-add-plugin_base_dir-variable.patch new file +45 -0
new file mode 100644
index 0000000000..90e9f71bce
@@ -0,0 +1,45 @@
+From 2b15d1c4d48a431a92d76486818a84d9653e549b Mon Sep 17 00:00:00 2001
+From: Adam Duskett <[email protected]>
+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 <[email protected]>
+---
+ 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
+
package/uwsgi/Config.in +18 -1
index 96e7bc13c2..fa63842e72 100644
@@ -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 || \
package/uwsgi/buildroot.ini.in new file +6 -0
new file mode 100644
index 0000000000..b83e765f42
@@ -0,0 +1,6 @@
+[uwsgi]
+main_plugin =
+inherit = base
+embedded_plugins = null
+plugin_dir = /usr/lib/uwsgi
+plugins = 
package/uwsgi/uwsgi.mk +26 -1
index f63b37816e..6f063ca263 100644
@@ -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))
Signature · 1 line
2.14.3
#3 lore raw

PATCH v2 1/3 uwsgi: new package

In reply to Adam Duskett

Hello,

Quoted 5 lines · Adam Duskett

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:

Quoted 8 lines

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.

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

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
#4 lore raw

PATCH v2 1/3 uwsgi: new package

In reply to Adam Duskett

Hello,

Quoted 5 lines · Adam Duskett

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:

Quoted 8 lines

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.

A few minor nits below.

Quoted 1 line

+UWSGI_LICENSE = GPL2

This is not a valid SPDX license code.

package/uwsgi/uwsgi.mk line 28

Quoted 2 lines
package/uwsgi/uwsgi.mk new file +2 -0
+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

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