aboutsummaryrefslogtreecommitdiff
path: root/config/pkgit.lua
diff options
context:
space:
mode:
Diffstat (limited to 'config/pkgit.lua')
-rw-r--r--config/pkgit.lua53
1 files changed, 53 insertions, 0 deletions
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