Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] add checks for obsolete settings #1702

Merged
merged 1 commit into from Apr 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package/gluon-autoupdater/check_site.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ need_table({'autoupdater', 'branches'}, function(branch)
need_string_array_match(extend(branch, {'mirrors'}), '^http://')
need_number(in_site(extend(branch, {'good_signatures'})))
need_string_array_match(in_site(extend(branch, {'pubkeys'})), '^%x+$')
obsolete(in_site(extend(branch, {'probability'})), 'Use GLUON_PRIORITY in site.mk instead.')
end)
1 change: 1 addition & 0 deletions package/gluon-core/check_site.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ end
need_string_match(in_domain({'domain_seed'}), '^' .. ('%x'):rep(64) .. '$')

need_string({'opkg', 'openwrt'}, false)
obsolete({'opkg', 'lede'}, 'Use opkg.openwrt instead.')
need_table({'opkg', 'extra'}, function(extra_repo)
need_alphanumeric_key(extra_repo)
need_string(extra_repo)
Expand Down
32 changes: 24 additions & 8 deletions scripts/check_site.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ local function config_error(src, ...)
error(src .. ' error: ' .. string.format(...), 0)
end


local has_domains = (os.execute('ls -d "$IPKG_INSTROOT"/lib/gluon/domains/ >/dev/null 2>&1') == 0)


Expand Down Expand Up @@ -89,11 +88,7 @@ local function domain_src()
return 'domains/' .. domain_code .. '.conf'
end

local function var_error(path, val, msg)
if type(val) == 'string' then
val = string.format('%q', val)
end

local function conf_src(path)
local src

if has_domains then
Expand All @@ -108,15 +103,22 @@ local function var_error(path, val, msg)
src = site_src()
end

return src
end

local function var_error(path, val, msg)
if type(val) == 'string' then
val = string.format('%q', val)
end

local found = 'unset'
if val ~= nil then
found = string.format('%s (a %s value)', tostring(val), type(val))
end

config_error(src, 'expected %s to %s, but it is %s', path_to_string(path), msg, found)
config_error(conf_src(path), 'expected %s to %s, but it is %s', path_to_string(path), msg, found)
end


function in_site(path)
if has_domains and loadpath(nil, domain, unpack(path)) ~= nil then
config_error(domain_src(), '%s is allowed in site configuration only', path_to_string(path))
Expand Down Expand Up @@ -315,6 +317,20 @@ function need_domain_name(path)
end, nil, 'be a valid domain name')
end

function obsolete(path, msg)
local val = loadvar(path)
if val == nil then
return nil
end

if not msg then
msg = 'Check the release notes and documentation for details.'

end

config_error(conf_src(path), '%s is obsolete. %s', path_to_string(path), msg)
end

local check = assert(loadfile())

site = load_json(os.getenv('IPKG_INSTROOT') .. '/lib/gluon/site.json')
Expand Down