From 871a74bc862f8144ef736f0fed4c65b38c6a93ab Mon Sep 17 00:00:00 2001 From: Carlo Landmeter Date: Sat, 2 Dec 2017 11:41:53 +0000 Subject: move configuration to seperate file --- utils.lua | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'utils.lua') diff --git a/utils.lua b/utils.lua index d53100a..45af153 100644 --- a/utils.lua +++ b/utils.lua @@ -1,10 +1,6 @@ -local M = {} - +local conf = require("config") -M.allowed = { - archs = { x86=1, x86_64=2, armhf=3, aarch64=4, ppc64le=5, s390x=6 }, - repos = { main=1, community=2, testing=3, backports=4 } -} +local M = {} function M.in_array(t, value) for k,v in ipairs(t) do @@ -27,6 +23,16 @@ function M.write_file(file, string) file:close() end +---- +-- convert array to list +function M.to_list(t) + local res = {} + for k,v in ipairs(t) do + res[v] = k + end + return res +end + ---- -- table iterator which sorts on keys function M.kpairs(t, f) @@ -51,7 +57,7 @@ end ---- -- repo sort function for kpairs function M.sort_repo(a,b) - local repos = M.allowed.repos + local repos = M.to_list(conf.repos) if type(repos[a]) == "number" and type(repos[b]) == "number" then if repos[a] < repos[b] then return true end end @@ -60,7 +66,7 @@ end ---- -- arch sort function for kpairs function M.sort_arch(a,b) - local archs = M.allowed.archs + local archs = M.to_list(conf.archs) if type(archs[a]) == "number" and type(archs[b]) == "number" then if archs[a] < archs[b] then return true end end -- cgit v1.2.3