mbox series

[00/13] Extend Lua Environemnt and post-failure scripts

Message ID 20240221082221.11997-1-stefano.babic@swupdate.org
Headers show
Series Extend Lua Environemnt and post-failure scripts | expand

Message

Stefano Babic Feb. 21, 2024, 8:22 a.m. UTC
This patchset introduces two big changes:

- Lua life-cycle is extended to the whole update. It is still configurable,
  and a Lua state can still isolate a single script (as before). This is
  the default environment.
  SWUpdate sets a Lua state at the beginning of an update and frees when the
  update is terminated. This lets to use functions and variables defined
  in scripts that ran before.
  As example, an embedded-lua script in sw-description can set some Lua
  variables, that a later script can read (and modify). This is also
  a step for security, because no external data to transfer information
  is needed, and everything remains in context of the Lua state.

- post-failure scripts. These are called only in case an update fails.
  They are usually required for cleanup and to restore to the same
  state before the update has begun, like restart some services, etc.


Stefano Babic (13):
  Lua: prepare to extend Lua lifetime
  Lua: move out state initialization from run_lua_script
  image: create pointer to per install Lua state
  Store install Lua State in image structure
  Lua Script: runs with global Lua state
  Introduce entry for post-update failure scripts
  Export run_prepost_script to other modules
  Introduce postfailure scripts
  Lua Script: TRACE the name of the called function
  run_lua_script: check input parms
  Lua Script Handler: allows to run scripts globally
  doc: explain Lua and shell script handlers
  Fix warnings in case CONFIG_LUA is not set

 core/installer.c               |  10 +++-
 core/stream_interface.c        |  13 +++++
 corelib/lua_interface.c        |  55 +++++++++--------
 doc/source/handlers.rst        |  86 +++++++++++++++++++++++++--
 doc/source/sw-description.rst  |  20 ++++++-
 handlers/lua_scripthandler.c   | 104 ++++++++++++++++++++++++++++-----
 handlers/shell_scripthandler.c |   3 +
 include/handler.h              |  12 +++-
 include/installer.h            |   1 +
 include/lua_util.h             |  17 ++++--
 include/swupdate.h             |   1 +
 include/swupdate_image.h       |  10 +++-
 parser/parser.c                |  17 ++++--
 13 files changed, 288 insertions(+), 61 deletions(-)

--
2.34.1