-
Notifications
You must be signed in to change notification settings - Fork 1
/
bootstrap.lua
117 lines (102 loc) · 3.34 KB
/
bootstrap.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
--[[
Root script for updater-ng configuration used for bootstrapping new root.
This script expects following variables to be possibly defined in environment:
BOOTSTRAP_BOARD: board name (Mox|Omnia|Turris)
BOOTSTRAP_BASE: optional specification of base script. 'base' is used in default.
BOOTSTRAP_L10N: commas separated list of languages to be installed in root.
BOOTSTRAP_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)
BOOTSTRAP_DRIVERS: comamas separated list of driver flags. Every driver class is
combination of bus ('usb', 'pci' or 'sdio') and class itself separated by
colon (ex: usb:foo,pci:fee). Special class 'all' can be used to include all
drivers.
BOOTSTRAP_CONTRACT: name of contract medkit is generated for. Do not specify for
standard medkits
BOOTSTRAP_TESTKEY: if defined non-empty then test kyes are included in
installation
BOOTSTRAP_INITIAL_CONFIG: if defined non-empty then package initial-config is
included.
]]
-- Sanity checks
if root_dir == "/" then
DIE("Bootstrap is not allowed on root.")
end
-- Get target board
model = os.getenv('BOOTSTRAP_BOARD')
if not model or model == "" then
DIE("Target model has to be provided by BOOTSTRAP_BOARD environment variable.")
end
Export('model')
-- Load requested localizations
l10n = {}
local env_l10n = os.getenv('BOOTSTRAP_L10N')
if env_l10n then
for lang in env_l10n:gmatch('[^,]+') do
table.insert(l10n, lang)
end
end
Export('l10n')
-- Always include base script
local base = os.getenv('BOOTSTRAP_BASE')
if not base or base == "" then
base = "base"
end
Script(base .. '.lua')
-- Include any additional lists
local env_pkglists = os.getenv('BOOTSTRAP_PKGLISTS')
if env_pkglists then
for list in env_pkglists:gmatch('[^,]+') do
local list_name = list:match('^[^(]+')
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('pkglists/' .. list_name .. '.lua')
end
end
-- Include any additional driver classes
local env_devices = os.getenv('BOOTSTRAP_DRIVERS')
if env_devices then
local usb_devices = {}
local pci_devices = {}
local sdio_devices = {}
for device in env_devices:gmatch('[^,]+') do
local tp, class = device:match('([^:]+):(.*)')
if tp == "usb" then
table.insert(usb_devices, class)
elseif tp == "pci" then
table.insert(pci_devices, class)
elseif tp == "sdio" then
table.insert(sdio_devices, class)
else
WARN("Invalid device type, ignoring: " .. device)
end
end
devices = usb_devices
Export('devices')
Script('drivers/usb.lua')
devices = pci_devices
Script('drivers/pci.lua')
devices = sdio_devices
Script('drivers/sdio.lua')
Unexport('drivers')
end
-- Include contract if specified
local env_contract = os.getenv('BOOTSTRAP_CONTRACT')
if env_contract and env_contract ~= "" then
Script('contracts/' .. env_contract .. '.lua')
end
local env_testkey = os.getenv('BOOTSTRAP_TESTKEY')
if env_testkey and env_testkey ~= "" then
Install('cznic-repo-keys-test')
end
local env_initial_config = os.getenv('BOOTSTRAP_INITIAL_CONFIG')
if env_initial_config and env_initial_config ~= "" then
Install('initial-config')
end