Skip to content
Snippets Groups Projects
Verified Commit b66355a8 authored by Karel Koci's avatar Karel Koci :metal:
Browse files

lists/bootstrap: fix invalid usage of environment variables

This fixes bug that caused normal medkits to not be generated as
contract with no name was not located.

The reason is that Lua's string when they are empty are still true
(contrary to other languages such as Python). This adds explicit checks
if they are non-empty as that is more common and more expected.

This also fixes potential problem when some environment variable is not
defined. This does no happen with our script but can happen if that
script is not used.
parent 31e01894
Branches
Tags
1 merge request!229lists/bootstrap: fix invalid usage of environment variables
......@@ -4,7 +4,7 @@ Root script for updater-ng configuration used for medkit generation.
-- Get target board
model = os.getenv('BOARD')
if not model then
if not model or model == "" then
-- TODO we might ask interactively
DIE("Target model has to be provided by BOARD environment variable.")
end
......
--[[
Root script for updater-ng configuration usable for bootstrapping.
Root script for updater-ng configuration used for bootstrapping new root.
This script expects following variables to be possibly defined in environment:
BOARD: board name (Mox|Omnia|Turris)
L10N: commas separated list of languages to be installed in root.
PKGLISTS: commas separated list of package lists to be included in root. To
specify options you can optionally add parentheses at the end of package name
and list pipe separated options inside them. (ex: foo(opt1|opt2),fee)
specify options you can optionally add parentheses at the end of package name
and list pipe separated options inside them. (ex: foo(opt1|opt2),fee)
CONTRACT: name of contract medkit is generated for. Do not specify for standard
medkits
TESTKEY: if definied non-empty then test kyes are included in installation
]]
......@@ -17,8 +19,11 @@ end
-- Load requested localizations
l10n = {}
for lang in os.getenv('L10N'):gmatch('[^,]+') do
table.insert(l10n, lang)
local env_l10n = os.getenv('L10N')
if env_l10n then
for lang in env_l10n:gmatch('[^,]+') do
table.insert(l10n, lang)
end
end
Export('l10n')
......@@ -34,24 +39,28 @@ Export('for_l10n')
-- Aways include base script
Script('base.lua')
-- Include any additional lists
for list in os.getenv('PKGLISTS'):gmatch('[^,]+') do
local list_name = list:match('^[^(]+') .. ".lua"
local list_options = list:match('%((.*)%)$')
options = {}
Export("options")
if list_options then
for opt in list_options:gmatch('[^|]+') do
options[opt] = true
local env_pkglists = os.getenv('PKGLISTS')
if env_pkglists then
for list in env_pkglists:gmatch('[^,]+') do
local list_name = list:match('^[^(]+') .. ".lua"
local list_options = list:match('%((.*)%)$')
options = {}
Export("options")
if list_options then
for opt in list_options:gmatch('[^|]+') do
options[opt] = true
end
end
Script(list_name .. '.lua')
end
Script(list_name .. '.lua')
end
-- Include contract if specified
local contract = os.getenv('CONTRACT')
if contract then
local env_contract = os.getenv('CONTRACT')
if env_contract and env_contract ~= "" then
Script('contracts/' .. contract .. '.lua')
end
if os.getenv('TESTKEY') then
local env_testkey = os.getenv('TESTKEY')
if env_testkey and env_testkey ~= "" then
Install('cznic-repo-keys-test')
end
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment