2019-06-14 17:20:15 +00:00
|
|
|
local ret = 0
|
|
|
|
|
|
|
|
|
|
|
|
local function fail(...)
|
|
|
|
if ret == 0 then
|
|
|
|
ret = 1
|
|
|
|
io.stderr:write('Configuration failed:', '\n')
|
|
|
|
end
|
|
|
|
|
|
|
|
io.stderr:write(' * ', string.format(...), '\n')
|
|
|
|
end
|
|
|
|
|
|
|
|
local function match_config(f)
|
|
|
|
for line in io.lines('openwrt/.config') do
|
|
|
|
if f(line) then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
local function check_config(pattern)
|
|
|
|
return match_config(function(line) return line == pattern end)
|
|
|
|
end
|
|
|
|
|
|
|
|
local function check_config_prefix(pattern)
|
|
|
|
return match_config(function(line) return string.sub(line, 1, -2) == pattern end)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2019-06-17 23:33:12 +00:00
|
|
|
local funcs = {}
|
2019-06-14 17:20:15 +00:00
|
|
|
|
2019-06-17 23:33:12 +00:00
|
|
|
function funcs.config_message(_, message, ...)
|
2019-06-14 17:20:15 +00:00
|
|
|
local pattern = string.format(...)
|
|
|
|
|
|
|
|
if not check_config(pattern) then
|
|
|
|
fail('%s', message)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-06-17 23:33:12 +00:00
|
|
|
function funcs.config_package(_, pkg, value)
|
2019-06-14 17:20:15 +00:00
|
|
|
local pattern = string.format('CONFIG_PACKAGE_%s=%s', pkg, value)
|
2019-06-17 23:33:12 +00:00
|
|
|
local res
|
2019-06-14 17:20:15 +00:00
|
|
|
if value == 'y' then
|
|
|
|
res = check_config(pattern)
|
|
|
|
else
|
|
|
|
res = check_config_prefix(string.sub(pattern, 1, -2))
|
|
|
|
end
|
|
|
|
|
|
|
|
if not res then
|
|
|
|
fail("unable to enable package '%s'", pkg)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-06-17 23:33:12 +00:00
|
|
|
local lib = dofile('scripts/target_config_lib.lua')(funcs)
|
2019-06-14 17:20:15 +00:00
|
|
|
|
2019-06-17 23:33:12 +00:00
|
|
|
for config, v in pairs(lib.configs) do
|
|
|
|
if v == 2 then
|
|
|
|
if not check_config(config) then
|
|
|
|
fail("unable to set '%s'", config)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-06-14 17:20:15 +00:00
|
|
|
|
|
|
|
os.exit(ret)
|