docs: install, bundle and modules for the Flatpak output
The README's Flatpak section brings in `crafter-build install` and `bundle` after -r, where the sentence on what build-finish writes was, says how they make the app, crafter-build writing the build directory's metadata and the host's flatpak build-finish adding the command and the permissions to it and writing export/, and where that directory is, for trying the app on the host without installing it, says where the repo and remote live and how two installs of one app-id take turns on the remote, where `install` takes the runtime from, what to install where no installation has it and that an app with modules needs the Sdk too, how they ask the host whether it sees the project's bin/ and build/ and refuse a project it does not and who in the sandbox holds the permission they run with, and describes cfg.flatpak.runtime, cfg.flatpak.permissions, which install and bundle print and build-finish judges, and cfg.flatpak.modules; it names install and bundle among the invocations that write AGENTS.md. AGENTS.template.md names what :Flatpak holds now, and says that org.freedesktop.Flatpak is the whole sandbox's while crafter-build's own code uses it only in the host helper, why the trust model allows it, how a test reaches the host without touching the user's installation, and the trap in probing a tool with `command -v` through RunCommandWithTimeout, whose `timeout` cannot run a shell builtin, and lists the locks install keeps on the user's remotes among what goes in ~/.cache/crafter.build/, found by HOME, so that native and Flatpak crafter-builds share them.
This commit is contained in:
parent
71540b24aa
commit
52a767fadc
2 changed files with 25 additions and 7 deletions
21
README.md
21
README.md
|
|
@ -61,7 +61,16 @@ bin/myapp-<variant>/
|
|||
└── share/ the desktop entry, metainfo and icons, under the app-id
|
||||
```
|
||||
|
||||
`-r` runs `files/bin/myapp` from that directory, inside crafter-build's sandbox, against the libraries in `files/lib`, the ones the app carries. A Flatpak build directory holds two things more: `metadata`, naming the app, its runtime and its sandbox's permissions, and `export/`, what the host sees of the app, such as its desktop entry and icons. `flatpak build-finish` adds the command and the permissions to a metadata that names the app and its runtime, and writes `export/`, by flatpak's own rules.
|
||||
`-r` runs `files/bin/myapp` from that directory, inside crafter-build's sandbox, against the libraries in `files/lib`, the ones the app carries. To install the app for yourself, or to hand it to someone else:
|
||||
|
||||
```bash
|
||||
crafter-build install # build it and install it for this user: `flatpak run local.crafterbuild.myapp`
|
||||
crafter-build bundle # build it into bin/myapp-<variant>.flatpak, for `flatpak install --user <file>`
|
||||
```
|
||||
|
||||
Both make the app first. Without modules, crafter-build makes `build/flatpak-apps/<app-id>/build-dir` of `files/`, as hard links to the build's own where they can be made and copies where they cannot, and a `metadata` naming the app, its runtime and the Sdk, and the host's `flatpak build-finish` finishes it by flatpak's own rules: it adds the command and the sandbox's permissions to the metadata and writes `export/`, what the host sees of the app, such as its desktop entry and icons. With modules, flatpak-builder does all of it.
|
||||
|
||||
`install` puts the app into a repo of the project's, in `build/flatpak-apps/<app-id>/`, and installs it from a user remote named `crafter-build-<app-id>`, updating what an earlier install left; it prints how to remove both, which matters before `crafter-build clean` deletes the repo. Installs of one app-id from two checkouts take turns on that remote, by a lock in `~/.cache/crafter.build/flatpak-remotes/` that every crafter-build installing for the user takes, the Flatpak's too. `bundle` writes a single file that `flatpak install --user` installs, naming Flathub's repository in it for the runtime. `install` takes the runtime from an installation that has it, the system's or the user's, or from a remote of the user's installation; where none does, flatpak stops with `requires the runtime ... which was not found`, and `flatpak install flathub org.freedesktop.Platform//26.08`, or the Sdk for an app that runs on it, puts it in place. An app with modules needs `org.freedesktop.Sdk//26.08` whatever it runs on, since flatpak-builder makes it with that: `flatpak install flathub org.freedesktop.Sdk//26.08`. Both run the host's `flatpak`, and with modules its flatpak-builder, which crafter-build's Flatpak reaches through the Flatpak session helper (the `org.freedesktop.Flatpak` permission) and uses for nothing else. The permission belongs to the whole sandbox, so a `project.cpp`, its scripts, the builds of its dependencies and the programs `-r` and `test` start can reach the host through it too; through the sandbox's `--filesystem=host` they could already write files the host runs, such as `~/.bashrc`. The host sees the project at the path crafter-build does where the sandbox shares the host's directories, as it does the home, `/mnt`, `/opt`, `/srv` and `/run/media`, and not in the sandbox's own `/tmp`, `/var`, `/usr`, `/etc` and `/app`. Before building, `install` and `bundle` ask the host whether it sees the project's `bin/` and `build/` where crafter-build does, following their links as the host does: they start its `flatpak` in a directory made in each for the question and removed again, and refuse the project where it cannot start there. To try the app on the host without installing it, run `flatpak build --runtime --readonly build/flatpak-apps/<app-id>/build-dir myapp` there after an `install` or `bundle`: it runs on the app's runtime, with the filesystems and the environment its metadata grants.
|
||||
|
||||
Installed, the program starts in the directory it is started from, when its permissions let it see that directory, and in `$HOME` otherwise. A program that reads its own files therefore finds them next to its executable (`/proc/self/exe`) rather than in the working directory, which is only its own under `-r`.
|
||||
|
||||
|
|
@ -69,11 +78,17 @@ What the app is installed as is `cfg.flatpak`; a hello world sets none of it:
|
|||
|
||||
```cpp
|
||||
cfg.flatpak.appId = "net.example.MyGame"; // default: local.crafterbuild.<outputName>
|
||||
cfg.flatpak.runtime = FlatpakRuntime::Sdk; // default Platform; the Sdk has git, gcc and the like
|
||||
cfg.flatpak.permissions = { "--socket=pulseaudio" }; // finish-args, spelled as in a Flatpak manifest
|
||||
cfg.flatpak.desktopFile = "packaging/MyGame.desktop"; // installed as <appId>.desktop; its Icon= is the app-id
|
||||
cfg.flatpak.metainfo = "packaging/MyGame.metainfo.xml";
|
||||
cfg.flatpak.icons = { "packaging/icon.svg" }; // an .svg is scalable, a square .png goes under its size
|
||||
cfg.flatpak.modules = { "packaging/flatpak/node.yaml" }; // flatpak-builder modules for more in /app
|
||||
```
|
||||
|
||||
- **Permissions** are the sandbox's: sockets, devices, shares, filesystems, bus names, environment. A library declares what every program built on it needs in its own `cfg.flatpak.permissions`, and those reach the program before the program's own, which can take one back (`--nosocket=x11`). `install` and `bundle` print the resulting list, with where each came from, and hand it to `flatpak build-finish`, which refuses a misspelled argument, and a share, socket, device or feature flatpak does not have, naming the ones it has. The build itself does not read them, so changing one builds nothing.
|
||||
- **The runtime** is always at the branch crafter-build runs on (26.08 today), since the program links that runtime's glibc. The Platform is enough to run a program; the Sdk is for one that runs tools such as git at run time.
|
||||
- **Modules** are for what the app needs in `/app` besides the program: a runtime it starts, a tool it runs, data built from source. They are flatpak-builder module files in Flatpak's own format, which crafter-build names and never reads. With any, `install` and `bundle` have the host's flatpak-builder (or the `org.flatpak.Builder` app) make the app with `org.freedesktop.Sdk//26.08`, which the host then needs as well as the runtime, from a manifest in `build/flatpak-apps/<app-id>/` that lists them and copies the built program in last, so it is not compiled again; flatpak-builder's defaults then also strip it and split its debug info into a `.Debug` extension. Translations under `share/locale` stay in the app rather than going into a `.Locale` extension, which a bundle would leave out. `-r` runs the program without them.
|
||||
- **What cannot be a Flatpak** fails the build saying why: Windows and wasm targets, which keep their `.exe` and `.wasm`; a build against a sysroot, which links that sysroot's libraries and not the runtime's, or one for musl, a C library no runtime has; an architecture other than the runtime's; a build against `CRAFTER_BUILD_LIBCXX_DIR`, since a Flatpak carries the toolchain's own libc++, built against the runtime's glibc; and a build by a native crafter-build, whose programs link the host's glibc, unless `CRAFTER_BUILD_FLATPAK_INFO`, which the tests set, names a runtime. A dependency's executables stay as linked even when `--packaging=flatpak` reaches their project, since their consumers run them by path, and tests are never packaged. A dependency that sets `cfg.packaging` in its own `project.cpp` is packaged, and the files its `cfg.flatpak` names are found in its own directory, as its `cfg.files` are.
|
||||
- **For other machines**, build with `--march=x86-64-v3` rather than the default `native`, which can crash with SIGILL on an older CPU. Pass it on the command line or in `CRAFTER_BUILD_MARCH`: either reaches every configuration of the program that `ApplyStandardArgs` is called on, a sibling's whose `project.cpp` calls it included, while CMake externals are compiled without `-march`, and a `#pragma crafter dependency`, tooling built for `project.so` alone, with `-march=native`.
|
||||
|
||||
|
|
@ -141,7 +156,7 @@ Such a dependency is built for the host, whatever the project targets, and its `
|
|||
|
||||
An agent working on a project reads its `AGENTS.md`, which says nothing about the libraries the project builds against unless someone copied that in by hand. A library ships it instead: an `AGENTS.consumer.md` beside its `project.cpp`, written for whoever uses the library rather than whoever works on it.
|
||||
|
||||
A consumer that wants its dependencies' notes writes its own instructions in an `AGENTS.template.md` beside its `project.cpp`, and commits that instead of an `AGENTS.md`. `crafter-build` and `crafter-build test` then write `AGENTS.md` from the template with the notes added, so `AGENTS.md` is build output and stays out of version control: a dependency that changes its notes changes nothing a diff shows. A project with a committed `AGENTS.md` moves over from the directory of its `project.cpp`:
|
||||
A consumer that wants its dependencies' notes writes its own instructions in an `AGENTS.template.md` beside its `project.cpp`, and commits that instead of an `AGENTS.md`. `crafter-build`, `crafter-build test`, `crafter-build install` and `crafter-build bundle` then write `AGENTS.md` from the template with the notes added, so `AGENTS.md` is build output and stays out of version control: a dependency that changes its notes changes nothing a diff shows. A project with a committed `AGENTS.md` moves over from the directory of its `project.cpp`:
|
||||
|
||||
```bash
|
||||
git mv AGENTS.md AGENTS.template.md
|
||||
|
|
@ -171,7 +186,7 @@ What a build then writes:
|
|||
- The section goes after the template's text and a blank line. To have it elsewhere, put the begin and end marker lines in the template where it should go: whatever they enclose is replaced. A template moved over from a committed `AGENTS.md` has them where its section was, around notes that can be deleted.
|
||||
- `AGENTS.md` is written only when its text changes, in place, so a `CLAUDE.md` linked to it, its ownership and a read-only `AGENTS.md` are respected. An edit made in it is gone after the next build, and a fresh clone has none until its first build. The template is never written.
|
||||
- An `AGENTS.md` that no build wrote, such as a committed one still next to a new template, is never replaced: each build warns instead, until it is deleted. Without a template, `AGENTS.md` is never touched. One that still holds a section from crafter-build 3.0.0, which kept the notes in a committed `AGENTS.md`, gets a warning: move it over as above, or delete the section.
|
||||
- The update runs once `project.cpp` has loaded and before the project compiles, so a build that fails still has the notes. A `project.cpp` that fails to load gets no update. `test --list`, `lint`, `format`, `run` and `clean` leave the file alone.
|
||||
- The update runs once `project.cpp` has loaded and before the project compiles, so a build that fails still has the notes. A `project.cpp` that fails to load gets no update. `test --list`, `lint`, `format`, `run` and `clean` leave the file alone, and so does an `install` or `bundle` refused before building.
|
||||
- The section follows what the build loaded: a dependency that only some flags pull in (a `--target=`, a flag of the project's own) comes and goes with them. An unpinned dependency's notes follow its default branch, as its code does, so the section can change on any build. Pin a `commit` to decide when.
|
||||
- A library reached through two specs, pinned at one revision here and another further down, is described once, as the nearer one has it.
|
||||
- When there are notes to write, unbalanced markers in the template leave `AGENTS.md` as it is, with a warning. A notes file that would break the section (a code block it never closes, a marker line of its own) is left out, also with a warning. Markers quoted inside a fenced code block don't count.
|
||||
|
|
|
|||
Loading…
Reference in a new issue