From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH next 2/2] package/luarocks: rework configuration file for per-package folders
Date: Mon, 19 Nov 2018 11:32:27 +0100 [thread overview]
Message-ID: <20181119103227.24726-3-thomas.petazzoni@bootlin.com> (raw)
In-Reply-To: <20181119103227.24726-1-thomas.petazzoni@bootlin.com>
Currently, luarocks.mk generates a configuration file with hardcoded
STAGING_DIR, TARGET_DIR, TARGET_CC, LUAROCKS_CFLAGS and TARGET_LDFLAGS
values. This is not compatible with per-package folders, where the
value of STAGING_DIR, TARGET_DIR, TARGET_CC and possibly
TARGET_CFLAGS/TARGET_LDFLAGS may be different from one package to the
other.
Based on input from Fran?ois Perrad, this commit:
- Ensures that the getenv() function can be used in the sandboxed
environment used when reading the Luarocks configuration file.
- Changes the Luarocks configuration file to use getenv() for the
appropriate variables. Since the contents of this file is not
fixed, it is no longer generated by luarocks.mk using a series of
'echo' but simply concatanated with the rest of the Luarocks
configuration file.
- Adjusts LUAROCKS_RUNV_ENV so that the necessary environment
variables are now passed.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
---
package/luarocks/0002-getenv-in-config.patch | 31 ++++++++++++++++++++
package/luarocks/luarocks-br-config.lua | 12 ++++++++
package/luarocks/luarocks.mk | 21 +++++--------
3 files changed, 51 insertions(+), 13 deletions(-)
create mode 100644 package/luarocks/0002-getenv-in-config.patch
create mode 100644 package/luarocks/luarocks-br-config.lua
diff --git a/package/luarocks/0002-getenv-in-config.patch b/package/luarocks/0002-getenv-in-config.patch
new file mode 100644
index 0000000000..9113724dfd
--- /dev/null
+++ b/package/luarocks/0002-getenv-in-config.patch
@@ -0,0 +1,31 @@
+From 3d855e0c678b241f4f9b9c596c409da3a27411aa Mon Sep 17 00:00:00 2001
+From: Francois Perrad <francois.perrad@gadz.org>
+Date: Fri, 16 Nov 2018 19:57:47 +0100
+Subject: [PATCH] Allow using getenv in configuration file
+
+This commit adds getenv() in the sandboxed environment used when
+loading a config file, which allows to get environment variables from
+a luarocks configuration file.
+
+Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
+[Thomas: slightly improved commit title/log]
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
+---
+ src/luarocks/core/cfg.lua | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/src/luarocks/core/cfg.lua b/src/luarocks/core/cfg.lua
+index 3237786..9bc0d22 100644
+--- a/src/luarocks/core/cfg.lua
++++ b/src/luarocks/core/cfg.lua
+@@ -89,6 +89,7 @@ do
+ local function env_for_config_file(cfg, platforms)
+ local e
+ e = {
++ getenv = os.getenv,
+ home = cfg.home,
+ lua_version = cfg.lua_version,
+ platforms = util.make_shallow_copy(platforms),
+--
+2.17.1
+
diff --git a/package/luarocks/luarocks-br-config.lua b/package/luarocks/luarocks-br-config.lua
new file mode 100644
index 0000000000..39d6eaad12
--- /dev/null
+++ b/package/luarocks/luarocks-br-config.lua
@@ -0,0 +1,12 @@
+-- BR cross-compilation
+variables.LUA_INCDIR = getenv('STAGING_DIR') .. [[/usr/include]]
+variables.LUA_LIBDIR = getenv('STAGING_DIR') .. [[/usr/lib]]
+variables.CC = getenv('TARGET_CC')
+variables.LD = getenv('TARGET_CC')
+variables.CFLAGS = getenv('TARGET_CFLAGS')
+variables.LIBFLAG = [[-shared ]] .. getenv('TARGET_LDFLAGS')
+external_deps_dirs = { getenv('STAGING_DIR') .. [[/usr]] }
+gcc_rpath = false
+rocks_trees = { getenv('TARGET_DIR') .. [[/usr]] }
+wrap_bin_scripts = false
+deps_mode = [[none]]
diff --git a/package/luarocks/luarocks.mk b/package/luarocks/luarocks.mk
index cfef8f19b3..1577189007 100644
--- a/package/luarocks/luarocks.mk
+++ b/package/luarocks/luarocks.mk
@@ -30,23 +30,18 @@ endef
define HOST_LUAROCKS_INSTALL_CMDS
rm -f $(LUAROCKS_CONFIG_FILE)
$(MAKE1) -C $(@D) install
- echo "-- BR cross-compilation" >> $(LUAROCKS_CONFIG_FILE)
- echo "variables.LUA_INCDIR = [[$(STAGING_DIR)/usr/include]]" >> $(LUAROCKS_CONFIG_FILE)
- echo "variables.LUA_LIBDIR = [[$(STAGING_DIR)/usr/lib]]" >> $(LUAROCKS_CONFIG_FILE)
- echo "variables.CC = [[$(TARGET_CC)]]" >> $(LUAROCKS_CONFIG_FILE)
- echo "variables.LD = [[$(TARGET_CC)]]" >> $(LUAROCKS_CONFIG_FILE)
- echo "variables.CFLAGS = [[$(LUAROCKS_CFLAGS)]]" >> $(LUAROCKS_CONFIG_FILE)
- echo "variables.LIBFLAG = [[-shared $(TARGET_LDFLAGS)]]" >> $(LUAROCKS_CONFIG_FILE)
- echo "external_deps_dirs = { [[$(STAGING_DIR)/usr]] }" >> $(LUAROCKS_CONFIG_FILE)
- echo "gcc_rpath = false" >> $(LUAROCKS_CONFIG_FILE)
- echo "rocks_trees = { [[$(TARGET_DIR)/usr]] }" >> $(LUAROCKS_CONFIG_FILE)
- echo "wrap_bin_scripts = false" >> $(LUAROCKS_CONFIG_FILE)
- echo "deps_mode = [[none]]" >> $(LUAROCKS_CONFIG_FILE)
+ cat $(HOST_LUAROCKS_PKGDIR)/luarocks-br-config.lua >> $(LUAROCKS_CONFIG_FILE)
endef
$(eval $(host-generic-package))
-LUAROCKS_RUN_ENV = LUA_PATH="$(HOST_DIR)/share/lua/$(LUAINTERPRETER_ABIVER)/?.lua"
+LUAROCKS_RUN_ENV = \
+ LUA_PATH="$(HOST_DIR)/share/lua/$(LUAINTERPRETER_ABIVER)/?.lua" \
+ STAGING_DIR="$(STAGING_DIR)" \
+ TARGET_DIR="$(TARGET_DIR)" \
+ TARGET_CC="$(TARGET_CC)" \
+ TARGET_CFLAGS="$(LUAROCKS_CFLAGS)" \
+ TARGET_LDFLAGS="$(TARGET_LDFLAGS)"
LUAROCKS_RUN_CMD = $(LUA_RUN) $(HOST_DIR)/bin/luarocks
define LUAROCKS_FINALIZE_TARGET
--
2.19.1
next prev parent reply other threads:[~2018-11-19 10:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-19 10:32 [Buildroot] [PATCH next 0/2] Adjust Luarocks support to per-package folder Thomas Petazzoni
2018-11-19 10:32 ` [Buildroot] [PATCH next 1/2] package/pkg-luarocks: drop flock at installation time Thomas Petazzoni
2018-11-19 20:28 ` François Perrad
2018-11-19 20:46 ` Thomas Petazzoni
2018-11-19 10:32 ` Thomas Petazzoni [this message]
2018-11-19 20:57 ` [Buildroot] [PATCH next 2/2] package/luarocks: rework configuration file for per-package folders François Perrad
2018-11-20 11:02 ` Thomas Petazzoni
2018-11-21 8:23 ` François Perrad
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=20181119103227.24726-3-thomas.petazzoni@bootlin.com \
--to=thomas.petazzoni@bootlin.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