feat: move install commands from xtask into clap subcommands
This commit is contained in:
1 parent
4dad85473b
commit
3acc577aac
15 files changed
+463
-381
No files matched your search
@@ -7,8 +7,9 @@ while it does. None of this is needed to install or configure it.
|
||||
|
||||
- **systemd ≥ 246 as PID 1.** bootvine reads the jobs and units from the
|
||||
service manager over D-Bus.
|
||||
- **libdbus.** It talks to PID 1 over systemd's private socket, which zbus
|
||||
cannot use; see [systemd's private socket](#systemds-private-socket).
|
||||
- **[libdbus](https://www.freedesktop.org/wiki/Software/dbus/).** It talks to
|
||||
PID 1 over systemd's private socket, which
|
||||
[zbus](https://github.com/dbus2/zbus) cannot use; see [systemd's private socket](#systemds-private-socket).
|
||||
- **A virtual terminal.** It draws on `tty12` and switches the console to it.
|
||||
|
||||
## Lifecycle
|
||||
@@ -52,8 +53,10 @@ back. Kernel messages from before it starts are already on screen; see
|
||||
|
||||
### Passphrase prompts
|
||||
|
||||
bootvine acts as a systemd password agent: it watches
|
||||
`/run/systemd/ask-password` and answers requests, such as a LUKS unlock, in a
|
||||
bootvine acts as a systemd
|
||||
[password agent](https://systemd.io/PASSWORD_AGENTS/): it watches
|
||||
`/run/systemd/ask-password` and answers requests, such as a
|
||||
[LUKS](https://gitlab.com/cryptsetup/cryptsetup) unlock, in a
|
||||
popup over the tree. If another agent's prompt is already showing when it
|
||||
starts, it stays behind it and comes forward once the prompt is answered.
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Every setting has a default, so bootvine needs no configuration. To change
|
||||
some, write only those keys:
|
||||
|
||||
- **On NixOS**, under `services.bootvine.settings`. The module writes them to
|
||||
- **On [NixOS](https://nixos.org)**, under `services.bootvine.settings`. The module writes them to
|
||||
`/etc/bootvine.toml` in the real root and the initrd, and the rebuild fails
|
||||
if `bootvine check` rejects them.
|
||||
|
||||
@@ -25,7 +25,8 @@ some, write only those keys:
|
||||
```
|
||||
|
||||
Then check the file and, if bootvine runs in your initrd, rebuild the
|
||||
initramfs, since the dracut and mkinitcpio hooks copy the file into it:
|
||||
initramfs, since the [dracut](https://github.com/dracut-ng/dracut-ng) and
|
||||
[mkinitcpio](https://wiki.archlinux.org/title/Mkinitcpio) hooks copy the file into it:
|
||||
|
||||
```sh
|
||||
bootvine check /etc/bootvine.toml
|
||||
|
||||
+11
-9
@@ -2,8 +2,9 @@
|
||||
|
||||
## Setup
|
||||
|
||||
Work inside the dev shell (`direnv allow` once). Version control is jj, not
|
||||
the `git` CLI.
|
||||
Work inside the dev shell (`direnv allow` once, with
|
||||
[direnv](https://direnv.net)). Version control is
|
||||
[jj](https://github.com/jj-vcs/jj), not the `git` CLI.
|
||||
|
||||
## Before committing
|
||||
|
||||
@@ -23,14 +24,15 @@ nix run .#check-conventional-commits -- origin/main..HEAD
|
||||
```
|
||||
|
||||
Git users can install the same commit-message check and a formatting check as
|
||||
hooks with `prek install` (from the dev shell) or `pre-commit install`.
|
||||
hooks with `prek install` ([prek](https://github.com/j178/prek), from the dev
|
||||
shell) or `pre-commit install` ([pre-commit](https://pre-commit.com)).
|
||||
|
||||
## Continuous integration
|
||||
|
||||
`.woodpecker/rust-and-flake-checks.yaml` runs on Codeberg for every push and
|
||||
pull request: the bootvine build with its tests, the xtask build, clippy,
|
||||
`.woodpecker/rust-and-flake-checks.yaml` runs on Codeberg's
|
||||
[Woodpecker CI](https://woodpecker-ci.org) for every push and pull request: the bootvine build with its tests, the xtask build, clippy,
|
||||
rustfmt, an evaluation of every flake output, and the commit-message check on
|
||||
pull requests. Builds on `main` are pushed to the `wvhulle` Cachix cache, which
|
||||
pull requests. Builds on `main` are pushed to the `wvhulle` [Cachix](https://www.cachix.org) cache, which
|
||||
`nixConfig` in `flake.nix` offers as a substituter. The two VM checks need KVM,
|
||||
which Codeberg's runners lack, so they only run locally.
|
||||
|
||||
@@ -61,14 +63,14 @@ on marker files instead of sleeping. To step through one by hand, run
|
||||
call `test_script()`.
|
||||
|
||||
Prefix VM and recording commands with `env -u LD_LIBRARY_PATH` when your shell
|
||||
exports libraries that clash with QEMU or Chromium.
|
||||
exports libraries that clash with [QEMU](https://www.qemu.org) or Chromium.
|
||||
|
||||
## Repository tasks
|
||||
|
||||
- `nix run .#record-screencasts` re-records the README animations from the
|
||||
scripted demos and copies the passphrase screenshot from the VM check.
|
||||
- `cargo xtask install --destdir <dir> --initrd dracut` stages an install
|
||||
without touching the system; `cargo xtask uninstall --destdir <dir>` removes
|
||||
- `cargo run -- install --destdir <dir> --initrd dracut` stages an install
|
||||
without touching the system; `cargo run -- uninstall --destdir <dir>` removes
|
||||
it again.
|
||||
|
||||
## Code style and design
|
||||
|
||||
+29
-22
@@ -45,54 +45,58 @@ as well, the initrd has to run systemd.
|
||||
|
||||
## Ubuntu
|
||||
|
||||
1. Install the build dependencies and Rust. The repository pins a nightly
|
||||
toolchain in `rust-toolchain.toml`, which rustup fetches on the first
|
||||
build:
|
||||
1. Install the build dependencies and Rust:
|
||||
|
||||
```sh
|
||||
sudo apt install build-essential pkg-config libdbus-1-dev git curl
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
||||
```
|
||||
|
||||
2. Clone, build and install the binary and the systemd units, and enable
|
||||
them. `cargo xtask install` builds as you and asks `sudo` only for the
|
||||
copying and `systemctl enable`:
|
||||
2. Build bootvine into `~/.cargo/bin`:
|
||||
|
||||
```sh
|
||||
git clone https://codeberg.org/wvhulle/bootvine.git
|
||||
cd bootvine
|
||||
cargo xtask install
|
||||
cargo install --locked --git https://codeberg.org/wvhulle/bootvine bootvine
|
||||
```
|
||||
|
||||
This installs `/usr/bin/bootvine`, and `bootvine.service` and
|
||||
`bootvine-shutdown.service` in `/usr/lib/systemd/system`, which is enough
|
||||
for stage 2 and shutdown.
|
||||
3. Install it for the system and enable its units. It asks `sudo` itself for
|
||||
the copying and `systemctl enable`:
|
||||
|
||||
3. Optionally, show the boot from the initrd. This needs a dracut initramfs
|
||||
with systemd in it; initramfs-tools has no systemd, so on releases that use
|
||||
```sh
|
||||
bootvine install
|
||||
```
|
||||
|
||||
This copies the binary to `/usr/bin/bootvine`, and `bootvine.service` and
|
||||
`bootvine-shutdown.service` to `/usr/lib/systemd/system`, which is enough
|
||||
for stage 2 and shutdown. The copy in `~/.cargo/bin` is no longer needed;
|
||||
`cargo uninstall bootvine` removes it.
|
||||
|
||||
4. Optionally, show the boot from the initrd. This needs a
|
||||
[dracut](https://github.com/dracut-ng/dracut-ng) initramfs with systemd in
|
||||
it; initramfs-tools has no systemd, so on releases that use
|
||||
it bootvine starts in stage 2 only.
|
||||
|
||||
```sh
|
||||
cargo xtask install --initrd dracut
|
||||
bootvine install --initrd dracut
|
||||
sudo dracut --force
|
||||
```
|
||||
|
||||
This adds the dracut module in `/usr/lib/dracut/modules.d/90bootvine` and
|
||||
enables it in `/etc/dracut.conf.d/bootvine.conf`.
|
||||
|
||||
4. Reboot.
|
||||
5. Reboot.
|
||||
|
||||
## Other distributions
|
||||
|
||||
Install as in the Ubuntu steps, with your distribution's packages for a C
|
||||
toolchain, `pkg-config` and the libdbus headers.
|
||||
|
||||
For the initrd, use the dracut module as above, or on mkinitcpio:
|
||||
For the initrd, use the dracut module as above, or on
|
||||
[mkinitcpio](https://wiki.archlinux.org/title/Mkinitcpio):
|
||||
|
||||
1. Install the hook in `/usr/lib/initcpio/install/sd-bootvine`:
|
||||
|
||||
```sh
|
||||
cargo xtask install --initrd mkinitcpio
|
||||
bootvine install --initrd mkinitcpio
|
||||
```
|
||||
|
||||
2. Add `sd-bootvine` after `systemd` in `HOOKS` in `/etc/mkinitcpio.conf`.
|
||||
@@ -105,10 +109,13 @@ For the initrd, use the dracut module as above, or on mkinitcpio:
|
||||
|
||||
## Packaging
|
||||
|
||||
`cargo xtask install --destdir <dir>` stages the files under `<dir>` instead of
|
||||
the root, and combines with `--initrd`.
|
||||
`bootvine install --destdir <dir>` stages the files under `<dir>` instead of
|
||||
the root, without `sudo` or `systemctl`, and combines with `--initrd` and
|
||||
`--prefix`. The units' `ExecStart` follows `--prefix`. The initrd hooks expect
|
||||
the default `/usr`.
|
||||
|
||||
## Uninstall
|
||||
|
||||
`cargo xtask uninstall` removes everything `cargo xtask install` put in place.
|
||||
On NixOS, remove `services.bootvine.enable` and rebuild.
|
||||
`bootvine uninstall` disables and removes everything `bootvine install` put in
|
||||
place, with the same `--prefix` and `--destdir`. On NixOS, remove
|
||||
`services.bootvine.enable` and rebuild.
|
||||
Reference in new issue
Block a user