* [Buildroot] [PATCH next 0/2] Adjust Luarocks support to per-package folder @ 2018-11-19 10:32 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 10:32 ` [Buildroot] [PATCH next 2/2] package/luarocks: rework configuration file for per-package folders Thomas Petazzoni 0 siblings, 2 replies; 8+ messages in thread From: Thomas Petazzoni @ 2018-11-19 10:32 UTC (permalink / raw) To: buildroot Hello, Based on Fran?ois Perrad's feedback, this small patch series reworks how Luarocks is used to make it compatible with per-package folders. It is sent as a separate series, because it can be applied independently from the per-package series itself. Thanks, Thomas Thomas Petazzoni (2): package/pkg-luarocks: drop flock at installation time package/luarocks: rework configuration file for per-package folders package/luarocks/0002-getenv-in-config.patch | 31 ++++++++++++++++++++ package/luarocks/luarocks-br-config.lua | 12 ++++++++ package/luarocks/luarocks.mk | 21 +++++-------- package/pkg-luarocks.mk | 2 +- 4 files changed, 52 insertions(+), 14 deletions(-) create mode 100644 package/luarocks/0002-getenv-in-config.patch create mode 100644 package/luarocks/luarocks-br-config.lua -- 2.19.1 ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Buildroot] [PATCH next 1/2] package/pkg-luarocks: drop flock at installation time 2018-11-19 10:32 [Buildroot] [PATCH next 0/2] Adjust Luarocks support to per-package folder Thomas Petazzoni @ 2018-11-19 10:32 ` Thomas Petazzoni 2018-11-19 20:28 ` François Perrad 2018-11-19 20:46 ` Thomas Petazzoni 2018-11-19 10:32 ` [Buildroot] [PATCH next 2/2] package/luarocks: rework configuration file for per-package folders Thomas Petazzoni 1 sibling, 2 replies; 8+ messages in thread From: Thomas Petazzoni @ 2018-11-19 10:32 UTC (permalink / raw) To: buildroot In commit 22b327fc743b48a33aec0a9190bd67118641b294 ("pkg-luarocks: fix top-level parallel makefile support"), a flock on $(TARGET_DIR) was added to ensure that two Luarocks packages are not installed at the same time. However, to support top-level parallel build, we have now clearly decided that per-package folders is a requirement. Therefore, TARGET_DIR is anyway going to be different for each package, making this flock unnecessary. Trying to use top-level parallel build without per-package folder is simply not supported, so this commit drops the unnecessary flock. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com> --- package/pkg-luarocks.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/pkg-luarocks.mk b/package/pkg-luarocks.mk index 29c5e66cd1..f0985433b7 100644 --- a/package/pkg-luarocks.mk +++ b/package/pkg-luarocks.mk @@ -63,7 +63,7 @@ endif # ifndef $(2)_INSTALL_TARGET_CMDS define $(2)_INSTALL_TARGET_CMDS - cd $$($(2)_SRCDIR) && $$(LUAROCKS_RUN_ENV) flock $$(TARGET_DIR) \ + cd $$($(2)_SRCDIR) && $$(LUAROCKS_RUN_ENV) \ $$(LUAROCKS_RUN_CMD) make --keep $$($(2)_ROCKSPEC) $$($(2)_BUILD_OPTS) endef endif -- 2.19.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Buildroot] [PATCH next 1/2] package/pkg-luarocks: drop flock at installation time 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 1 sibling, 0 replies; 8+ messages in thread From: François Perrad @ 2018-11-19 20:28 UTC (permalink / raw) To: buildroot Le lun. 19 nov. 2018 ? 11:32, Thomas Petazzoni <thomas.petazzoni@bootlin.com> a ?crit : > In commit 22b327fc743b48a33aec0a9190bd67118641b294 ("pkg-luarocks: fix > top-level parallel makefile support"), a flock on $(TARGET_DIR) was > added to ensure that two Luarocks packages are not installed at the > same time. > > However, to support top-level parallel build, we have now clearly > decided that per-package folders is a requirement. Therefore, > TARGET_DIR is anyway going to be different for each package, making > this flock unnecessary. > > Trying to use top-level parallel build without per-package folder is > simply not supported, so this commit drops the unnecessary flock. > > Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com> > Acked-by: Francois Perrad <francois.perrad@gadz.org> --- > package/pkg-luarocks.mk | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/package/pkg-luarocks.mk b/package/pkg-luarocks.mk > index 29c5e66cd1..f0985433b7 100644 > --- a/package/pkg-luarocks.mk > +++ b/package/pkg-luarocks.mk > @@ -63,7 +63,7 @@ endif > # > ifndef $(2)_INSTALL_TARGET_CMDS > define $(2)_INSTALL_TARGET_CMDS > - cd $$($(2)_SRCDIR) && $$(LUAROCKS_RUN_ENV) flock $$(TARGET_DIR) \ > + cd $$($(2)_SRCDIR) && $$(LUAROCKS_RUN_ENV) \ > $$(LUAROCKS_RUN_CMD) make --keep $$($(2)_ROCKSPEC) > $$($(2)_BUILD_OPTS) > endef > endif > -- > 2.19.1 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20181119/3b6f5b56/attachment.html> ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Buildroot] [PATCH next 1/2] package/pkg-luarocks: drop flock at installation time 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 1 sibling, 0 replies; 8+ messages in thread From: Thomas Petazzoni @ 2018-11-19 20:46 UTC (permalink / raw) To: buildroot Hello, On Mon, 19 Nov 2018 11:32:26 +0100, Thomas Petazzoni wrote: > In commit 22b327fc743b48a33aec0a9190bd67118641b294 ("pkg-luarocks: fix > top-level parallel makefile support"), a flock on $(TARGET_DIR) was > added to ensure that two Luarocks packages are not installed at the > same time. > > However, to support top-level parallel build, we have now clearly > decided that per-package folders is a requirement. Therefore, > TARGET_DIR is anyway going to be different for each package, making > this flock unnecessary. > > Trying to use top-level parallel build without per-package folder is > simply not supported, so this commit drops the unnecessary flock. > > Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com> > --- > package/pkg-luarocks.mk | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Applied to next, thanks. Thomas -- Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Buildroot] [PATCH next 2/2] package/luarocks: rework configuration file for per-package folders 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 10:32 ` Thomas Petazzoni 2018-11-19 20:57 ` François Perrad 2018-11-21 8:23 ` François Perrad 1 sibling, 2 replies; 8+ messages in thread From: Thomas Petazzoni @ 2018-11-19 10:32 UTC (permalink / raw) To: buildroot 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 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Buildroot] [PATCH next 2/2] package/luarocks: rework configuration file for per-package folders 2018-11-19 10:32 ` [Buildroot] [PATCH next 2/2] package/luarocks: rework configuration file for per-package folders Thomas Petazzoni @ 2018-11-19 20:57 ` François Perrad 2018-11-20 11:02 ` Thomas Petazzoni 2018-11-21 8:23 ` François Perrad 1 sibling, 1 reply; 8+ messages in thread From: François Perrad @ 2018-11-19 20:57 UTC (permalink / raw) To: buildroot Le lun. 19 nov. 2018 ? 11:32, Thomas Petazzoni <thomas.petazzoni@bootlin.com> a ?crit : > 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. > + > In fact, this patch is useless, the sandbox environment contains a field `os_getenv`. Just use `os_getenv` instead of `getenv` in luarocks-br-config.lua. Another point, without defining a lot variables, the command `somewhere_host/bin/luarocks --help` fails with the message : attemps to concatenate a nil value (when loading the config file) So, add something like this, on the top of luarocks-br-config.lua : local function getenv (name) return os_getenv(name) or '' end By this way, the buildroot addon still works ( https://patchwork.ozlabs.org/patch/995892/). Fran?ois > +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 part -------------- An HTML attachment was scrubbed... URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20181119/b44b683d/attachment.html> ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Buildroot] [PATCH next 2/2] package/luarocks: rework configuration file for per-package folders 2018-11-19 20:57 ` François Perrad @ 2018-11-20 11:02 ` Thomas Petazzoni 0 siblings, 0 replies; 8+ messages in thread From: Thomas Petazzoni @ 2018-11-20 11:02 UTC (permalink / raw) To: buildroot Hello Fran?ois, On Mon, 19 Nov 2018 21:57:35 +0100, Fran?ois Perrad wrote: > In fact, this patch is useless, the sandbox environment contains a field > `os_getenv`. > Just use `os_getenv` instead of `getenv` in luarocks-br-config.lua. > > Another point, without defining a lot variables, the command > `somewhere_host/bin/luarocks --help` fails > with the message : attemps to concatenate a nil value (when loading the > config file) > > So, add something like this, on the top of luarocks-br-config.lua : > local function getenv (name) return os_getenv(name) or '' end Thanks for the feedback! I will send an updated version soon. Best regards, Thomas -- Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Buildroot] [PATCH next 2/2] package/luarocks: rework configuration file for per-package folders 2018-11-19 10:32 ` [Buildroot] [PATCH next 2/2] package/luarocks: rework configuration file for per-package folders Thomas Petazzoni 2018-11-19 20:57 ` François Perrad @ 2018-11-21 8:23 ` François Perrad 1 sibling, 0 replies; 8+ messages in thread From: François Perrad @ 2018-11-21 8:23 UTC (permalink / raw) To: buildroot Le lun. 19 nov. 2018 ? 11:32, Thomas Petazzoni <thomas.petazzoni@bootlin.com> a ?crit : > 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 > Another detail, the notation [[string]] was useful when echoing from luarocks.mk. Now, you could just simple or double quote string. Fran?ois > +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 part -------------- An HTML attachment was scrubbed... URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20181121/cf4eb325/attachment.html> ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2018-11-21 8:23 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 ` [Buildroot] [PATCH next 2/2] package/luarocks: rework configuration file for per-package folders Thomas Petazzoni 2018-11-19 20:57 ` François Perrad 2018-11-20 11:02 ` Thomas Petazzoni 2018-11-21 8:23 ` François Perrad
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox