Skip to content

Commit

Permalink
gluon-autoupdater: make site.conf branch setting optional
Browse files Browse the repository at this point in the history
Default to the alphabetically smallest branch if none is set in
site.conf.

Also prevent enabling the autoupdater when no branches exist.
  • Loading branch information
neocturne committed Aug 15, 2020
1 parent ee53357 commit d82ffb4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package/gluon-autoupdater/check_site.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
need_string(in_site({'autoupdater', 'branch'}))
need_string(in_site({'autoupdater', 'branch'}), false)

need_table({'autoupdater', 'branches'}, function(branch)
need_alphanumeric_key(branch)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ local uci = require('simple-uci').cursor()
local unistd = require 'posix.unistd'


local min_branch

for name, config in pairs(site.autoupdater.branches()) do
uci:delete('autoupdater', name)
uci:section('autoupdater', 'branch', name, {
Expand All @@ -13,18 +15,26 @@ for name, config in pairs(site.autoupdater.branches()) do
good_signatures = config.good_signatures,
pubkey = config.pubkeys,
})

if not min_branch or (name < min_branch) then
min_branch = name
end
end

if not uci:get('autoupdater', 'settings') then
local enabled = unistd.access('/lib/gluon/autoupdater/default_enabled') ~= nil

local branch = site.autoupdater.branch()
local branch = site.autoupdater.branch(min_branch)
local f = io.open('/lib/gluon/autoupdater/default_branch')
if f then
branch = f:read('*line')
f:close()
end

if not branch then
enabled = false
end

uci:section('autoupdater', 'autoupdater', 'settings', {
enabled = enabled,
branch = branch,
Expand Down

0 comments on commit d82ffb4

Please sign in to comment.