Skip to content
Snippets Groups Projects
Commit dd5c5033 authored by David Bauer's avatar David Bauer
Browse files

image-customization: load image-customization.lua once


Load the site image-customization.lua file only on init. Previously, the
file was loaded on every device invocation.

Signed-off-by: default avatarDavid Bauer <mail@david-bauer.net>
parent 83406bc5
No related branches found
No related tags found
No related merge requests found
local M = {}
local function file_exists(file)
local f = io.open(file)
if not f then
return false
end
f:close()
return true
end
local function get_customization_file_name(env)
return env.GLUON_SITEDIR .. '/image-customization.lua'
end
local M = {
customization_file = nil,
}
local function evaluate_device(env, dev)
local selections = {
......@@ -91,12 +80,8 @@ local function evaluate_device(env, dev)
end
-- Evaluate the feature definition files
local f, err = loadfile(get_customization_file_name(env))
if not f then
error('Failed to parse feature definition: ' .. err)
end
setfenv(f, funcs)
f()
setfenv(M.customization_file, funcs)
M.customization_file()
return {
selections = selections,
......@@ -110,7 +95,8 @@ function M.get_selections(dev)
packages = {},
}
if not file_exists(get_customization_file_name(M.env)) then
if M.customization_file == nil then
-- No customization file found
return return_object
end
......@@ -119,7 +105,8 @@ function M.get_selections(dev)
end
function M.device_overrides(dev)
if not file_exists(get_customization_file_name(M.env)) then
if M.customization_file == nil then
-- No customization file found
return {}
end
......@@ -128,7 +115,17 @@ function M.device_overrides(dev)
end
function M.init(env)
local filename = env.GLUON_SITEDIR .. '/image-customization.lua'
M.env = env
local f, _ = loadfile(filename)
if not f then
-- No customization file found, nothing to do
return
end
M.customization_file = f
end
return M
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment