autoupdater: add possibility to specify mirrors on commandline (#123)

This commit is contained in:
Jan-Philipp Litza 2017-02-24 11:46:43 +01:00 committed by Matthias Schiffer
parent c7de283d44
commit 463f872844
1 changed files with 10 additions and 4 deletions

View File

@ -35,6 +35,7 @@ local force = false
-- timespan given by the priority and another 24h have passed
local fallback = false
local mirrors = {}
local function parse_args()
local i = 1
@ -52,9 +53,11 @@ local function parse_args()
end
branch_name = arg[i]
else
elseif arg[i]:sub(0, 1) == '-' then
io.stderr:write("Error parsing command line: unexpected argument '" .. arg[i] .. "'\n")
os.exit(1)
else
table.insert(mirrors, arg[i])
end
i = i+1
@ -350,10 +353,13 @@ if not lockfd:lock('tlock') then
end
local mirrors = branch.mirror
if #mirrors == 0 then
while #branch.mirror > 0 do
table.insert(mirrors, table.remove(branch.mirror, math.random(#branch.mirror)))
end
end
while #mirrors > 0 do
local mirror = table.remove(mirrors, math.random(#mirrors))
for k, mirror in ipairs(mirrors) do
if autoupdate(mirror) then
os.exit(0)
end