diff mbox series

[meta-swupdate] swupdate-lualoader: Add recipe

Message ID 20200707141434.23221-1-JPEWhacker@gmail.com
State Accepted
Headers show
Series [meta-swupdate] swupdate-lualoader: Add recipe | expand

Commit Message

Joshua Watt July 7, 2020, 2:14 p.m. UTC
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>
---
 .../swupdate-lualoader/swupdate_handlers.lua  | 29 +++++++++++++++++++
 .../swupdate-lualoader_1.0.bb                 | 20 +++++++++++++
 2 files changed, 49 insertions(+)
 create mode 100644 recipes-lua/swupdate-lualoader/swupdate-lualoader/swupdate_handlers.lua
 create mode 100644 recipes-lua/swupdate-lualoader/swupdate-lualoader_1.0.bb

Comments

Stefano Babic July 7, 2020, 6:53 p.m. UTC | #1
Hi Joshua,

On 07.07.20 16:14, Joshua Watt wrote:
> 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>
> ---
>   .../swupdate-lualoader/swupdate_handlers.lua  | 29 +++++++++++++++++++
>   .../swupdate-lualoader_1.0.bb                 | 20 +++++++++++++
>   2 files changed, 49 insertions(+)
>   create mode 100644 recipes-lua/swupdate-lualoader/swupdate-lualoader/swupdate_handlers.lua
>   create mode 100644 recipes-lua/swupdate-lualoader/swupdate-lualoader_1.0.bb
> 
> diff --git a/recipes-lua/swupdate-lualoader/swupdate-lualoader/swupdate_handlers.lua b/recipes-lua/swupdate-lualoader/swupdate-lualoader/swupdate_handlers.lua
> new file mode 100644
> index 0000000..c70ed98
> --- /dev/null
> +++ b/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
> +
> diff --git a/recipes-lua/swupdate-lualoader/swupdate-lualoader_1.0.bb b/recipes-lua/swupdate-lualoader/swupdate-lualoader_1.0.bb
> new file mode 100644
> index 0000000..4e8924b
> --- /dev/null
> +++ b/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"
> 

Fine with me.

Reviewed-by: stefano Babic <sbabic@denx.de>

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/recipes-lua/swupdate-lualoader/swupdate-lualoader/swupdate_handlers.lua b/recipes-lua/swupdate-lualoader/swupdate-lualoader/swupdate_handlers.lua
new file mode 100644
index 0000000..c70ed98
--- /dev/null
+++ b/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
+
diff --git a/recipes-lua/swupdate-lualoader/swupdate-lualoader_1.0.bb b/recipes-lua/swupdate-lualoader/swupdate-lualoader_1.0.bb
new file mode 100644
index 0000000..4e8924b
--- /dev/null
+++ b/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"