refactor: rename to agentos, hand-picked /etc, user presets at first boot
os / os (push) Waiting to run
os / os (push) Waiting to run
- Rename the image from agent to agentos (ImageId, hostname, CI, docs). - mkosi.finalize only copies /etc to /usr/share/factory/etc. The hand-written tmpfiles.d/factory-etc.conf links the 24 entries the image needs. - /etc/systemd is writable: PID 1 applies the system presets at first boot and preset-global.service the user presets, as in ParticleOS. - claude-remote runs in the user manager of agent, enabled by a user preset. - Root has no /var subvolume, and the verity partitions shrink to 16M. - Style pass over comments, CLAUDE.md and AGENTS.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
25 files changed
+253
-249
No files matched your search
@@ -6,13 +6,12 @@ every change.
|
||||
## Style
|
||||
|
||||
- Keep it simple. Prefer fewer files and fewer lines. Delete what isn't
|
||||
needed.
|
||||
needed. Write plain English in short sentences.
|
||||
- Follow the defaults and conventions of each tool and language. Only set an
|
||||
option when the default doesn't work, and say why.
|
||||
option when the default doesn't work.
|
||||
- Each fact lives in one place. Elsewhere, refer to it instead of repeating it.
|
||||
- Divide code and config into parts (files, directories, sections) that each
|
||||
stand on their own: reading one part alone tells you what it does and why.
|
||||
- Each fact lives in one place. Elsewhere, refer to it instead of repeating it.
|
||||
- Write plain English in short sentences.
|
||||
- Name each part for what it does. A part without a good name holds things
|
||||
that don't belong together.
|
||||
- A little copying beats a little dependency. Repeat a small piece rather than
|
||||
@@ -22,7 +21,7 @@ every change.
|
||||
|
||||
A file starts with a header, after the shebang if there is one. Leave it out
|
||||
when the name already says it all, as with `.gitignore`. A part made of
|
||||
many files, like a package, needs it in only one of them. For example:
|
||||
many files, like a package, needs it in only one file. For example:
|
||||
|
||||
```sh
|
||||
#!/bin/bash
|
||||
@@ -43,48 +42,56 @@ the file that uses them.
|
||||
### Comments
|
||||
|
||||
- Explain why, not what. Leave out comments that only repeat the code. Try to
|
||||
write clean code instead of many comments.
|
||||
- Put a comment right above the line or block it is about. A short note on
|
||||
one line may go at the end of that line, as a full sentence too.
|
||||
write clean code instead of comments.
|
||||
- Write full sentences that start with the name of what they describe:
|
||||
`# ManifestFormat lists the packages and versions in the image.` or
|
||||
`# link prints the tmpfiles line for /etc/$1.`
|
||||
- Put a comment right above the line or block it is about. A short note on
|
||||
one line may go at the end of that line, as a full sentence too.
|
||||
- Separate paragraphs and lists with a line holding only the comment
|
||||
character.
|
||||
- Wrap comments at 80 columns.
|
||||
|
||||
## Testing
|
||||
|
||||
`mkosi vm` boots the image in qemu and needs systemd on the host. Without it,
|
||||
run mkosi in a privileged podman container that boots systemd:
|
||||
`mkosi vm` boots the image in qemu. It needs systemd on the host, so run mkosi
|
||||
in a privileged podman container that boots systemd:
|
||||
|
||||
```sh
|
||||
podman build -t mkosi-vm - <<'END'
|
||||
FROM registry.fedoraproject.org/fedora:latest
|
||||
RUN dnf install -y mkosi git-core
|
||||
FROM registry.fedoraproject.org/fedora:45
|
||||
RUN dnf install -y mkosi git-core qemu-system-x86-core edk2-ovmf swtpm-tools \
|
||||
virtiofsd openssh-clients socat
|
||||
CMD ["/sbin/init"]
|
||||
END
|
||||
podman run -d --name mkosi --privileged --systemd=always -v <repo>:/repo \
|
||||
-v mkosi-cache:/root/.cache/mkosi -v mkosi-work:/var/tmp -w /repo mkosi-vm
|
||||
podman exec mkosi mkosi genkey # Run this once, if there is no mkosi.key.
|
||||
podman exec -d -t mkosi sh -c 'mkosi -f vm > mkosi.output/vm.log 2>&1'
|
||||
podman exec mkosi mkdir -p mkosi.cache
|
||||
podman exec -d -t mkosi sh -c 'mkosi -i -f \
|
||||
--kernel-command-line-extra=console=ttyS0 vm -- -serial chardev:console \
|
||||
> mkosi.output/vm.log 2>&1'
|
||||
podman exec mkosi mkosi ssh -- systemctl --failed
|
||||
```
|
||||
|
||||
podman resolves paths on the host, so `<repo>` is the repository's path there.
|
||||
The volume `mkosi-cache` keeps mkosi's package cache when the container is
|
||||
made again, so builds don't download every package anew.
|
||||
The volume `mkosi-work` keeps mkosi's workspace in /var/tmp off the
|
||||
container's overlayfs. mkosi copies a tree with SELinux labels (as files from
|
||||
the host have) to overlayfs without any xattrs. That drops the file
|
||||
capabilities of newuidmap and newgidmap, and rootless podman fails in the VM.
|
||||
`mkosi vm` needs a terminal, hence `-d -t`; its console goes to the log.
|
||||
`mkosi ssh` runs a command as root, once the VM has booted. For the user
|
||||
`agent`, run `su - agent -c '<command>'`.
|
||||
- `mkosi -i` keeps the image with its packages installed in `mkosi.cache/`.
|
||||
Rebuilds start from it and skip installing packages.
|
||||
- The volume `mkosi-work` keeps mkosi's workspace in /var/tmp off overlayfs.
|
||||
When mkosi copies files with SELinux labels to overlayfs, it drops all
|
||||
xattrs. That removes the file capabilities of newuidmap and newgidmap, and
|
||||
rootless podman fails in the VM.
|
||||
- `mkosi vm` needs a terminal, hence `-d -t`. Its console goes to the log.
|
||||
- The console of `mkosi vm` is hvc0, which the kernel can only use once the
|
||||
initrd loads its driver. `console=ttyS0` also sends the kernel log to the
|
||||
serial port, and `-serial chardev:console` sends that port to the same log.
|
||||
The log then shows early errors too, such as a panic or an initrd that
|
||||
can't find /usr. Arguments after `--` go to qemu.
|
||||
- `mkosi ssh` runs a command as root once the VM has booted. For the user
|
||||
`agent`, run `su - agent -c '<command>'`.
|
||||
|
||||
`mkosi.version` gives every run a new version, so `mkosi vm` without `-f` fails
|
||||
with "has not been built yet". To boot an existing build without a rebuild, pin
|
||||
its version (from `mkosi.output/agent_<version>.raw`):
|
||||
`mkosi.version` gives each run a new version, so `mkosi vm` without `-f` fails
|
||||
with "has not been built yet". To boot an existing build again, pin its version
|
||||
from `mkosi.output/agentos_<version>.raw`:
|
||||
|
||||
```sh
|
||||
mkosi --image-version 202611171816.c80e843 vm
|
||||
|
||||
Reference in new issue
Block a user