Skip to contentSkip to conversation

package/swupdate: add embedded lua handler config option

PATCH New James Hilliard 2 participants 2 messages Sep 19, 2023 – Nov 21

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 package/swupdate: add embedded lua handler config option

We are able to configure most swupdate options using a swupdate config file, however the embedded lua source option may need to point to a buildroot generated source path.

To simplify configuration of this swupdate option add a buildroot config option which will pass a source file path to swupdate when enabled in buildroot. We also need a config option to enable this feature in swupdate which the source file path config option will depend on.

---
Changes v1 -> v2:
- pass path via make opts instead of kconfig

---
 package/swupdate/Config.in   | 12 ++++++++++++
 package/swupdate/swupdate.mk | 22 ++++++++++++++++------
 2 files changed, 28 insertions(+), 6 deletions(-)
package/swupdate/Config.in +12 -0
index 7d9fc90e10..4e3573569b 100644
@@ -60,6 +60,18 @@ config BR2_PACKAGE_SWUPDATE_CONFIG
 	  I you wish to use your own modified swupdate configuration
 	  file specify the config file location with this option.
 
+config BR2_PACKAGE_SWUPDATE_EMBEDDED_LUA_HANDLER
+	bool "swupdate embedded lua handler"
+	depends on BR2_PACKAGE_HAS_LUAINTERPRETER
+	help
+	  Enable the embedded lua handler.
+
+config BR2_PACKAGE_SWUPDATE_EMBEDDED_LUA_HANDLER_SOURCE
+	string "swupdate embedded lua handler source"
+	depends on BR2_PACKAGE_SWUPDATE_EMBEDDED_LUA_HANDLER
+	help
+	  Path to the embedded lua handler source.
+
 config BR2_PACKAGE_SWUPDATE_USB
 	bool "swupdate usb"
 	depends on BR2_PACKAGE_SYSTEMD
package/swupdate/swupdate.mk +16 -6
index ea4a5a62e5..5abdf7cb34 100644
@@ -27,6 +27,12 @@ SWUPDATE_MAKE_ENV = CC="$(TARGET_CC)" LD="$(TARGET_CC)" SKIP_STRIP=y
 # we don't package EFI Boot Guard/libebgenv
 SWUPDATE_MAKE_ENV += HAVE_LIBEBGENV=n
 
+SWUPDATE_MAKE_OPTS = \
+	SWU_VER="$(SWUPDATE_VERSION) (Buildroot $(BR2_VERSION_FULL))" \
+	CROSS_COMPILE="$(TARGET_CROSS)" \
+	CONFIG_EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
+	CONFIG_EXTRA_LDFLAGS="$(TARGET_LDFLAGS)"
+
 # swupdate bundles its own version of mongoose (version 6.16)
 
 ifeq ($(BR2_PACKAGE_E2FSPROGS),y)
@@ -113,6 +119,15 @@ define SWUPDATE_SET_LUA_VERSION
 	$(call KCONFIG_SET_OPT,CONFIG_LUAPKG,$(BR2_PACKAGE_PROVIDES_LUAINTERPRETER))
 endef
 SWUPDATE_MAKE_ENV += HAVE_LUA=y
+ifeq ($(BR2_PACKAGE_SWUPDATE_EMBEDDED_LUA_HANDLER),y)
+define SWUPDATE_SET_EMBEDDED_LUA
+	$(call KCONFIG_ENABLE_OPT,CONFIG_LUA)
+	$(call KCONFIG_ENABLE_OPT,CONFIG_LUASCRIPTHANDLER)
+	$(call KCONFIG_ENABLE_OPT,CONFIG_HANDLER_IN_LUA)
+	$(call KCONFIG_ENABLE_OPT,CONFIG_EMBEDDED_LUA_HANDLER)
+endef
+SWUPDATE_MAKE_OPTS += CONFIG_EMBEDDED_LUA_HANDLER_SOURCE=$(BR2_PACKAGE_SWUPDATE_EMBEDDED_LUA_HANDLER_SOURCE)
+endif
 else
 SWUPDATE_MAKE_ENV += HAVE_LUA=n
 endif
@@ -217,14 +232,9 @@ endif
 SWUPDATE_KCONFIG_FILE = $(call qstrip,$(BR2_PACKAGE_SWUPDATE_CONFIG))
 SWUPDATE_KCONFIG_EDITORS = menuconfig xconfig gconfig nconfig
 
-SWUPDATE_MAKE_OPTS = \
-	SWU_VER="$(SWUPDATE_VERSION) (Buildroot $(BR2_VERSION_FULL))" \
-	CROSS_COMPILE="$(TARGET_CROSS)" \
-	CONFIG_EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
-	CONFIG_EXTRA_LDFLAGS="$(TARGET_LDFLAGS)"
-
 define SWUPDATE_KCONFIG_FIXUP_CMDS
 	$(SWUPDATE_SET_LUA_VERSION)
+	$(SWUPDATE_SET_EMBEDDED_LUA)
 	$(SWUPDATE_SET_SYSTEMD)
 	$(SWUPDATE_SET_WEBSERVER)
 endef
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

PATCH v3 1/1 package/swupdate: add embedded lua handler config option

From: James Hilliard <[email protected]>

We are able to configure most swupdate options using a swupdate config file, however the embedded lua source option may need to point to a buildroot generated source path.

To simplify configuration of this swupdate option add a buildroot config option which will pass a source file path to swupdate when enabled in buildroot. We also need a config option to enable this feature in swupdate which the source file path config option will depend on.

---
Changes v2 -> v3:
- do not enable CONFIG_HANDLER_IN_LUA: swupdate removed it, and the embedded handler now only needs CONFIG_LUA
- do not enable CONFIG_LUASCRIPTHANDLER: the Lua script handler is another feature, not needed by the embedded handler
- strip the quotes of the source path with qstrip
- help text: say to use an absolute path, as swupdate looks for a relative path in its own source tree
- rebase on master (swupdate 2026.05.1)

Changes v1 -> v2:
- pass path via make opts instead of kconfig

Supersedes v2: https://patchwork.buildroot.org/project/buildroot/patch/[email protected]/

 package/swupdate/Config.in   | 15 +++++++++++++++
 package/swupdate/swupdate.mk | 21 +++++++++++++++------
 2 files changed, 30 insertions(+), 6 deletions(-)
package/swupdate/Config.in +15 -0
index 112e53a127..0ad32950ed 100644
@@ -60,6 +60,21 @@ config BR2_PACKAGE_SWUPDATE_CONFIG
 	  I you wish to use your own modified swupdate configuration
 	  file specify the config file location with this option.
 
+config BR2_PACKAGE_SWUPDATE_EMBEDDED_LUA_HANDLER
+	bool "swupdate embedded lua handler"
+	depends on BR2_PACKAGE_HAS_LUAINTERPRETER
+	help
+	  Enable the embedded lua handler.
+
+config BR2_PACKAGE_SWUPDATE_EMBEDDED_LUA_HANDLER_SOURCE
+	string "swupdate embedded lua handler source"
+	depends on BR2_PACKAGE_SWUPDATE_EMBEDDED_LUA_HANDLER
+	help
+	  Path to the Lua handler source file to embed in the
+	  swupdate binary. Use an absolute path, for example in a
+	  br2-external:
+	  $(BR2_EXTERNAL_<NAME>_PATH)/swupdate_handlers.lua
+
 config BR2_PACKAGE_SWUPDATE_USB
 	bool "swupdate usb"
 	depends on BR2_PACKAGE_SYSTEMD
package/swupdate/swupdate.mk +15 -6
index 2384dea33a..def4248fbd 100644
@@ -28,6 +28,12 @@ SWUPDATE_MAKE_ENV = CC="$(TARGET_CC)" LD="$(TARGET_CC)" SKIP_STRIP=y
 # we don't package EFI Boot Guard/libebgenv
 SWUPDATE_MAKE_ENV += HAVE_LIBEBGENV=n
 
+SWUPDATE_MAKE_OPTS = \
+	SWU_VER="$(SWUPDATE_VERSION) (Buildroot $(BR2_VERSION_FULL))" \
+	CROSS_COMPILE="$(TARGET_CROSS)" \
+	CONFIG_EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
+	CONFIG_EXTRA_LDFLAGS="$(TARGET_LDFLAGS)"
+
 # swupdate bundles its own version of mongoose (version 6.16)
 
 ifeq ($(BR2_PACKAGE_E2FSPROGS),y)
@@ -103,6 +109,14 @@ define SWUPDATE_SET_LUA_VERSION
 	$(call KCONFIG_SET_OPT,CONFIG_LUAPKG,$(BR2_PACKAGE_PROVIDES_LUAINTERPRETER))
 endef
 SWUPDATE_MAKE_ENV += HAVE_LUA=y
+ifeq ($(BR2_PACKAGE_SWUPDATE_EMBEDDED_LUA_HANDLER),y)
+define SWUPDATE_SET_EMBEDDED_LUA
+	$(call KCONFIG_ENABLE_OPT,CONFIG_LUA)
+	$(call KCONFIG_ENABLE_OPT,CONFIG_EMBEDDED_LUA_HANDLER)
+endef
+SWUPDATE_MAKE_OPTS += \
+	CONFIG_EMBEDDED_LUA_HANDLER_SOURCE="$(call qstrip,$(BR2_PACKAGE_SWUPDATE_EMBEDDED_LUA_HANDLER_SOURCE))"
+endif
 else
 SWUPDATE_MAKE_ENV += HAVE_LUA=n
 endif
@@ -205,14 +219,9 @@ endif
 SWUPDATE_KCONFIG_FILE = $(call qstrip,$(BR2_PACKAGE_SWUPDATE_CONFIG))
 SWUPDATE_KCONFIG_EDITORS = menuconfig xconfig gconfig nconfig
 
-SWUPDATE_MAKE_OPTS = \
-	SWU_VER="$(SWUPDATE_VERSION) (Buildroot $(BR2_VERSION_FULL))" \
-	CROSS_COMPILE="$(TARGET_CROSS)" \
-	CONFIG_EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
-	CONFIG_EXTRA_LDFLAGS="$(TARGET_LDFLAGS)"
-
 define SWUPDATE_KCONFIG_FIXUP_CMDS
 	$(SWUPDATE_SET_LUA_VERSION)
+	$(SWUPDATE_SET_EMBEDDED_LUA)
 	$(SWUPDATE_SET_SYSTEMD)
 	$(SWUPDATE_SET_WEBSERVER)
 endef
Signature · 6 lines
2.53.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot