handbook-mag.html (11573B)
1 <!doctype html> 2 <html lang="en"> 3 <head> 4 <meta charset="utf-8"> 5 <meta name="viewport" content="width=device-width, initial-scale=1"> 6 <title>mag - Chamesle</title> 7 <meta name="description" content="mag is the package manager. It installs binary packages from the repositories in /etc/mag/repos, checks every index"> 8 <link rel="canonical" href="https://chamesle.org/handbook-mag.html"> 9 <meta property="og:type" content="website"> 10 <meta property="og:site_name" content="Chamesle"> 11 <meta property="og:title" content="mag - Chamesle"> 12 <meta property="og:description" content="mag is the package manager. It installs binary packages from the repositories in /etc/mag/repos, checks every index"> 13 <meta property="og:url" content="https://chamesle.org/handbook-mag.html"> 14 <link rel="stylesheet" href="style.css?25"> 15 <link rel="icon" href="img/logo.png"> 16 </head> 17 <body> 18 19 <div id="page"> 20 21 <div id="top"> 22 <h1><a href="./"><img src="img/banner.png" alt="Chamesle Linux" width="223" height="56"></a></h1> 23 </div> 24 25 <div id="nav"> 26 <a href="./">Home</a> | 27 <a href="download.html">Download</a> | 28 <b>Handbook</b> | 29 <a href="packages.html">Packages</a> | 30 <a href="new.html">News</a> | 31 <a href="board.html">Board</a> | 32 <a href="chat.html">Chat</a> | 33 <a href="source.html">Source</a> | 34 <a href="https://x22.chamesle.org/">X22</a> | 35 <a href="https://github.com/tortr-rs/mag">mag</a> | 36 <a href="about.html">About</a> 37 </div> 38 39 <main> 40 <p><a href="handbook-installing.html">← Installing</a> | <a href="docs.html">Contents</a> | <a href="handbook-rifle.html">rifle →</a></p> 41 <h2>4. mag</h2> 42 <p>mag is the package manager. It installs binary packages from the repositories in <code>/etc/mag/repos</code>, checks every index and every package against <code>/etc/mag/keys</code>, and keeps what it installed in <code>/var/lib/mag</code>. It is one C file and runs nothing but the download command, and bash when it builds from a source tree (4.6, 4.7).</p> 43 <h2 id="s4-1">4.1 The commands</h2> 44 <pre>mag update get the index of every repo 45 mag install PKG... install, with what they need 46 mag build PKG... build them from a source tree: CRUX, Void or Exherbo (4.6, 4.7) 47 mag remove PKG... take packages off 48 mag upgrade install what the repos have a newer version of 49 mag autoremove remove what was only a dependency and is not needed now 50 mag list what is installed 51 mag info PKG version, size, description, and whether it is installed 52 mag search WORD names and descriptions 53 mag files PKG the files a package put on the system 54 mag owns PATH which package a file came from 55 mag deps PKG what it needs; rdeps PKG for what needs it 56 mag fetch PKG... only download them</pre> 57 <p>Before it installs or removes anything it lists the packages, where they come from and their sizes, and asks. <code>-n</code> says what would happen and does nothing, <code>-f</code> goes on when files clash or something still needs a package. <code>-y</code> or <code>MAG_YES=1</code> answers yes, for scripts. <code>MAG_ROOT=/mnt mag ...</code> works on another root, which is what chamesle-bootstrap does.</p> 58 <h2 id="s4-2">4.2 Installing and removing</h2> 59 <pre>mag install vim 60 mag -n install xorg-server what would come with it 61 mag remove vim</pre> 62 <p>Before it unpacks anything, mag checks each file against what other packages own and stops if two packages want the same file. A file under <code>/etc</code> that you changed stays, and the new one is written next to it as <code>NAME.new</code>. Packages carry scripts that run after they are installed, and triggers that run when a directory they watch changes, like the one that makes the initramfs when a kernel is installed.</p> 63 <p>A name can also be what a package provides: <code>mag install cmd:htop</code> installs the package that has the command.</p> 64 <h2 id="s4-3">4.3 Where it keeps things</h2> 65 <table> 66 <tr><th>what</th><th>where</th></tr> 67 <tr><td>the repositories</td><td><code>/etc/mag/repos</code>, one URL a line</td></tr> 68 <tr><td>the keys</td><td><code>/etc/mag/keys</code></td></tr> 69 <tr><td>the architecture</td><td><code>/etc/mag/arch</code></td></tr> 70 <tr><td>installed packages</td><td><code>/var/lib/mag/NAME/</code>: <code>version</code>, <code>files</code>, <code>deps</code>, <code>explicit</code> and the scripts</td></tr> 71 <tr><td>indexes and downloads</td><td><code>/var/cache/mag</code></td></tr> 72 </table> 73 <h2 id="s4-4">4.4 Repositories</h2> 74 <pre>https://chamesle.org/repo 75 https://dl-cdn.alpinelinux.org/alpine/edge/main 76 https://dl-cdn.alpinelinux.org/alpine/edge/community</pre> 77 <p>Each line is the URL above the directory of the architecture: mag adds <code>/x86_64/APKINDEX.tar.gz</code>. A repository you add needs its key in <code>/etc/mag/keys</code>. <code>mag update</code> after any change.</p> 78 <h2 id="s4-5">4.5 Making a package</h2> 79 <p><code>tools/mkapk</code> packs a directory, signs it and leaves its index entry; <code>tools/mkrepo</code> signs the index of a directory of them:</p> 80 <pre>mkapk -k KEY -n hello -v 1.0 -a x86_64 -d "says hello" -D "musl" -o repo/x86_64 ./root 81 mkrepo repo/x86_64 KEY</pre> 82 <p>Put the public half of KEY in <code>/etc/mag/keys</code> and the repo's URL in <code>/etc/mag/repos</code>. <code>tools/mkpkgs</code> is how Chamesle's own repo is made.</p> 83 <h2 id="s4-6">4.6 CRUX ports</h2> 84 <p>mag also builds from CRUX's port trees. A line that starts with <code>crux</code> is a tree of ports, and its key goes next to the others:</p> 85 <pre>echo 'crux https://crux.nu/ports/crux-3.8/opt' >> /etc/mag/repos 86 curl -o /etc/mag/keys/opt.pub https://crux.nu/ports/crux-3.8/core/ports/opt.pub 87 mag update 88 mag build foo</pre> 89 <p><code>mag update</code> gets only the ports that changed, as httpup does, into <code>/var/cache/mag</code>. Every port's <code>.signature</code> is checked with the key, then its sources against the signature, and its <code>build()</code> runs with bash. <code>core</code>, <code>xorg</code> and <code>contrib</code> work the same way, with <code>core.pub</code>, <code>xorg.pub</code> and <code>contrib.pub</code>.</p> 90 <p>A package the binary repos have wins over a port of the same name: <code>mag install</code> takes a port only when nothing has it built, <code>mag build</code> always takes the port. A port brings build-base, pkgconf and bash with it, and the <code>-dev</code> package of every dependency that comes built. The flags go in <code>/etc/mag/build.conf</code>, otherwise it is <code>-O2 -pipe</code> and one job per core:</p> 91 <pre>CFLAGS="-O2 -pipe -march=native" 92 MAKEFLAGS="-j4"</pre> 93 <p>What a port installs is a package like any other: <code>mag files</code>, <code>mag remove</code> and <code>mag upgrade</code> work on it.</p> 94 <h2 id="s4-7">4.7 Void and Exherbo</h2> 95 <p>mag builds Void's templates and Exherbo's exheres too, from their git trees:</p> 96 <pre>echo 'void https://github.com/void-linux/void-packages' >> /etc/mag/repos 97 echo 'exherbo https://gitlab.exherbo.org/exherbo/arbor' >> /etc/mag/repos 98 mag update 99 mag build tmux</pre> 100 <p><code>mag update</code> gets the whole tree as one tarball, about 9 MB for Void and 2 MB for arbor, and indexes it. Neither tree is signed: what you get is what GitHub or Exherbo's GitLab sent over https. A Void template has the sha256 of each of its sources, and mag checks them. An exheres has none, so its sources are as good as the connection they came over.</p> 101 <p>A Void template runs with the helpers in the tree's <code>common/</code>, the way xbps-src runs it: the build style (<code>gnu-configure</code>, <code>cmake</code>, <code>meson</code> and the others), <code>vinstall</code>, <code>vmove</code> and the rest, and Void's patches. What Void splits into subpackages stays in one package here: <code>mag build libzstd</code> builds zstd. A <code>-devel</code> it needs is the <code>-dev</code> of the binary repos.</p> 102 <p>An exheres runs on a small exheres-0 of mag's own, with the exlibs of the tree. Options are what Exherbo's profile turns on, without systemd and pam. Exherbo puts programs in <code>/usr/x86_64-...-musl/bin</code>; mag builds them there and moves them to <code>/usr</code> afterwards. Arbor is Exherbo's main tree, about 1000 packages; the others are on the same GitLab and work the same way.</p> 103 <p>When two trees have a package, <code>mag build</code> takes the newer version. A package the binary repos split differently, like xz with its <code>xz-libs</code>, clashes with what is installed, and mag stops; <code>-f</code> writes over it.</p> 104 <h2 id="s4-8">4.8 pacman repos and the AUR</h2> 105 <p>The glibc Chamesle (1.3) runs on pacman repos, which mag reads natively. Its <code>/etc/mag/repos</code>:</p> 106 <pre>https://chamesle.org/repo/glibc 107 pacman https://mirrors.dotsrc.org/artix-linux/repos/system/os 108 pacman https://mirrors.dotsrc.org/artix-linux/repos/world/os 109 pacman https://mirrors.dotsrc.org/artix-linux/repos/galaxy/os 110 pacman https://mirrors.dotsrc.org/artix-linux/repos/lib32/os 111 pacman https://geo.mirror.pkgbuild.com/extra/os 112 pacman https://geo.mirror.pkgbuild.com/multilib/os 113 aur https://aur.archlinux.org</pre> 114 <p>A <code>pacman</code> line is the URL above the architecture's directory; the database is named after the last part before <code>os</code> (<code>system.db</code>). As in pacman, a package that two repos have comes from the first one, so Artix's OpenRC builds win over Arch's systemd ones. Any other mirror of the same repos works the same.</p> 115 <p>Packages are checked against their sha256 in the database and their OpenPGP signature, with the keyrings of <code>artix-keyring</code> and <code>archlinux-keyring</code> in <code>/usr/share/pacman/keyrings</code> (RSA and ed25519, without the revoked keys), and any <code>*.gpg</code> in <code>/etc/mag/keys</code>. A package's <code>.INSTALL</code> runs as its scripts, and after every run mag runs the hooks in <code>/usr/share/libalpm/hooks</code> and <code>/etc/pacman.d/hooks</code>, the way pacman does: they make the initramfs, the system users, the linker cache and the other caches. mag decompresses zstd itself.</p> 116 <p>The <code>aur</code> line makes the AUR one more repo. <code>mag update</code> gets the metadata of every AUR package (15 MB), and <code>mag install</code> builds what is not in the binary repos:</p> 117 <pre>mag install spotify</pre> 118 <p>mag installs <code>base-devel</code>, <code>git</code> and what the PKGBUILD needs to build, gets the snapshot into <code>/var/cache/mag/aur/NAME</code>, and runs makepkg there as nobody; the package it makes is installed like any other. Keys the PKGBUILD lists in <code>validpgpkeys</code> are fetched from keyserver.ubuntu.com for the build. A PKGBUILD is written by whoever uploaded it and nobody else read it: look at it first (<code>/var/cache/mag/aur/NAME/PKGBUILD</code> stays after the build) if you do not trust the package.</p> 119 <hr> 120 <p><a href="handbook-installing.html">← Installing</a> | <a href="docs.html">Contents</a> | <a href="handbook-rifle.html">rifle →</a></p> 121 </main> 122 123 <hr> 124 <div id="foot"> 125 Something wrong on this page? Tell us on the <a href="board.html">board</a>.<br> 126 Chamesle installs with <code>chamesle-install</code>, or by hand from the <a href="docs.html">handbook</a>.<br> 127 <a href="https://ko-fi.com/L6N725GI1V">Ko-fi</a><br> 128 <a href="#" id="edit-link">Edit text</a><br> 129 $Date: 2026-11-23 $ 130 </div> 131 132 </div> 133 134 <script src="edit.js"></script> 135 </body> 136 </html>