uwsgi: new package
cover uwsgi: new package
From: Adam Duskett <[email protected]>
This patch series is reasonably substantial. Below I have documented my thoughts.
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.
The first patch set's the package directly as a python package because the main application is hard-coded to Python (This is the most common use case as far as I can tell.)
The second patch allows a user to force building the libphp7.so file from PHP. This is necessary to enable PHP as the main application for uWSGI.
The third and final patch changes the package to a dual-type. The first being generic if the application type isn't Python and the second as a python-type package. This change saves a substantial amount of space and build time if the user isn't using uWSGI as a Python server.
The package itself requires Python to configure, build, and install, but it is not required to run, as such, this package is defined as a generic-package. Defining uWSGI as a generic package saves 29M of space with a Glibc target filing system (52M vs. 23M.) If however, the primary application type is Python, then the package is better suited to be a python-package because there is no longer any space saved, as Python is now on the target and staging directories.
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.
While 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 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. The main application plugin sets several dependencies, and this patchset includes support for PHP and Python. Other application types can be added in the future.
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: 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: The main plugin application type.
- 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, with both PHP and Python set as the main application type:
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
Adam Duskett (3):
uwsgi: new package
package/php: add option to force building the shared library package/uwsgi: Add support for application types
DEVELOPERS | 1 + package/Config.in | 1 + package/php/Config.in | 9 ++ package/php/php.mk | 4 + .../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 | 94 ++++++++++++++ package/uwsgi/buildroot.ini.in | 9 ++ package/uwsgi/uwsgi.hash | 3 + package/uwsgi/uwsgi.mk | 120 ++++++++++++++++++ 13 files changed, 501 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
Signature · 1 line
2.21.0
PATCH 1/3 uwsgi: new package
From: Adam Duskett <[email protected]>
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
--- 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 | 88 +++++++++++++++++++ 11 files changed, 427 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
DEVELOPERS +1 -0
@@ -70,6 +70,7 @@ F: package/semodule-utils/ F: package/setools/ F: package/sngrep/ F: package/systemd/ +F: package/uwsgi/ N: Adam Heinrich <[email protected]> F: package/jack1/
package/Config.in +1 -0
@@ -2094,6 +2094,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"
package/uwsgi/0001-add-plugin_base_dir-variable.patch new file +47 -0
47 lines not on this page · raw message
package/uwsgi/0002-add-a-xml2_config-environment-variable-for-cross-co.patch new file +60 -0
60 lines not on this page · raw message
package/uwsgi/0003-add-a-pcre_config-environment-variable-for-cross-co.patch new file +58 -0
58 lines not on this page · raw message
package/uwsgi/0004-adjust-python-library-header-paths-for-cross-compila.patch new file +34 -0
@@ -0,0 +1,34 @@ +From 8bf43f727d34619773d826357f49e172876f8a30 Mon Sep 17 00:00:00 2001 +From: Adam Duskett <[email protected]> +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 <[email protected]> +--- + 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 +
package/uwsgi/0005-fix-building-with-uClibc.patch new file +61 -0
61 lines not on this page · raw message
package/uwsgi/Config.in new file +65 -0
65 lines not on this page · raw message
package/uwsgi/buildroot.ini.in new file +9 -0
@@ -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
package/uwsgi/uwsgi.hash new file +3 -0
@@ -0,0 +1,3 @@ +# Locally computed +sha256 4972ac538800fb2d421027f49b4a1869b66048839507ccf0aa2fda792d99f583 uwsgi-2.0.18.tar.gz +sha256 ca495399f5da3ce2724649b47eb118f7549344ba58c0cf350d94c3390e435897 LICENSE
package/uwsgi/uwsgi.mk new file +87 -0
87 lines not on this page · raw message
Signature · 1 line
2.21.0
PATCH 2/3 package/php: add option to force building the shared library
In reply to aduskett at gmail.comFrom: Adam Duskett <[email protected]>
The uWSGI plugin requires libphp7.so to build. This option forces PHP to build the libphp7.so file.
--- package/php/Config.in | 9 +++++++++ package/php/php.mk | 4 ++++ 2 files changed, 13 insertions(+)
package/php/Config.in +9 -0
@@ -19,6 +19,15 @@ config BR2_PACKAGE_PHP if BR2_PACKAGE_PHP +config BR2_PACKAGE_PHP_BUILD_SHARED_LIBRARY + bool "Build the shared library" + depends on !BR2_STATIC_LIBS + help + Build the libphp7.so file. + +comment "Building the shared library needs a toolchain w/ dynamic library" + depends on BR2_STATIC_LIBS + config BR2_PACKAGE_PHP_SAPI_APACHE bool "Apache interface" depends on BR2_PACKAGE_APACHE
package/php/php.mk +4 -0
@@ -121,6 +121,10 @@ PHP_CONF_OPTS += \ $(if $(BR2_PACKAGE_PHP_EXT_MBSTRING),--enable-mbstring) \ $(if $(BR2_PACKAGE_PHP_EXT_PHAR),--enable-phar) +ifeq ($(BR2_PACKAGE_PHP_BUILD_SHARED_LIBRARY),y) +PHP_CONF_OPTS += --enable-embed=shared +endif + ifeq ($(BR2_PACKAGE_PHP_EXT_MCRYPT),y) PHP_CONF_OPTS += --with-mcrypt=$(STAGING_DIR)/usr PHP_DEPENDENCIES += libmcrypt
Signature · 1 line
2.21.0
PATCH 3/3 package/uwsgi: add support for application types
In reply to aduskett at gmail.comFrom: Adam Duskett <[email protected]>
uWSGI supports many different application types; two everyday use cases are Python and PHP.
uWSGI requires Python to configure, build, and install, but it is not necessary to run. Setting the package type to generic saves upwards of 29M of space with a Glibc target filing system (52M vs. 23M.) If however, the primary application type is Python, then the package is better suited to be a python-package because there is no longer any space saved, Python is now on the target and staging directories, and Buildroot can provide all of the necessary variables to compile the Python plugin.
The "Main application type" prompt in the Config.in sets the main_plugin variable in the buildroot.ini file.
--- package/uwsgi/Config.in | 45 +++++++++++++++++++++++++------ package/uwsgi/buildroot.ini.in | 2 +- package/uwsgi/uwsgi.mk | 48 ++++++++++++++++++++++++++++------ 3 files changed, 78 insertions(+), 17 deletions(-)
package/uwsgi/Config.in +37 -8
@@ -1,15 +1,11 @@ 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
@@ -24,7 +20,36 @@ menuconfig BR2_PACKAGE_UWSGI if BR2_PACKAGE_UWSGI -comment "plugins" +choice + prompt "Main application type" + default BR2_PACKAGE_UWSGI_APPLICATION_PHP + help + Select the application type + +config BR2_PACKAGE_UWSGI_APPLICATION_PHP + bool "PHP" + depends on !BR2_BINFMT_FLAT # PHP + select BR2_PACKAGE_PHP # runtime + select BR2_PACKAGE_PHP_BUILD_SHARED_LIBRARY # linking + help + Select this if your primary application is PHP based. + +config BR2_PACKAGE_UWSGI_APPLICATION_PYTHON + bool "Python" + depends on BR2_USE_MMU # python + depends on BR2_USE_WCHAR # python + depends on BR2_TOOLCHAIN_HAS_THREADS # python + select BR2_PACKAGE_PYTHON3 if !BR2_PACKAGE_PYTHON + help + Select this if your primary application is Python based. + +comment "uwsgi-python needs a toolchain w/ wchar, threads" + depends on BR2_USE_MMU + depends on !BR2_USE_WCHAR || !BR2_TOOLCHAIN_HAS_THREADS + +endchoice + +comment "plugins with external dependencies" config BR2_PACKAGE_UWSGI_PLUGINS_CAPABILITIES bool "POSIX capability support"
@@ -60,6 +85,10 @@ config BR2_PACKAGE_UWSGI_PLUGINS_YAML endif -comment "uwsgi-python 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 +config BR2_PACKAGE_UWSGI_MAIN_APPLICATION + string + default "php" if BR2_PACKAGE_UWSGI_APPLICATION_PHP + default "python" if BR2_PACKAGE_UWSGI_APPLICATION_PYTHON + +comment "uwsgi needs a toolchain w/ dynamic library" + depends on BR2_STATIC_LIBS
package/uwsgi/buildroot.ini.in +1 -1
@@ -5,5 +5,5 @@ pcre = true ssl = false xml = false yaml = false -main_plugin = python +main_plugin = #MAIN_PLUGIN# plugin_dir = /usr/lib/uwsgi
package/uwsgi/uwsgi.mk +42 -8
77 lines not on this page · raw message
Signature · 1 line
2.21.0