aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: db62514a12e376ae25e09617267f4281ba6a5e6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
<div align="center">

<h1>pkgit</h1>
(package it!)

</div>

# What is this?
pkgit is an unconventional package manager designed to compile & install packages directly from their git repository.

> ***[DISCLAIMER]***
>
> Due to the nature of pkgit, you are solely responsible for vetting the repos that you add to your system.
>
> Use at your own risk.

# Compile pkgit
Enter the project directory, and follow one of the following procedures.

## Using Make
```
make
```

## Using pkgit
```
pkgit build
```
Both methods will create an executable in the root directory of the project.

You'll probably also want to generate a base configuration file if you don't already have one.
Run this as a user to generate the config:
```
make defconfig
```

# Install pkgit
After compiling, run the following with root privilages:
```
make install
```

## Don't have root?
You can specify any install location with `PREFIX=<path>`:
```
make install PREFIX="/path/to/install"
```

# Usage
## Installing Packages
### Basic install
Assuming you have already added its respective repo, you can install a package by specifying its name:
```
pkgit install [pkg_name]
```
Or you can use the short command:
```
pkgit i [pkg_name]
```

### Specific version install
You can specify a version of any package based on its tags with '@' separating the name from the version:
```
pkgit install [pkg_name]@[version]
```

### Repo install
If you haven't added the package's repository yet, or you just want to be specific, you can install the package using its git URL:
```
pkgit install [url.git]
```

## Removal
### Packages
Removing (uninstalling) a package is as simple as it seems:
```
pkgit remove [pkg_name]
```
Or the short command:
```
pkgit r [pkg_name]
```

## Dependency Management
As it is, pkgit is capable of dependency management, but you will likely have to specify the dependency URLs for each package you install in `<config_directory>/pkgit/init.lua`. There's not a universal way to check for dependencies without using an existing package manager (unless the package you're installing has a bldit.lua).

### Configuring pkgit
Thankfully, this is a very simple process.

To configure pkgit, you have one centralized configuration file: `<config_directory>/pkgit/init.lua`
Thanks to liblua, pkgit pushes a package.path variable directly to your configuration file.
This means that you can require any sub-file/directory, without wrestling with `require()`.

The overall structure of the configuration file looks like this:
```lua
--[[
  - install directories -
  this is where every package you
  get with pkgit is installed,
  with respect to each of it's
  files' types:

  install_directories = {
    bin     = "...",
    include = "...",
    lib     = "...",
    src     = "...",
  }

  it is recommended that you create
  a prefix variable to prepend to
  these directories, like so:
]]
local prefix = os.getenv("HOME").."/.local" -- for user-level installs
install_directories = {
  bin     = prefix.."/bin",
  include = prefix.."/include",
  lib     = prefix.."/lib",
  src     = prefix.."/src",
}

--[[
  - your repositories -
  this is where you store your
  own custom urls, dependencies,
  and functions to install
  whatever programs you desire.
]]
repositories = {
  example_name = {
    url = "https://...",
    version = "v0.0.0",
    dependencies = {
      ...
    },
    build = function() ... end
    pre_install = function() ... end
    install = function() ... end
    post_install = function() ... end
  }
}
--[[
  pkgit also creates a 'repos.lua' file in
  your config directory,  which you can
  require here to automatically add repos
  that you install from.
]]
require('repos')

--[[
  - standard build systems -
  will be auto-detected if required
  functions aren't in 'repositories'
  or a repo's 'bldit.lua'
]]
build_systems = {
  ["filename.extension"] = {
    build = function() ... end
    pre_install = function() ... end
    install = function() ... end
    post_install = function() ... end
  }
}
```

For each dependency, all you need to do is paste the dependency's remote git URL in its own url variable.

Here's an example for mush:
```lua
repositories = {
  mush = {
    url = "https://github.com/dacctal/mush",
    dependencies = {
      mpv = { url = "https://github.com/mpv-player/mpv" },

      ["yt-dlp"] = { url = "https://github.com/yt-dlp/yt-dlp" },
      --[[
        for dependencies with names that contain illegal
        characters in lua, you'll want to wrap them in
        [""] to avoid problems.
      ]]

      ffmpeg = { url = "https://github.com/FFmpeg/FFmpeg" },
      curl = { url = "https://github.com/curl/curl" },
      mutagen = { url = "https://github.com/quodlibet/mutagen" }
    }
  }
}
```

That's it! pkgit will read from this file and resolve these
dependencies automatically.

### [DEVELOPER]: bldit.lua
If you want your own package's dependencies, version, compilation,
and other aspects to be properly resolved in pkgit, you can create a
`bldit.lua` file in the root directory of your project's git repo.

Do not name it anything other than `bldit.lua`, otherwise pkgit
will not find the file.

> [!WARNING]
> Recursive dependency management does NOT work in pkgit, so you may want to list your dependencies accordingly.

Example `bldit.lua` that works for pkgit:
```lua
bldit_version = "0.0.0"
package_version = "0.0.0"
--[[
  versions have to be strings, 
  because some devs like to
  have fun and whimsical
  version numbers :D
]]

global_dependencies = {}
-- dependencies for all targets

targets = {
	default = {
		dependencies = {},
		-- target-specific dependencies
		build = function(name)
			os.execute("make")
		end,
		pre_install = function() end,
		install = function(prefix)
			os.execute("make install")
		end,
		post_install = function() end,
	}
	--[[
    could also have targets for 'client'
    or 'server.' useful for monorepos
    and related use-cases.
	]]
}
```

# Contributing to pkgit
To contribute to pkgit, you should go to the xmpp muc *pkgit@muc.symlinx.net* and drop your patch file which *should* contain the commits you made.