Files
keru/recipe-authoring.html
Astral 4a32fab414
Deploy website to GitHub Pages / deploy (push) Failing after 3s
migrate website from KeruOS web to its own repo
2026-09-01 12:06:36 +02:00

97 lines
4.5 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Recipe authoring — Keru OS</title>
<meta name="description" content="A practical HOWTO for writing kama package recipes: easy tier, real examples, common patterns, and how to get it merged into kama-packages.">
<link rel="stylesheet" href="assets/css/style.css">
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>ける</text></svg>">
</head>
<body>
<nav class="top" data-nav></nav>
<header class="pagehead">
<p class="crumbs"><a href="index.html">home</a> / <a href="docs.html">docs</a> / recipe authoring</p>
<h1>Recipe authoring</h1>
<p>Writing a kama recipe, top to bottom.</p>
</header>
<section>
<div class="wrap">
<div class="prose">
<p>Every package in a Keru system is described by a recipe: a plain POSIX shell script in <code>kama-packages</code>. Writing one is closer to filling a form than engineering a build.</p>
<h3>The template</h3>
<p><code>kama-packages/TEMPLATE.sh</code> is the canonical starting point. Copy it, fill the easy tier:</p>
<div class="code-block">name=hello # required
version=2.12.1 # required for fetch
url=https://ftp.gnu.org/gnu/hello/hello-2.12.1.tar.gz
deps=() # build-time deps, compiled then purged
build() {
./configure --prefix=/usr
make -j"$JOBS"
}
install() {
make install DESTDIR="$pkgdir" # stage, never $ROOT
}</div>
<h3>A real, complete recipe</h3>
<p>This is the entire busybox recipe currently in the repo:</p>
<div class="code-block">name=busybox
version=1.36.1
url=https://busybox.net/downloads/busybox-1.36.1.tar.bz2
deps=()
build() {
make defconfig
make -j"$JOBS"
}
install() {
make install CONFIG_PREFIX="$pkgdir"
}</div>
<p>That's it. Kama downloads, extracts, strips the top dir, builds, stages, and installs.</p>
<h3>Stepping up</h3>
<table>
<tr><th>Need</th><th>Field / function</th></tr>
<tr><td>Colliding with another package</td><td><code>provides=(...) conflicts=(...)</code></td></tr>
<tr><td>Build deps that must stay</td><td><code>runtime_deps=(...)</code></td></tr>
<tr><td>Arch-restricted</td><td><code>arch=(x86_64)</code></td></tr>
<tr><td>Repo or vcs sources</td><td><code>noextract=("$url")</code> + own <code>build()</code></td></tr>
<tr><td>Custom fetch (patch first)</td><td><code>pkg_fetch() { default_fetch; patch ...; }</code></td></tr>
<tr><td>Post-install work</td><td><code>pkg_post()</code> · <code>pkg_split()</code> for subpackages</td></tr>
</table>
<h3>Rules of the road</h3>
<ul class="features">
<li><strong>Stage, don't touch.</strong> <code>install()</code> installs into <code>$pkgdir</code>. Kama commits the staging dir to <code>$ROOT</code> only after a successful build.</li>
<li><strong>Add pure build deps to <code>deps</code>.</strong> They're purged automatically after the build (AUR-style). Keeps the door clean.</li>
<li><strong>Declare the license.</strong> <code>license=(SPDX)</code> — supply chain cleanliness starts here.</li>
<li><strong>Pin exactly.</strong> A fixed <code>url</code> + <code>version</code>, never a moving "latest".</li>
</ul>
<h3>Checking your work</h3>
<div class="code-block">sh -n recipe.sh # syntax check
kama info &lt;pkgname&gt; # metadata parses (name from the recipe)
make recipe-check # lint the whole kama-packages repo
kama make &lt;pkgname&gt; # build it for real</div>
<div class="callout">The behavioral spec lives at <a href="recipe-format.html">recipe format</a>. For hands-on, mirror the <a href="kama-recipes.html">recipe concept</a> page and start with <code>busybox.sh</code>, the smallest real recipe.</div>
<p><a href="recipe-format.html">← Recipe format</a> · <a href="kama-repos.html">The repos</a></p>
</div>
</div>
</section>
<footer data-footer></footer>
<noscript><div style="text-align:center;padding:16px">See the <a href="sitemap.html">sitemap</a> for all pages.</div></noscript>
<script src="assets/js/include.js" data-base="."></script>
</body>
</html>