Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Adam Duskett <aduskett@gmail.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH v2 3/3] uwsgi: add plugin support
Date: Fri,  2 Feb 2018 09:06:01 -0500	[thread overview]
Message-ID: <20180202140601.21285-3-aduskett@gmail.com> (raw)
In-Reply-To: <20180202140601.21285-1-aduskett@gmail.com>

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

  parent reply	other threads:[~2018-02-02 14:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2018-05-20 21:46 ` [Buildroot] [PATCH v2 1/3] uwsgi: new package Thomas Petazzoni
2018-05-20 21:50 ` Thomas Petazzoni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180202140601.21285-3-aduskett@gmail.com \
    --to=aduskett@gmail.com \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox