From e2cda84ebbd073ece54692c6a3d785afc6148268 Mon Sep 17 00:00:00 2001 From: dacctal Date: Mon, 27 Jul 2026 04:38:32 +0000 Subject: added some config stuff --- config/pkgit.lua | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 config/pkgit.lua (limited to 'config/pkgit.lua') diff --git a/config/pkgit.lua b/config/pkgit.lua new file mode 100644 index 0000000..718e761 --- /dev/null +++ b/config/pkgit.lua @@ -0,0 +1,53 @@ +-- std pkgit functions + +local M = {} + +function M.run(items, verbose) + local cmd = io.popen('set -e &&\n'..table.concat(items,"&&\n")) + if cmd == nil then return 1 end + if verbose then print(cmd:read("*a")) end + local rc = {cmd:close()} + if rc[1] then return 0 + else return 1 + end +end + +function M.join(t1, ...) + local new = t1 + local tables = { ... } + for _, new_table in ipairs(tables) do + for index, val in ipairs(new_table) do + if val ~= nil then + new[index] = val + end + end + end + return new +end + +function M.exists(s) + local file = io.open(s, "r") + if file ~= nil then + io.close(file) + return true + else + return false + end +end + +function M.autodetect(builds, final_dir) + for k, system in pairs(builds) do + for i, file in pairs(system.files) do + if M.exists(final_dir.."/"..file) then + return system.step + end + end + end +end + +function M.destdir(name, version) + if version == nil then version = "HEAD" end + return cfg.dirs.src.."/"..name.."/"..version +end + +return M -- cgit v1.2.3