# Packaging and Releasing

---

# Packaging

_Pekit / Packaging and Releasing_

> Describe packages with the package definition type, pack them with the workspace's packagers such as ppk, and publish them into a package store with pekit publish.

A package says what it contains, not how a format stores it. You write
packages with the `package` definition type, beside the builds they ship.
The workspace's packagers turn each into a file of their format, such as a
Peios package, and publish it into a store.

## Before you start

- The ppk library, and a `ppk` program to register as its tool. See
  [Libraries](/pekit/libraries/libraries.md).
- A target that builds what you want to ship.

## Describe a package

In a build file beside the build it ships, such as `package.gcsl` next to
`build.gcsl`, declare the package:

```gcsl
let version = "1.0-1"

def package dev.example.greet() {
    version = version
    files = {"bin/greet" = build app()}
}

def package dev.example.greet-dev() {
    let g = build greet()
    version = version
    files = {"include" = g.headers; "lib/libgreet.a" = g.archive}
}
```

The definition's path is the package's name. Each of its `files` is placed
at its path under `/usr`: a file at its path, a list of files under it by
their names, and a directory's tree under it. Files in one directory see
each other's declarations, so `build app()` needs no import.

## Give a package its metadata

A package can carry more than its files. pekit keeps any other field of a
package's body and never reads it, so each packager defines the fields it
takes. The ppk packager reads a field named `ppk`, and records what it holds
in the package's manifest:

```gcsl
def package dev.example.greet-dev() {
    let g = build greet()
    version = version
    files = {"include" = g.headers; "lib/libgreet.a" = g.archive}
    ppk = {
        description = "The greet library, for developers"
        license = "MIT"
        license_class = "free"
        homepage = "https://example.com/greet"
        dependencies = {"dev.example.greet" = "= {version}"}
    }
}
```

`ppk` has two kinds of field:

- **Single values,** each a string: `description`, `homepage`, `license`,
  `license_class`, and `source_license`.
- **Tables,** each a record of strings:
  - `dependencies`: the packages this one needs, each with a version
    constraint.
  - `requires`: the capabilities it needs, such as `sh`, each with a
    constraint.
  - `provides`: the capabilities it offers, each with a version.
  - `claims`: links it owns outside its files, each an absolute path and
    the link's target, such as `"/usr/bin/sh" = "dash"`.
  - `descriptors`: files and directories of the package that get a
    security descriptor of their own, each a path as `files` gives it and
    the descriptor in hexadecimal.

An empty string means any version, or no version. ppk checks every value as
`ppk pack` does, and finds an ELF program's libraries and their floors
itself, so don't write those. A field ppk has no form for is an error
naming it, so a misspelt field never goes missing quietly. A package
without `ppk` is packed with no metadata, as before.

A signed file, such as firmware, takes its signature from a file beside it
named with `.peios.sig` added. Place the signature in `files` like any other
file, or in the directory you place. `ppk pack` records it in the signed
file's entry and doesn't pack it as a file:

```gcsl
def package dev.example.firmware() {
    version = "1.0-1"
    files = {
        "lib/firmware/acme/fw.bin" = file("fw.bin")
        "lib/firmware/acme/fw.bin.peios.sig" = file("fw.bin.peios.sig")
    }
    ppk = {descriptors = {"lib/firmware/acme" = "0100048014000000..."}}
}
```

The descriptor is shortened here. What ppk requires of a descriptor or a
signature is under SECURITY METADATA in `ppk(1)`.

## Register the packager

1. In `workspace.gcsl`, register the `ppk` tool as a toolchain, and the ppk
   packager in `pekitconf.packagers`:

   ```gcsl
   import * from "github.com/gcslib/ppk"
   import * from toolchain

   def Toolchain::Ppk workspace_ppk() {
       let tools = dir("tools")
       host_platform = ^host_platform
       platform = {}
       provides = {root = tools; runtime = dir("/"); ppk = tools.file("ppk")}
   }

   pekitconf = {
       toolchains = [Toolchain::C system_c, Toolchain::Ppk workspace_ppk]
       packagers = [packager()]
   }
   ```

   This keeps the `ppk` program at `tools/ppk` in the workspace. A relative
   path is relative to the file it's written in, so `dir("tools")` in
   `workspace.gcsl` is `tools` at the workspace's root.

2. Pack every package below the current directory:

   ```sh
   pekit package
   ```

## Check the result

pekit packs each package with each packager, and prints where each went:

```text
packed example/dev.example.greet with ppk
  pekit-out/example/dev.example.greet/pack/artifacts
packed example/dev.example.greet-dev with ppk
  pekit-out/example/dev.example.greet-dev/pack/artifacts
6 steps run, 0 found in the store
```

Name packages to pack only those, as `pekit build` names targets:
`pekit package dev.example.greet`, or `pekit package 'pkgs/**'`.

## What reruns

Each packing is a step of its own, so a package whose files didn't change
isn't packed again. Changing `main.c` repacks `dev.example.greet` and
leaves `dev.example.greet-dev` alone. Changing the version alone repacks
both and compiles nothing.

The ppk packager packs a package as `ppk pack` does, for the architecture
of `^platform`, into a new directory, so the same files and version always
give the same package.

## Pack in a build

A build can pack packages itself, with the ppk library's `pack`:

```gcsl
import "github.com/gcslib/ppk"

def build packages() {
    greet = ppk.pack(package dev.example.greet())
    greet_dev = ppk.pack(package dev.example.greet-dev())
}
```

`ppk.pack` gives the artifact directory of one package.

## Publish packages

Copying a package into a store is publishing. It changes things outside the
build, so it's never a step: it happens on each run, in order, after the
packing it needs. `pekit publish` packs each package it's given, as `pekit
package` does, then publishes it with each packager into the store `--to`
names:

```sh
pekit publish dev.example.greet --to /srv/artifacts
```

```text
published example/dev.example.greet with ppk
  pekit-out/example/dev.example.greet/pack/artifacts
0 steps run, 5 found in the store
```

Packing doesn't depend on the store, so publishing what you've packed, or
the same package into a second store, packs nothing again. ppk publishes
into an artifact directory with `ppk fetch --no-deps`, which copies only the
named package and refuses a version whose contents changed: publish a new
version instead. If one package fails to publish, the packages published
before it stay published.

## Publish strictly

A strict build refuses a target's own effects, and publishing is one. To
publish what a strict build packs, pass `--strict` to `pekit publish`:

```sh
pekit publish 'pkgs/**' --to /srv/artifacts --strict
```

pekit packs every package strictly, then publishes them, taking every pack
from the store. If a package fails to pack strictly, pekit publishes none of
its recipe's packages, so that a recipe is published whole or not at all. It
publishes the other recipes, says which it held back, and fails:

```text
error: a recipe is not published, since a package of it did not pack strictly: org.gnu.bash
```

## Replace a published version

ppk refuses to publish a version whose contents changed, because something
might already have fetched the old contents. A repository that nothing has
fetched from yet, such as one being bootstrapped, can need a version
rebuilt and published again. For that, give the ppk packager
`replace = true` in `workspace.gcsl`:

```gcsl
pekitconf = {
    packagers = [packager(replace = true)]
}
```

The packager then publishes with `ppk fetch --no-deps --replace`, and each
line pekit prints names it:

```text
published example/dev.example.greet with ppk --replace
```

> [!CAUTION]
> A replaced version breaks anything that fetched the old one. Use
> `replace = true` only on a repository nothing has fetched from, and don't
> commit it.

## Write a packager

Each packager is a `packaging.Packager`, from GCSL's standard `packaging`
module. It has a `name`, a `pack` function of a package to the directory it
packed it into, and a `publish` function of a package, that directory, and a
store. A library for another format gives a packager of its own, and a
workspace lists it in `pekitconf.packagers` beside ppk's.

---

# Signing Kernel Modules

_Pekit / Packaging and Releasing_

> Sign a package's Linux kernel modules with the modsig library, using a key from the keychain, so that a kernel enforcing module signatures loads them and the package stays reproducible.

A kernel that enforces module signatures loads a module only if it carries
a signature by a key the kernel trusts. The modsig library signs a tree of
modules after they are built, in a step of its own. It's the only step
given the key, so no build command sees it. Signing the same modules with
the same key always gives the same bytes, so a package of signed modules
stays reproducible.

## Before you start

- The modsig library, which builds its signing program with the rust
  library. See [Libraries](/pekit/libraries/libraries.md).
- The Rust and C toolchains registered in `workspace.gcsl`. See [Building
  Rust](/pekit/languages/building-rust.md).
- A target that builds a directory of modules, each compressed with zstd
  and named `.ko.zst`.
- A PEM file holding an ML-DSA-65 private key, with its seed, followed by
  its certificate, which the kernel trusts. Keep it outside the workspace,
  and out of version control.

## Sign the modules

1. Tell pekit where the key is. Name a file in the environment, which keeps
   the path out of your workspace:

   ```sh
   export GCSL_SECRET_FILE_MODULE_SIGNING=~/.config/peios/keys/modsig.pem
   ```

   Or give it a keychain entry named `module-signing`. See [Using
   Secrets](/pekit/building/using-secrets.md).

2. In the package, give `modsig.sign` the directory of modules:

   ```gcsl
   import "github.com/gcslib/modsig"

   def package dev.example.modules() {
       version = "1.0-1"
       files = {"lib/modules" = modsig.sign(build modules())}
   }
   ```

3. Pack it:

   ```sh
   pekit package dev.example.modules
   ```

## Check the result

Decompress a module from the package, and `modinfo` shows who signed it:

```sh
zstd -d example.ko.zst
modinfo example.ko | grep -E '^(sig_id|signer)'
```

```text
sig_id:         PKCS#7
signer:         example module signing key
```

## What it changes

`modsig.sign` gives a copy of the directory. In that copy, each `.ko.zst` is
decompressed, signed, and compressed again at zstd's level 19. Everything
else is copied unchanged, so run `depmod` before or after signing, as you
prefer.

The step fails, and says why, if:

- a module is a `.ko`, `.ko.gz`, or `.ko.xz`. The signature has to be inside
  the compression, and only zstd's is supported.
- a module is signed already.
- the directory holds no module.
- the key file holds no seed, or the certificate isn't the private key's.

## How a signature is made

Each signature is deterministic pure ML-DSA-65 over the whole module, with
an empty context string and no signed attributes, in a PKCS#7 message
appended to the module. The kernel's `sign-file` can't produce this with
OpenSSL 3, which adds a signing time and randomises each signature.

A signed module's bytes also depend on zstd. The library's `Cargo.lock` pins
the version, so updating it changes every package that holds signed modules.

## How the key and the store work together

The signing step is an ordinary step given a secret, so [Using
Secrets](/pekit/building/using-secrets.md) describes how pekit protects the key. For
signing, that means:

- The directory you give `modsig.sign`, and every step that made it, stays
  unsigned in the store. Changing the key signs again without rebuilding
  them.
- The signed copy is kept in the store, under the key's identity. It holds
  no secret.
- Another machine signs for itself, because a secret's identity differs
  between machines. It packs for itself too, and gets the same package.
- `pekit release` uses the `release` profile's key. Signing twice gives the
  same bytes, so the release's reproducibility check passes.

---

# Signing Firmware

_Pekit / Packaging and Releasing_

> Sign a package's device firmware, or any file that isn't ELF, with the pipsig library and a key from the keychain, so that the Peios kernel trusts it and the package stays reproducible.

The Peios kernel loads device firmware only if the file carries a signature
by a key in the kernel's trusted computing base. A file that isn't ELF
carries its signature in its `security.peios.sig` attribute, which a package
can't hold. So the package carries the signature as a file beside the one it
signs, `<file>.peios.sig`, and the package's consumer sets the attribute from
it. The pipsig library makes those files after the build, in a step of its
own. It's the only step given the key, so no build command sees it. Signing
the same files with the same key always gives the same bytes, so the package
stays reproducible.

For the format of the signature and what the kernel checks, see [Signature
Format](/specifications/pspk/binary-signing-and-pip/signature-format.md) and
[Files the Kernel
Loads](/specifications/pspk/binary-signing-and-pip/kernel-loaded-files.md). For
how a package carries one, see [Payload
Entries](/specifications/pspu/package-format-and-repository-protocol/payload-entries.md#detached-signatures).

## Before you start

- The pipsig library, which builds its signing program with the rust
  library. See [Libraries](/pekit/libraries/libraries.md).
- The Rust and C toolchains registered in `workspace.gcsl`. See [Building
  Rust](/pekit/languages/building-rust.md).
- A target that builds a directory holding the files to sign.
- A PEM file holding an ML-DSA-65 private key with its seed, such as
  `openssl genpkey -algorithm ML-DSA-65` writes, whose public key the kernel
  trusts. Keep it outside the workspace, and out of version control.

## Sign the files

1. Tell pekit where the key is. Name a file in the environment, which keeps
   the path out of your workspace:

   ```sh
   export GCSL_SECRET_FILE_TCB_SIGNING=~/.config/peios/keys/tcb.pem
   ```

   Or give it a keychain entry named `tcb-signing`. See [Using
   Secrets](/pekit/building/using-secrets.md).

2. In the package, give `pipsig.sign` the directory and the patterns of the
   files to sign:

   ```gcsl
   import "github.com/gcslib/pipsig"

   def package dev.example.firmware() {
       version = "1.0-1"
       files = {"." = pipsig.sign(build firmware(), take = ["usr/lib/firmware/**"])}
   }
   ```

3. Pack it:

   ```sh
   pekit package dev.example.firmware
   ```

## Check the result

Each file the patterns take has its signature beside it, of 3310 bytes:

```sh
wc -c usr/lib/firmware/example.bin.zst.peios.sig
```

```text
3310 usr/lib/firmware/example.bin.zst.peios.sig
```

## What it changes

`pipsig.sign` gives a copy of the directory. In that copy, each regular file
the patterns take has a signature beside it, with mode `0644`. Everything
else, the files themselves included, is copied unchanged.

A pattern is matched against the whole of a path in the directory. `**`
matches any characters, `*` matches any characters but `/`, and every other
character matches itself. So `usr/lib/firmware/**` takes every file under
`usr/lib/firmware`, and `*/usr/lib/firmware/**` takes those of each directory
the tree holds.

A link that a pattern takes isn't signed. The kernel checks the file a link
names, so that file's signature serves the link.

The step fails, and says why, if:

- a file it takes is ELF. An ELF file carries its signature in a section
  instead.
- a file it takes is a signature, or already has one beside it.
- a pattern takes no file, or `take` is empty.
- the tree holds something that is neither a file, a directory nor a link.
- the key file holds no seed, or its expanded key isn't its seed's.

## How a signature is made

Each signature is a version byte, `1`, followed by a deterministic pure
ML-DSA-65 signature, with an empty context string, of the SHA-256 of the
whole file as it is on disk. A compressed file is signed as it is
compressed, since the kernel checks the file before it decompresses it.

## How the key and the store work together

The signing step is an ordinary step given a secret, so [Using
Secrets](/pekit/building/using-secrets.md) describes how pekit protects the key. For
signing, that means:

- The directory you give `pipsig.sign`, and every step that made it, stays
  unsigned in the store. Changing the key signs again without rebuilding
  them.
- The signed copy is kept in the store, under the key's identity. It holds
  no secret.
- Another machine signs for itself, because a secret's identity differs
  between machines. It packs for itself too, and gets the same package.
- `pekit release` uses the `release` profile's key. Signing twice gives the
  same bytes, so the release's reproducibility check passes.

---

# Recording Corresponding Source

_Pekit / Packaging and Releasing_

> Record what each recipe's packages are built from in pekit.sources with pekit sources, so that a package of the source can be built from it, and keep it current, which a strict publish checks.

A package that ships a binary often has to come with its corresponding
source: everything the binary was built from, as the GPL asks of anyone
who distributes a GPL program, say. pekit works that out for you. It
records what each recipe's packages are built from in `pekit.sources`, a
file at the workspace's root, beside `pekit.lock`. A package of a recipe's
source is then built from that record alone, so it's the same wherever
it's built, and a change to a recipe's source shows in review.

## What a recipe's source is

A recipe is a directory of package definitions, such as `org.gnu.bash`.
Its source is everything a build of all its packages used, except tools:

- each file its build fetched, by URL and SHA-256;
- each git commit its build fetched, by repository and commit;
- each file and directory of the workspace that its code read, that its
  steps were given, or that its packages hold, by its path in the
  workspace. The GCSL code itself is among them, with `workspace.gcsl`
  and `pekit.lock`, which loading the workspace takes;
- each library whose code it ran. A library that `pekit.lock` pins is
  recorded whole, by its import path and its directory, since a build
  restores a pinned library whole. One the lock doesn't pin is recorded
  by the files of its code alone.

A tool isn't source:

- What a registered toolchain is made from: its definition's fetches, and
  everything fetched to make it, such as the source of a tool it compiles.
- A fetch or a `fetch_git` marked `tool = true` (see [Fetching
  Files](/pekit/building/fetching-files.md#mark-a-tool)).
- A path that leads out of the workspace, such as a link to a repository
  of packages that build roots are taken from.

Packing isn't part of a recipe's source either: pekit builds a recipe's
packages without packing them to record it, so a packager's own program
isn't counted.

Nor is what the package of the source holds. A package whose own code reads
`pekit.sources` is built from the record, so pekit counts its code but not
what it reads, fetches or holds. Otherwise a file the record once named
would stay recorded after the recipe stopped using it, or even after it was
deleted, since the package of the source holds it.

## Before you start

- A workspace whose packages build strictly, if the workspace requires
  `--strict`. See [Hermetic and Strict
  Builds](/pekit/concepts/hermetic-and-strict-builds.md).
- Every tool your builds fetch outside a toolchain marked `tool = true`.

## Record the sources

1. Run `pekit sources` with the packages whose recipes to record, or none
   to record every recipe below this directory:

   ```sh
   pekit sources --strict 'org.gnu.bash/**'
   ```

   pekit builds each recipe's packages on their own, every package of the
   recipe whichever you named, and records what each build used, with the
   names of the recipe's packages:

   ```text
   recorded org.gnu.bash: 21 fetched, 0 git, 15 files, 9 directories
   ```

2. Review `pekit.sources`, and commit it with the change that made it.

A recipe's record replaces what was recorded of it. Recipes you didn't name
keep theirs.

## Keep it current

Run `pekit sources` again whenever a recipe's source changes: a new
version, a new patch, a build that reads another file, or a new package. A
strict publish or a release checks the record of each recipe it
publishes, and publishes nothing if one isn't what the recipe's build uses
and the packages it has:

```text
error: nothing is published, since `pekit.sources` does not record what org.gnu.bash is built from: run `pekit sources --strict` for it, and review the change
```

A workspace with no `pekit.sources` publishes without the check.

## Check the result

Each recipe in `pekit.sources` lists its `packages`, its `fetched` files,
its `git` commits, the `libraries` whose code it ran, and the workspace's
`files` and `dirs` it read, each sorted:

```json
{
  "recipe": "org.gnu.bash",
  "packages": ["org.gnu.bash", "org.gnu.bash-doc"],
  "fetched": [
    {
      "url": "https://ftpmirror.gnu.org/bash/bash-5.3.tar.gz",
      "sha256": "0d5cd86965f869a26cf64f4b71be7b96f90a3ba8b3d74e27e8e9d9d5550f31ba"
    }
  ],
  "git": [],
  "libraries": ["github.com/gcslib/ppk"],
  "files": [
    "org.gnu.bash/build.gcsl",
    "pekit.lock",
    "recipe.gcsl",
    "workspace.gcsl"
  ],
  "dirs": [".gcsl/libraries/github.com/gcslib/ppk", "org.gnu.bash/patches"]
}
```

A directory stands for everything in it. A package of the
source fetches each file again by its digest, which the store answers, and
takes the commits and the workspace's files as they are.

A build from a package of the source restores every library that its
`pekit.lock` pins, and fetches any that it lacks. So give the package a
lock that pins only the recipe's `libraries`, beside their directories.
It then builds with no network, from the store's tools and what the
package holds.

---

# Releasing

_Pekit / Packaging and Releasing_

> Release a package with pekit release, which builds it from a committed tree strictly and reproducibly with release secrets, publishes it, and tags the commit it was built from.

`pekit release` makes a release of one package. It builds the package as a
release should be built, publishes it, and tags the commit it was built
from. Everything a release depends on is pinned, so anyone with the commit
can build the same bytes.

## Before you start

- A workspace in a git repository, with every change committed.
- Every library pinned in `pekit.lock`. See [Pinning
  Libraries](/pekit/libraries/pinning-libraries.md).
- Steps that use only pinned toolchains, since a release is a strict
  build.
- The release profile's secrets in the keychain, if the package needs any.
  See [Using Secrets](/pekit/building/using-secrets.md).
- A packager registered in `pekitconf.packagers`. See
  [Packaging](/pekit/shipping/packaging.md).

## Release a package

1. Commit everything, and check that `git status` is clean.

2. Release the package into its store:

   ```sh
   pekit release dev.example.greet --to /srv/artifacts
   ```

## Check the result

pekit reports what it published and the tag it added:

```text
published dev.example.greet@1.0-1 with ppk into /srv/artifacts
tagged dev.example.greet@1.0-1 at 4834d15186dbf67463ca1410d67bc578faca1f4e
```

`git tag` lists the new tag. Push it to share the release.

## What a release is built from

A release is built from a commit, never from your working tree. The
workspace must match the repository's `HEAD`: every file committed, and
nothing changed or added, except the build's own `pekit-out/` and `.gcsl/`.
If any file differs, pekit names it and stops.

pekit then exports the workspace's tree at `HEAD` into a directory of its
own, and builds there. So a file that git ignores never reaches a release.

## How a release is built

A release builds as `pekit build --strict --check-reproducible` would, with
the keychain's `release` profile:

- **No host tools.** Its steps run their programs from pinned toolchains,
  and a target's own code only fetches, unpacks, asks the keychain, and
  reads the workspace and the build's outputs. See [Hermetic and Strict
  Builds](/pekit/concepts/hermetic-and-strict-builds.md).
- **Pinned libraries.** Its libraries are exactly those `pekit.lock` pins.
- **Reproducible steps.** Every step runs a second time, and a step that
  gives other outputs from the same inputs fails the release.
- **Release secrets.** Secrets come from the `release` profile, so a release
  signs with its own keys.

## Publishing and tagging

Once the package is built and checked, pekit publishes it with each of the
workspace's packagers into the store `--to` names. Then it tags `HEAD` as
`NAME@VERSION`, the package's name and version: `dev.example.greet@1.0-1`.
The tag is a lightweight tag, so it needs no git identity.

A version is released from one commit. If its tag is on another commit,
pekit refuses before publishing anything: give the new release a version of
its own. Releasing again from the commit that has the tag publishes the
same package again, and adds no tag. pekit only ever adds tags. It never
moves or deletes one.

---

# Building and Booting an Image

_Pekit / Packaging and Releasing_

> Build a bootable Peios ISO from packages with the peiso library, boot it in a test with the qemu library, and boot it yourself with pekit run.

A bootable ISO is an ordinary build. The peiso library makes one from
packages with the `peiso` tool, and the qemu library boots one in QEMU, in
a test or for you to use.

## Before you start

- The peiso, ppk, and qemu libraries. See [Libraries](/pekit/libraries/libraries.md).
- The `peiso`, `mkirf`, and `mkuki` programs, and `ppk`, to register as
  toolchains.
- On the host: `mkfs.vfat`, mtools, and `xorriso`, which peiso runs, and
  QEMU with OVMF's firmware for booting.

## Register the tools

The libraries ask the `toolchain` module for their tools. The qemu
library's `system_qemu` is the host's `qemu-system-x86_64` and OVMF's
firmware. peiso, `mkirf`, and `mkuki` aren't published, so register the
ones you have, as ppk is registered in [Packaging](/pekit/shipping/packaging.md):

```gcsl
def Toolchain::Peiso workspace_peiso() {
    let tools = dir("tools")
    host_platform = ^host_platform
    platform = {}
    provides = {
        root = tools
        runtime = dir("/")
        peiso = tools.file("peiso")
        mkirf = tools.file("mkirf")
        mkuki = tools.file("mkuki")
    }
}
```

## Build the image

1. In a build file, call `peiso.iso` with the kernel the ISO boots and the
   packages it carries:

   ```gcsl
   import "github.com/gcslib/peiso"
   import "github.com/gcslib/ppk"

   def build iso() {
       = peiso.iso(
           kernel = {
               package = ppk.from_repository(dir("repository"), "dev.peios.kernel", "0.25.0-indev-1")
               cmdline = "console=ttyS0"
           },
           packages = [
               {package = ppk.from_repository(dir("repository"), "net.busybox.busybox", "1.37.0-1"); initramfs = true},
               {package = package dev.example.motd()},
           ],
       )
   }
   ```

   Each package is a package definition, which the library packs with ppk,
   or a package ppk has packed already, such as one from a repository.

2. Build it:

   ```sh
   pekit build iso
   ```

## Check the result

pekit prints the ISO's path. The ISO is one step, given its packages, so
changing the kernel's command line rebuilds the ISO and no package.
Changing one package rebuilds that package and the ISO.

## Choose where each package goes

Each package says whether the live system holds it, `liveboot`, which it does
unless you say otherwise, and whether the initramfs does, `initramfs`. The
`initramfs` and `liveboot` arguments of `peiso.iso` replace what each holds
outside `/usr`, as peiso's own specification does. Each holds symbolic links,
each `{at; to}`, with a target starting `:` in `usr`, and empty directories.

## Take packages from a repository

`ppk.from_repository(repo, name, version)` takes a package that isn't built
here from an artifact directory in the workspace, by its name and version,
for the platform being built for. It's a step keyed by the repository's
contents, so what it gives is exactly what the repository holds. The
repository has to be a directory of the workspace; the ppk library doesn't
fetch one over the network. It uses `ppk fetch --no-deps` to take only the
named package. Callers that need its dependencies resolve the closure
themselves.

## Boot the image in a test

`qemu.boot(iso, until)` boots an ISO under UEFI, with no network and its
console on its first serial port, until a line holding `until` appears. It
gives what the machine printed, with status `0` if the line appeared. In a
test, ask for KVM so that the machine runs at speed:

```gcsl
import "github.com/gcslib/qemu"

#[device("kvm")]
#[timeout(5m)]
def test boots(iso: File = build iso()) {
    let run = qemu.boot(iso, until = "Please press Enter to activate this console.")
    assert run.status == 0, run.stdout
}
```

The test is a step given the ISO, so it boots again only when the ISO
changes. Without KVM, QEMU emulates the machine, slowly but the same.

## Boot the image yourself

`qemu.launcher(iso)` builds a program that boots the ISO with your
terminal, so that `pekit run` can run it:

```gcsl
def build boot() { = qemu.launcher(build iso()) }
```

```sh
pekit run boot
```
