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

build image-customization: create init routine


Create an init routine which loads the environment only once instead
every evaluation.

Signed-off-by: default avatarDavid Bauer <mail@david-bauer.net>
parent 0f044103
No related branches found
No related tags found
No related merge requests found
......@@ -104,27 +104,31 @@ local function evaluate_device(env, dev)
}
end
function M.get_selections(env, dev)
function M.get_selections(dev)
local return_object = {
features = {},
packages = {},
}
if not file_exists(get_customization_file_name(env)) then
if not file_exists(get_customization_file_name(M.env)) then
return return_object
end
local eval_result = evaluate_device(env, dev)
local eval_result = evaluate_device(M.env, dev)
return eval_result.selections
end
function M.device_overrides(env, dev)
if not file_exists(get_customization_file_name(env)) then
function M.device_overrides(dev)
if not file_exists(get_customization_file_name(M.env)) then
return {}
end
local eval_result = evaluate_device(env, dev)
local eval_result = evaluate_device(M.env, dev)
return eval_result.device_overrides
end
function M.init(env)
M.env = env
end
return M
......@@ -16,6 +16,8 @@ else
openwrt_config_target = env.BOARD
end
-- Initialize image-customization
image_customization_lib.init(env)
-- Split a string into words
local function split(s)
......@@ -93,7 +95,7 @@ local function site_specific_packages(dev_info)
local site_features
-- Get all enabled selections from image-customization.lua
site_selections = image_customization_lib.get_selections(env, dev_info)
site_selections = image_customization_lib.get_selections(dev_info)
-- First read enabled features from site
site_features = site_selections['features']
......
......@@ -31,6 +31,8 @@ M.configs = {}
M.devices = {}
M.images = {}
-- Initialize image-customization
image_customization_lib.init(env)
local default_options = {
factory = '-squashfs-factory',
......@@ -57,10 +59,6 @@ function F.istrue(v)
return (tonumber(v) or 0) > 0
end
local function get_device_overrides(device_info)
return image_customization_lib.device_overrides(env, device_info)
end
local function device_broken(device_info, overrides)
if F.istrue(env.BROKEN) then
return false
......@@ -76,7 +74,7 @@ local function device_broken(device_info, overrides)
end
local function want_device(device_info)
local overrides = get_device_overrides(device_info)
local overrides = image_customization_lib.device_overrides(device_info)
-- Check if device is disabled via image-customization.lua in site
if overrides['disabled'] then
......@@ -240,7 +238,7 @@ local function disable_factory_image(device_info)
return true
end
local overrides = get_device_overrides(device_info)
local overrides = image_customization_lib.device_overrides(device_info)
if overrides["disable_factory"] then
return true
end
......
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