From 7279c4017e052a9cb36e0d83bea6c397575a9f7b Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 31 May 2020 01:16:57 +0200 Subject: [PATCH] build: target_lib: allow to specify multiple factory_ext values By passing a table instead of a single string, multiple different extensions can be specified, each refering to a separate image file generated by OpenWrt. This is not supported for sysupgrade (as there can only be a single image in the format expected by OpenWrt). --- scripts/target_lib.lua | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/scripts/target_lib.lua b/scripts/target_lib.lua index 381a440b..bb974659 100644 --- a/scripts/target_lib.lua +++ b/scripts/target_lib.lua @@ -202,6 +202,14 @@ function F.packages(pkgs) end M.packages = F.packages +local function as_table(v) + if type(v) == 'table' then + return v + else + return {v} + end +end + function F.device(image, name, options) options = merge(default_options, options) @@ -233,15 +241,17 @@ function F.device(image, name, options) end if options.factory then - add_image { - image = image, - name = name, - subdir = 'factory', - in_suffix = options.factory, - out_suffix = '', - extension = options.factory_ext, - aliases = options.aliases, - } + for _, ext in ipairs(as_table(options.factory_ext)) do + add_image { + image = image, + name = name, + subdir = 'factory', + in_suffix = options.factory, + out_suffix = '', + extension = ext, + aliases = options.aliases, + } + end end for _, extra_image in ipairs(options.extra_images) do add_image {