From db48b6b6931d5b9df7be3d761b163519a887095e Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 15 May 2022 02:39:36 +0200 Subject: [PATCH] gluon-autoupdater: check default branch name Check the default branch (both from site.conf and GLUON_AUTOUPDATER_BRANCH) against the list of configured branch names to avoid misconfiguration. --- package/gluon-autoupdater/check_site.lua | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/package/gluon-autoupdater/check_site.lua b/package/gluon-autoupdater/check_site.lua index eaabf285..04c88a13 100644 --- a/package/gluon-autoupdater/check_site.lua +++ b/package/gluon-autoupdater/check_site.lua @@ -1,6 +1,4 @@ -need_string(in_site({'autoupdater', 'branch'}), false) - -need_table({'autoupdater', 'branches'}, function(branch) +local branches = table_keys(need_table({'autoupdater', 'branches'}, function(branch) need_alphanumeric_key(branch) need_string(in_site(extend(branch, {'name'}))) @@ -8,4 +6,15 @@ need_table({'autoupdater', 'branches'}, function(branch) 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) +end)) + +need_one_of(in_site({'autoupdater', 'branch'}), branches, false) + +-- Check GLUON_AUTOUPDATER_BRANCH +local default_branch +local f = io.open((os.getenv('IPKG_INSTROOT') or '') .. '/lib/gluon/autoupdater/default_branch') +if f then + default_branch = f:read('*line') + f:close() +end +need_one_of(value('GLUON_AUTOUPDATER_BRANCH', default_branch), branches, false)