aboutsummaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/init.lua307
-rw-r--r--config/types.lua35
2 files changed, 100 insertions, 242 deletions
diff --git a/config/init.lua b/config/init.lua
index 0557a89..2a9dce2 100644
--- a/config/init.lua
+++ b/config/init.lua
@@ -1,247 +1,70 @@
---[[ introduction
-
- this is the pkgit configuration template.
- every configuration file is written in lua,
- the embeddable high-level programming language.
-
- for info on how to write lua, check out
- this website for documentation:
- https://www.lua.org/pil/contents.html
-
- all variables that are
- set by default are designed to
- work out of the box. be sure to
- keep the global variables global,
- as they need to be global in
- order for them to work with
- each other effectively.
-
- `local install_directories`, for
- example, will not work well in
- most cases.
-
-]]
-
---[[ prefix
-
- the prefix variable is necessary
- for custom install paths, which
- bldit maintainers should be
- respecting with their recipes.
-
- if you want to install packages
- without root, it's easist to
- create a home variable and
- append that to your prefix.
-
-]]
-local home = os.getenv("HOME")
-prefix = home.."/.local"
-
---[[ install_directories
-
- install_directories is an essential
- table that pkgit needs in order to
- function. this is how it determines
- where you install your packages to.
-
- it's most convenient when combined
- with `prefix` which allows for a
- more dynamic definition of your
- install directories.
-
-]]
-install_directories = {
- bin = prefix.."/bin", -- binaries (executables)
- -- the value of `bin` should also be set in your shell's $PATH
- include = prefix.."/include", -- C headers
- lib = prefix.."/lib", -- libraries (shared objects)
- src = prefix.."/share/pkgit", -- source code
+local pkgit = require("pkgit")
+local cfg = {}
+
+local prefix = os.getenv("HOME") .. "/.local"
+cfg.dirs = {
+ prefix = prefix,
+ src = prefix .. "/share/pkgit",
+ bin = prefix .. "/bin",
+ lib = prefix .. "/lib",
+ include = prefix .. "/include",
}
---[[ repositories
-
- this is where all your repos need to
- end up. every repo has a name, which
- can be written out normally
- (`name = {...}`), or for some repos,
- it might be necessary to wrap it in
- quotes (`["name"] = {...}`).
- that name can be used in a pkgit
- command to be installed.
- ( `pkgit --install [repo]` )
-
- each of these repos must be structured
- as a lua table. the structure is
- demonstrated below.
-
-]]
-repositories = {
- pkgit = {
- url = "https://git.symlinx.net/pkgit",
- --[[ repo example
-
- no targets table or dependencies are actually needed in
- this specific case, pkgit has a bldit.lua which guarantees
- that it will compile & install (as long as `install_directories`
- and `prefix` are set up).
-
- if you do make a targets table here, it will take priority
- over the bldit.lua in the repo, and your build system
- autodetection config ( `build_systems = {...}` )
-
- more about `targets` in the global `build_systems` table.
-
- ]]
- --dependencies = {
- -- name = {
- -- url = {...},
- -- version = "...",
- -- target = "...",
- -- },
- --},
- --targets = {
- -- default = {
- -- build = function()
- -- return os.execute("make")
- --
- -- -- ^ make sure to return the exit code of os.execute ^ --
- --
- -- end,
- -- install = function()
- -- return os.execute("make install PREFIX="..prefix)
- -- end,
- -- uninstall = function()
- -- return os.execute("make uninstall PREFIX="..prefix)
- -- end,
- -- }
- --}
- },
+cfg.pkgs = {
+ ["gmp"] = {},
+ ["mpfr"] = {},
+ ["mpc"] = {},
+ ["gcc"] = {
+ url = "https://ftp.gnu.org/gnu/gcc/gcc-16.1.0/gcc-16.1.0.tar.xz",
+ version = "16.1.0",
+ fetcher = cfg.fetchers.tarball,
+ dependencies = {
+ "gmp", "mpfr", "mpc"
+ }
+ },
+ ["luajit"] = {
+ url = "https://luajit.org/git/luajit.git",
+ version = "v2.1",
+ fetcher = cfg.fetchers.git,
+ dependencies = {
+ "gcc"
+ },
+ },
+ ["pkgit"] = {
+ url = "https://git.symlinx.net/pkgit",
+ version = "HEAD",
+ fetcher = cfg.fetchers.git,
+ dependencies = {
+ "luajit",
+ },
+ opts = {},
+ recipe = cfg.recipes.make,
+ }
}
---[[ build_systems
-
- this table contains all of the automatic
- build system detection necessary for pkgit
- to work without bldit.lua or `repositories = {...}`.
-
- this works by creating a table named after the
- filename associated with the build system that
- is found in the root directory of a package.
-
- by associating a filename with a build system,
- pkgit can dynamically compile and install any
- package, given that they use the build system
- according to the standard (or otherwise
- generally popular) usage guidelines.
-
-]]
-build_systems = {
- ["Makefile"] = {
- --[[ targets
-
- briefly mentioned above in `repositories`,
- the `targets` subtable is a standard that's
- consistent across all the different methods
- to build a package using pkgit; meaning
- you can write the same `targets` subtable
- in `repositories.<pkg>`, `bldit.lua`, and
- right here in `build_systems`.
-
- this table comes with two templates;
- `default` and `quiet`. the first is pretty
- self-explanatory; this is what you'd define
- as the default intended behavior of the
- build system.
-
- `quiet` is similar to `default`, in the sense
- that it inherits the default intended behavior,
- except that it does so while printing nothing
- to the terminal. instead, ideally, it would
- output its logs to a temporary file accessible
- by the user running the command.
-
- this is why the default logs in this example
- are located in `/tmp` and not `/var/log`,
- because the user typically has full access to
- `/tmp`, and normally not `/var/log`.
-
- ]]
- targets = {
- default = {
- build = function()
- return os.execute("make")
- end,
- install = function()
- return os.execute("make install PREFIX="..prefix)
- end,
- uninstall = function()
- return os.execute("make uninstall PREFIX="..prefix)
- end,
- },
- quiet = {
- build = function()
- return os.execute("make &>/tmp/pkgit_build.log")
- end,
- install = function()
- return os.execute("make install PREFIX="..prefix.." &>/tmp/pkgit_build.log")
- end,
- uninstall = function()
- return os.execute("make uninstall PREFIX="..prefix.." &>/tmp/pkgit_build.log")
- end,
- },
- }
- },
- ["meson.build"] = {
- targets = {
- default = {
- build = function()
- return os.execute("meson setup build --prefix "..prefix.." && meson compile -C build")
- end,
- install = function()
- return os.execute("cd build && meson install")
- end,
- uninstall = function()
- return os.execute("cd build && ninja uninstall")
- end,
- },
- quiet = {
- build = function()
- return os.execute("meson setup build --prefix "..prefix.." &>/tmp/pkgit_build.log && meson compile -C build &>/tmp/pkgit_build.log")
- end,
- install = function()
- return os.execute("cd build && meson install &>/tmp/pkgit_build.log")
- end,
- uninstall = function()
- return os.execute("cd build && ninja uninstall &>/tmp/pkgit_build.log")
- end,
- },
- }
- },
- ["CMakeLists.txt"] = {
- targets = {
- default = {
- build = function()
- return os.execute("cmake -B build && cmake --build build")
- end,
- install = function()
- return os.execute("cmake --build . --target install")
- end,
- uninstall = function()
- return os.execute("xargs rm < install_manifest.txt")
- end,
- },
- quiet = {
- build = function()
- return os.execute("cmake -B build &>/tmp/pkgit_build.log && cmake --build build &>/tmp/pkgit_build.log")
- end,
- install = function()
- return os.execute("cmake --build . --target install &>/tmp/pkgit_build.log")
- end,
- uninstall = function()
- return os.execute("xargs rm < install_manifest.txt &>/tmp/pkgit_build.log")
- end,
- },
- }
- },
+cfg.fetchers = {
+ git = {
+ get_source = function(url, version, target_dir) return 0 end,
+ get_version = function(url, target_dir) return "HEAD" end,
+ },
+ tarball = {
+ get_source = function(url, version, target_dir) return 0 end,
+ get_version = function(url, target_dir) return "" end,
+ }
+}
+cfg.fetchers.default = cfg.fetchers.git
+
+cfg.recipes = {}
+cfg.recipes.make = {
+ build = function(bldit_build)
+ return pkgit.run({ "make" })
+ end,
+ install = function(bldit_install)
+ return pkgit.run({ "make install PREFIX=" .. prefix })
+ end,
+ remove = function(bldit_remove)
+ return pkgit.run({ "make uninstall PREFIX=" .. prefix })
+ end,
}
+
+return cfg
diff --git a/config/types.lua b/config/types.lua
new file mode 100644
index 0000000..10a444d
--- /dev/null
+++ b/config/types.lua
@@ -0,0 +1,35 @@
+---@class (exact) Dirs
+---@field prefix string
+---@field bin string
+---@field include string
+---@field lib string
+---@field src string
+
+---@class (exact) Recipe
+---@field setup (fun(bldit_setup: fun()): number)?
+---@field build fun(bldit_build: fun()): number
+---@field install fun(bldit_install: fun()): number
+---@field remove fun(bldit_remove: fun()): number
+---@field on_update (fun(bldit_on_update: fun()): number)?
+
+---@type Recipe
+---@alias GetSourcesFn fun(url: string, version: string, target_dir: string): number
+---@alias GetVersionFn fun(url: string, target_dir: string): string
+
+---@class (exact) Fetcher
+---@field get_sources GetSourcesFn
+---@field get_version GetVersionFn
+
+---@class (exact) Package
+---@field url string
+---@field version string?
+---@field fetcher Fetcher | nil
+---@field dependencies { [string]: Package } | "bldit" | nil
+---@field opts table?
+---@field recipe Recipe | "bldit" | nil
+
+---@class (exact) Config
+---@field dirs Dirs
+---@field fetchers { [string]: Fetcher }
+---@field recipes { [string]: Recipe }
+---@field pkgs { [string]: Package }