README.md (3282B)
1 mag 2 === 3 4 The package manager, one C file. It installs prebuilt packages from apk and pacman repos: it reads their signed 5 index, works out what a package needs, checks every download against the index and its signature, and puts 6 the files in place. gzip, zstd, tar, rsa, ed25519, OpenPGP and plain http are in mag itself; for https it runs a 7 download command (curl, else wget, else ftp). 8 9 ./build.sh builds ./mag on c.h (x86_64) 10 cc -DLIBC -static mag.c builds it on a libc, for any other cpu 11 12 mag update gets the index of every repo 13 mag install tmux tmux and what it needs, after a y 14 mag remove tmux mag help has the rest 15 16 `/etc/mag/repos` has one repo a line (the url above the arch directory), `/etc/mag/keys` the public keys the 17 indexes are signed with, `/etc/mag/arch` which builds to get, `x86_64` or `x86` and so on. It is written on 18 the first install, and without it mag goes by the machine. 19 20 CRUX ports work too. A line `crux https://crux.nu/ports/crux-3.8/opt` in `/etc/mag/repos` is a port tree: `mag 21 update` gets the files that changed, as httpup does, and `mag build foo` builds the port and installs it. The 22 `.signature` of the port is checked with its key (`opt.pub` in `/etc/mag/keys`, ed25519 is in mag too), then 23 the sources against it, and `build()` runs with bash. What a repo has built wins over a port of the same name; 24 `mag install` takes a port only when no repo has it. A port gets build-base, pkgconf and bash, and the `-dev` 25 package of every dependency that comes built. 26 27 Void and Exherbo work as well: `void https://github.com/void-linux/void-packages` and `exherbo 28 https://gitlab.exherbo.org/exherbo/arbor`. `mag update` gets the tree as a tarball. A Void template is run with 29 the helpers in the tree's `common/`, as xbps-src runs it, and its sources are checked against the template's sha256. 30 An exheres is run on a small exheres-0 in mag, with the tree's exlibs. Neither tree is signed, and exheres have no 31 checksums for their sources. 32 33 pacman repos are read as they are: `pacman https://geo.mirror.pkgbuild.com/extra/os` (the url above the arch 34 directory). mag reads the database, checks a package against its sha256 there and its OpenPGP signature (RSA or 35 ed25519) with the keyrings in `/usr/share/pacman/keyrings` and any `*.gpg` in `/etc/mag/keys`, runs its 36 `.INSTALL` and, after the run, the hooks in `/usr/share/libalpm/hooks` as pacman does. A name in two pacman repos 37 comes from the first, as in pacman. `aur https://aur.archlinux.org` adds the AUR: its metadata dump is the index, 38 and a package is built with makepkg as nobody, with its build dependencies from the binary repos first. 39 40 What it does on the way: files are checked against what other packages own before anything is touched, they 41 are put in place with a rename so a running program is never half written, and a changed file under /etc is 42 left alone (the new one comes as `.new`). A package's scripts run inside the root; one whose interpreter is not 43 installed yet waits until the end. Every package keeps its file list in `var/lib/mag`, so `remove`, `files`, 44 `owns` and `autoremove` need nothing else. 45 46 `MAG_ROOT` installs somewhere else than /, `MAG_ARCH` overrides the arch, `MAG_FETCH` is the download command.