local pkgit = require("pkgit") local cfg = {} local prefix = os.getenv("HOME").."/.local" cfg.dirs = { -- where everything is downloaded/installed to prefix = prefix, src = prefix.."/share/pkgit", -- source code (before compile/install) is downloaded here bin = prefix.."/bin", lib = prefix.."/lib", include = prefix.."/include", } cfg.fetchers = {} -- fetches the source code and newest version of any given package cfg.fetchers.git = { -- returns the exit code. 0 is success, anything else is failure. get_source = function(url, version, name) return pkgit.run({ "git clone --branch "..version.." --recursive --depth 1 "..url.. " "..cfg.dirs.src.."/"..name.."/"..version }) end, -- returns a string get_version = function(url) return io.popen( "git -c 'versionsort.suffix=-' ls-remote --exit-code --refs --sort='version:refname' --tags "..url.." '*.*.*' | tail --lines=1 | cut --delimiter='/' --fields=3" ):read("*a") end, } -- the default fetch method (used when you don't provide one in pkgs) cfg.fetchers.default = cfg.fetchers.git cfg.recipes = {} cfg.recipes.make = { --setup = function() -- return 0 --end, build = function(bldit_build) return pkgit.run({"make"}, true) end, install = function(bldit_install) return pkgit.run({"make install PREFIX="..cfg.dirs.prefix}, true) end, remove = function(bldit_remove) return pkgit.run({"make uninstall PREFIX="..cfg.dirs.prefix}, true) end, } cfg.recipes.meson = { setup = function() return pkgit.run({"meson setup build --prefix "..cfg.dirs.prefix}, true) end, build = function() return pkgit.run({"meson compile -C build"}, true) end, install = function() return pkgit.run({"cd build && meson install"}, true) end, remove = function() return pkgit.run({"cd build && ninja uninstall"}, true) end, } cfg.pkgs = {} cfg.pkgs.pkgit = { url = "https://git.symlinx.net/pkgit", version = "HEAD", fetcher = cfg.fetchers.git, dependencies = { luajit = { url = "https://luajit.org/git/luajit.git", version = "v2.1", fetcher = cfg.fetchers.git, }}, opts = {}, recipe = cfg.recipes.make, } return cfg