Jelajahi Sumber

swupdate-lualoader: Add recipe

Adds a recipe for a simple swudpate_handlers.lua script that loads lua
files from a directory. This allows other recipes to drop lua handler
scripts in the specified location and swupdate will find them instead of
having to explicitly list all the files to be loaded in a custom
swupdate_handlers.lua script.

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Reviewed-by: stefano Babic <sbabic@denx.de>
Joshua Watt 5 tahun lalu
induk
melakukan
559b12c8f5

+ 29 - 0
recipes-lua/swupdate-lualoader/swupdate-lualoader/swupdate_handlers.lua

@@ -0,0 +1,29 @@
+-- Copyright 2020 Joshua Watt <JPEWhacker@gmail.com>
+--
+-- Permission is hereby granted, free of charge, to any person obtaining a copy
+-- of this software and associated documentation files (the "Software"), to
+-- deal in the Software without restriction, including without limitation the
+-- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+-- sell copies of the Software, and to permit persons to whom the Software is
+-- furnished to do so, subject to the following conditions:
+--
+-- The above copyright notice and this permission notice shall be included in
+-- all copies or substantial portions of the Software.
+-- 
+-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+-- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+-- IN THE SOFTWARE.
+
+local lfs = require("lfs")
+
+local path = "@libdir@/swupdate/lua-handlers"
+for file in lfs.dir(path) do
+    if file:match("^.*%.lua") then
+        dofile(path .. "/" .. file)
+    end
+end
+

+ 20 - 0
recipes-lua/swupdate-lualoader/swupdate-lualoader_1.0.bb

@@ -0,0 +1,20 @@
+SUMMARY = "Loader for swupdate"
+LICENSE = "MIT"
+SECTION = ""
+DEPENDS = "lua"
+LIC_FILES_CHKSUM = "file://${WORKDIR}/swupdate_handlers.lua;md5=354cf4af377edd962d2e8d78085d3ed7;beginline=1;endline=19"
+
+SRC_URI = "file://swupdate_handlers.lua"
+
+inherit pkgconfig
+
+do_install() {
+    LUAVER=$(pkg-config --modversion lua | grep -o '^[0-9]\+\.[0-9]\+')
+    install -D -m 0644 ${WORKDIR}/swupdate_handlers.lua ${D}${libdir}/lua/$LUAVER/swupdate_handlers.lua
+    sed -e 's,@libdir@,${libdir},g' \
+        -i ${D}${libdir}/lua/$LUAVER/swupdate_handlers.lua
+
+}
+
+RDEPENDS_${PN} = "luafilesystem"
+FILES_${PN} = "${libdir}/lua"