Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ebb8e95a72 |
No files matched your search
@@ -1,2 +0,0 @@
|
||||
[alias]
|
||||
xtask = "run --quiet --package xtask --"
|
||||
@@ -1,3 +0,0 @@
|
||||
target
|
||||
result*
|
||||
/recordings/
|
||||
@@ -1,15 +0,0 @@
|
||||
default_install_hook_types: [pre-commit, commit-msg]
|
||||
repos:
|
||||
- repo: https://github.com/compilerla/conventional-pre-commit
|
||||
rev: v4.4.0
|
||||
hooks:
|
||||
- id: conventional-pre-commit
|
||||
stages: [commit-msg]
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: rustfmt-formatting
|
||||
name: rustfmt formatting
|
||||
entry: cargo fmt --all --check
|
||||
language: system
|
||||
types: [rust]
|
||||
pass_filenames: false
|
||||
@@ -1,10 +0,0 @@
|
||||
edition = "2024"
|
||||
format_code_in_doc_comments = true
|
||||
format_strings = true
|
||||
group_imports = "StdExternalCrate"
|
||||
imports_granularity = "Crate"
|
||||
normalize_comments = true
|
||||
normalize_doc_attributes = true
|
||||
unstable_features = true
|
||||
use_field_init_shorthand = true
|
||||
wrap_comments = true
|
||||
@@ -1,45 +0,0 @@
|
||||
when:
|
||||
- repo: wvhulle/bootvine
|
||||
event: [push, manual]
|
||||
branch: main
|
||||
|
||||
depends_on:
|
||||
- rust-and-flake-checks
|
||||
|
||||
clone:
|
||||
- name: clone-with-history-and-tags
|
||||
image: woodpeckerci/plugin-git
|
||||
settings:
|
||||
depth: 0
|
||||
partial: false
|
||||
tags: true
|
||||
|
||||
variables:
|
||||
- &release_env
|
||||
NIX_CONFIG: |
|
||||
experimental-features = nix-command flakes
|
||||
build-users-group =
|
||||
accept-flake-config = true
|
||||
GIT_AUTHOR_NAME: release-plz
|
||||
GIT_AUTHOR_EMAIL: willemvanhulle@protonmail.com
|
||||
GIT_COMMITTER_NAME: release-plz
|
||||
GIT_COMMITTER_EMAIL: willemvanhulle@protonmail.com
|
||||
CODEBERG_TOKEN:
|
||||
from_secret: codeberg_token
|
||||
CARGO_REGISTRY_TOKEN:
|
||||
from_secret: cargo_registry_token
|
||||
|
||||
steps:
|
||||
- name: publish-crate-and-tag-release
|
||||
image: nixos/nix:latest
|
||||
environment: *release_env
|
||||
commands:
|
||||
- git remote set-url origin "https://wvhulle:$${CODEBERG_TOKEN}@codeberg.org/$${CI_REPO}.git"
|
||||
- git checkout -B main "$${CI_COMMIT_SHA}"
|
||||
- nix run .#release-plz-release
|
||||
|
||||
- name: update-release-pr
|
||||
image: nixos/nix:latest
|
||||
environment: *release_env
|
||||
commands:
|
||||
- nix run .#release-plz-release-pr
|
||||
@@ -1,87 +0,0 @@
|
||||
when:
|
||||
- repo: wvhulle/bootvine
|
||||
event: [pull_request, push, manual]
|
||||
|
||||
variables:
|
||||
- &nix_config
|
||||
NIX_CONFIG: |
|
||||
experimental-features = nix-command flakes
|
||||
build-users-group =
|
||||
accept-flake-config = true
|
||||
- &cache_writing_env
|
||||
<<: *nix_config
|
||||
CACHIX_AUTH_TOKEN:
|
||||
from_secret: cachix_auth_token
|
||||
- &on_main_branch
|
||||
- event: [push, manual]
|
||||
branch: main
|
||||
- &off_main_branch
|
||||
- event: pull_request
|
||||
- event: [push, manual]
|
||||
branch:
|
||||
exclude: main
|
||||
- &on_pull_requests
|
||||
- event: pull_request
|
||||
|
||||
steps:
|
||||
- name: build-test-and-cache-bootvine
|
||||
image: nixos/nix:latest
|
||||
depends_on: []
|
||||
when: *on_main_branch
|
||||
environment: *cache_writing_env
|
||||
commands:
|
||||
- nix run .#build-and-push-to-cachix -- .#checks.x86_64-linux.bootvine-build
|
||||
|
||||
- name: build-and-test-bootvine
|
||||
image: nixos/nix:latest
|
||||
depends_on: []
|
||||
when: *off_main_branch
|
||||
environment: *nix_config
|
||||
commands:
|
||||
- nix build --print-build-logs .#checks.x86_64-linux.bootvine-build
|
||||
|
||||
- name: build-and-cache-repo-tasks
|
||||
image: nixos/nix:latest
|
||||
depends_on: []
|
||||
when: *on_main_branch
|
||||
environment: *cache_writing_env
|
||||
commands:
|
||||
- nix run .#build-and-push-to-cachix -- .#checks.x86_64-linux.repo-tasks-build
|
||||
|
||||
- name: build-repo-tasks
|
||||
image: nixos/nix:latest
|
||||
depends_on: []
|
||||
when: *off_main_branch
|
||||
environment: *nix_config
|
||||
commands:
|
||||
- nix build --print-build-logs .#checks.x86_64-linux.repo-tasks-build
|
||||
|
||||
- name: lint-rust-with-clippy
|
||||
image: nixos/nix:latest
|
||||
depends_on: []
|
||||
environment: *nix_config
|
||||
commands:
|
||||
- nix build --print-build-logs .#checks.x86_64-linux.clippy-lints
|
||||
|
||||
- name: check-rust-formatting
|
||||
image: nixos/nix:latest
|
||||
depends_on: []
|
||||
environment: *nix_config
|
||||
commands:
|
||||
- nix build --print-build-logs .#checks.x86_64-linux.rustfmt-formatting
|
||||
|
||||
- name: evaluate-flake-outputs
|
||||
image: nixos/nix:latest
|
||||
depends_on: []
|
||||
environment: *nix_config
|
||||
commands:
|
||||
- nix flake check --no-build
|
||||
|
||||
- name: check-conventional-commit-messages
|
||||
image: nixos/nix:latest
|
||||
depends_on: []
|
||||
when: *on_pull_requests
|
||||
environment: *nix_config
|
||||
commands:
|
||||
- git fetch --quiet origin "$${CI_COMMIT_TARGET_BRANCH}"
|
||||
- nix run .#check-conventional-commits -- FETCH_HEAD..HEAD
|
||||
@@ -1,122 +0,0 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [0.1.2](https://codeberg.org/wvhulle/bootvine/compare/v0.1.1...v0.1.2) - 2026-11-02
|
||||
|
||||
### Added
|
||||
|
||||
- show the kernel's image loading progress while resuming from hibernation
|
||||
- say when the screen is waiting for the system manager
|
||||
|
||||
### Changed
|
||||
|
||||
- reduce screen spacing to a small named set and declarative layouts
|
||||
|
||||
### Fixed
|
||||
|
||||
- repaint the whole screen while the root switches
|
||||
- finish console setup before resuming from hibernation
|
||||
|
||||
## [0.1.1](https://codeberg.org/wvhulle/bootvine/compare/v0.1.0...v0.1.1) - 2026-10-30
|
||||
|
||||
### Changed
|
||||
|
||||
- read the release environment from the crate build and generate the sample machine apps
|
||||
- keep recordings on an orphan branch
|
||||
|
||||
## [0.1.0](https://codeberg.org/wvhulle/bootvine/releases/tag/v0.1.0) - 2026-10-25
|
||||
|
||||
### Added
|
||||
|
||||
- follow shutdowns on the boot console
|
||||
- font-aware glyphs, quieter tree and timeline
|
||||
- support luks
|
||||
- better tree view
|
||||
- show the demo passphrase and say when an answer was wrong
|
||||
- print the version with --version
|
||||
- animate at 60 fps with timers in hundredths and bars that grow by eighths
|
||||
- move install commands from xtask into clap subcommands
|
||||
- show timeout timer
|
||||
|
||||
### Build
|
||||
|
||||
- raise MSRV to 1.91 for const Duration::from_mins
|
||||
- shrink the release binary from 2.82 MB to 1.74 MB
|
||||
- add tokio and futures for the stream loop
|
||||
|
||||
### Changed
|
||||
|
||||
- reduce polling
|
||||
- build graph first and then render
|
||||
- give modules descriptive names
|
||||
- build the waiting graph once with petgraph
|
||||
- fit and fold the waiting forest in the view
|
||||
- split model and view into files under 500 lines
|
||||
- decide phase, milestones and quit keys once
|
||||
- keep unit timestamps as one Activity
|
||||
- derive errors with thiserror
|
||||
- group modules by data-flow stage behind a thin main
|
||||
- parse systemd state strings at the bus boundary
|
||||
- parse systemd strings with serde_plain
|
||||
- reorganise flake, tests and repo tasks
|
||||
- drive the spinner by time instead of frame count
|
||||
- drive the watch loop with async streams in the Elm style
|
||||
|
||||
### Documentation
|
||||
|
||||
- compact README, move workflow to CONTRIBUTING
|
||||
- add boot screenshots
|
||||
- GIFs and install steps
|
||||
- automate gif generation
|
||||
- improve documentation of settings using a subcommand
|
||||
- add metadata for crates.io
|
||||
|
||||
### Fixed
|
||||
|
||||
- stand down when started after boot finished
|
||||
- separation of tree and timeline
|
||||
- arrow glyph
|
||||
- add luks prompt to fix broken on external keyboard
|
||||
- shutdown
|
||||
- make prompt LUKS more visible
|
||||
- passing control to display manager too early
|
||||
- add license
|
||||
- animation timeline loops
|
||||
- handover too early
|
||||
- yield the console once the display manager starts
|
||||
- deal with scripted initrd changes in nixos unstable
|
||||
- Ubuntu bugs
|
||||
|
||||
### Miscellaneous
|
||||
|
||||
- upgrade inputs
|
||||
- set initial version 0.1.0
|
||||
|
||||
### Other
|
||||
|
||||
- live systemd boot dependency tree on a dedicated VT
|
||||
- libdbus feed thread, dedicated VT, stage sections, bead timeline, demo example
|
||||
- single-threaded feed, Duration timestamps, fields over getters, jiff formatting
|
||||
- portable unit, dracut and mkinitcpio hooks, self-quieting console, minimal NixOS module
|
||||
- palette options, finished-run timeline, readable unit names, repaint on reconnect, handover frame
|
||||
- rename boot-tree to bootvine
|
||||
|
||||
### Performance
|
||||
|
||||
- small improvements
|
||||
- reach each sibling once when nesting waiting units
|
||||
- await systemd replies instead of blocking the screen
|
||||
- rebuild the waiting tree only when the boot changed
|
||||
- repaint the whole console only when something disturbed it
|
||||
|
||||
### Testing
|
||||
|
||||
- shutdown demo
|
||||
- share boot fixtures between model and view tests
|
||||
- measure the cost of one boot frame
|
||||
@@ -1,2402 +0,0 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "1.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "allocator-api2"
|
||||
version = "0.2.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
|
||||
|
||||
[[package]]
|
||||
name = "anstream"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"anstyle-parse",
|
||||
"anstyle-query",
|
||||
"anstyle-wincon",
|
||||
"colorchoice",
|
||||
"is_terminal_polyfill",
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle"
|
||||
version = "1.0.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000"
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-parse"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e"
|
||||
dependencies = [
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-query"
|
||||
version = "1.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc"
|
||||
dependencies = [
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-wincon"
|
||||
version = "3.0.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"once_cell_polyfill",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.104"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470"
|
||||
|
||||
[[package]]
|
||||
name = "approx"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cab112f0a86d568ea0e627cc1d6be74a1e9cd55214684db5561995f6dad897c6"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "atomic"
|
||||
version = "0.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a89cbf775b137e9b968e67227ef7f775587cde3fd31b0d8599dbd0f598a48340"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.22.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
|
||||
|
||||
[[package]]
|
||||
name = "bit-set"
|
||||
version = "0.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1"
|
||||
dependencies = [
|
||||
"bit-vec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bit-vec"
|
||||
version = "0.6.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.13.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"
|
||||
dependencies = [
|
||||
"serde_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "block-buffer"
|
||||
version = "0.10.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bootvine"
|
||||
version = "0.1.2"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"crossterm 0.29.0",
|
||||
"dbus",
|
||||
"futures",
|
||||
"heck",
|
||||
"jiff",
|
||||
"petgraph",
|
||||
"ratatui",
|
||||
"rustix 1.1.5",
|
||||
"ser_nix",
|
||||
"serde",
|
||||
"serde_plain",
|
||||
"systemd",
|
||||
"thiserror 2.0.21",
|
||||
"tokio",
|
||||
"toml",
|
||||
"unicode-truncate",
|
||||
"unicode-width",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "build-env"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1522ac6ee801a11bf9ef3f80403f4ede6eb41291fac3dde3de09989679305f25"
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.20.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649"
|
||||
|
||||
[[package]]
|
||||
name = "by_address"
|
||||
version = "1.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "64fa3c856b712db6612c019f14756e64e4bcea13337a6b33b696333a9eaa2d06"
|
||||
|
||||
[[package]]
|
||||
name = "bytemuck"
|
||||
version = "1.25.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "95832e849adfb21180ccb6826a99da14e5d266ae5c2e668e1602cf234f153797"
|
||||
|
||||
[[package]]
|
||||
name = "castaway"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dec551ab6e7578819132c713a93c022a05d60159dc86e7a7050223577484c55a"
|
||||
dependencies = [
|
||||
"rustversion",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "877bf67ac8e52449eb2f9e98a344ea163beb70dd1f9eebe3cc5357dcfeaee4df"
|
||||
dependencies = [
|
||||
"find-msvc-tools",
|
||||
"shlex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
|
||||
|
||||
[[package]]
|
||||
name = "cfg_aliases"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527"
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.6.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aa8876b300ab35ba921adea3dfd70157a46249b33f95c9084ae5709785478946"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.6.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec0797fb7aeb1406c84efac526901f7ec3ead2124f946b494e72879d4b54704d"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
"clap_lex",
|
||||
"strsim",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "4.6.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f9c751b79415d4e559e3d1fcf128e09e720eb673a06d26cf6f392d37d75b66e0"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 3.0.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_lex"
|
||||
version = "1.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1c133bc6a41be0d194c306b5506d15e6feeea7b1d6604bd3f8310dfb2ca96486"
|
||||
|
||||
[[package]]
|
||||
name = "colorchoice"
|
||||
version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570"
|
||||
|
||||
[[package]]
|
||||
name = "compact_str"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9dfdd1c2274d9aa354115b09dc9a901d6c5576818cdf70d14cae2bdb47df00ab"
|
||||
dependencies = [
|
||||
"castaway",
|
||||
"cfg-if",
|
||||
"itoa",
|
||||
"rustversion",
|
||||
"ryu",
|
||||
"serde",
|
||||
"static_assertions",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "convert_case"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "633458d4ef8c78b72454de2d54fd6ab2e60f9e02be22f3c6104cdc8a4e0fceb9"
|
||||
dependencies = [
|
||||
"unicode-segmentation",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cpufeatures"
|
||||
version = "0.2.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "critical-section"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b"
|
||||
|
||||
[[package]]
|
||||
name = "crossterm"
|
||||
version = "0.28.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"crossterm_winapi",
|
||||
"mio",
|
||||
"parking_lot",
|
||||
"rustix 0.38.44",
|
||||
"serde",
|
||||
"signal-hook",
|
||||
"signal-hook-mio",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossterm"
|
||||
version = "0.29.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d8b9f2e4c67f833b660cdb0a3523065869fb35570177239812ed4c905aeff87b"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"crossterm_winapi",
|
||||
"derive_more",
|
||||
"document-features",
|
||||
"mio",
|
||||
"parking_lot",
|
||||
"rustix 1.1.5",
|
||||
"serde",
|
||||
"signal-hook",
|
||||
"signal-hook-mio",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossterm_winapi"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crypto-common"
|
||||
version = "0.1.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "csscolorparser"
|
||||
version = "0.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eb2a7d3066da2de787b7f032c736763eb7ae5d355f81a68bab2675a96008b0bf"
|
||||
dependencies = [
|
||||
"lab",
|
||||
"phf",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cstr-argument"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6bd9c8e659a473bce955ae5c35b116af38af11a7acb0b480e01f3ed348aeb40"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "darling"
|
||||
version = "0.24.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed17f5901b6630b993ca003def43f2f8ef4014fc13b047b57aad617ff32bc2ec"
|
||||
dependencies = [
|
||||
"darling_core",
|
||||
"darling_macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "darling_core"
|
||||
version = "0.24.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6837e2cf7485aaae18f86181d2f0e9a7ed297a025e220aeabf63fdebd3a2ddff"
|
||||
dependencies = [
|
||||
"ident_case",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"strsim",
|
||||
"syn 3.0.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "darling_macro"
|
||||
version = "0.24.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2ac7135c3ef02b2f7833bbeb1be5ba7f966dcde8a87c6b87f65a778d71a02785"
|
||||
dependencies = [
|
||||
"darling_core",
|
||||
"quote",
|
||||
"syn 3.0.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dbus"
|
||||
version = "0.9.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3ab69f03cc8c4340c9c8e315114e1658e6775a9b16a04357973aa21cec22b32e"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"libdbus-sys",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "defmt"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e4a0795ac740cb54d7b3775c9c17345f6aaecf884c01733b39d6017738e0e3e1"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"defmt-macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "defmt-macros"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "840bb056bd99c495c9188198a258ab787c79f306d864db3e6e8451442d6d8366"
|
||||
dependencies = [
|
||||
"defmt-parser",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 3.0.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "defmt-parser"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "71958f69fb2de856c5dd51ac9377e986ca1aa5919f931bf5395a807277f889a0"
|
||||
dependencies = [
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "deltae"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5729f5117e208430e437df2f4843f5e5952997175992d1414f94c57d61e270b4"
|
||||
|
||||
[[package]]
|
||||
name = "deranged"
|
||||
version = "0.5.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9e9de72ce2ad1f90dc62fa25f0f430ef85eb4b0d8fa0be4f30373bc40a21d28e"
|
||||
|
||||
[[package]]
|
||||
name = "derive_more"
|
||||
version = "2.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d751e9e49156b02b44f9c1815bcb94b984cdcc4396ecc32521c739452808b134"
|
||||
dependencies = [
|
||||
"derive_more-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derive_more-impl"
|
||||
version = "2.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "799a97264921d8623a957f6c3b9011f3b5492f557bbb7a5a19b7fa6d06ba8dcb"
|
||||
dependencies = [
|
||||
"convert_case",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"rustc_version",
|
||||
"syn 2.0.119",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.10.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
|
||||
dependencies = [
|
||||
"block-buffer",
|
||||
"crypto-common",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "document-features"
|
||||
version = "0.2.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d4b8a88685455ed29a21542a33abd9cb6510b6b129abadabdcef0f4c55bc8f61"
|
||||
dependencies = [
|
||||
"litrs",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.19.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be"
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826"
|
||||
|
||||
[[package]]
|
||||
name = "errno"
|
||||
version = "0.3.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "euclid"
|
||||
version = "0.22.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f1a05365e3b1c6d1650318537c7460c6923f1abdd272ad6842baa2b509957a06"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fancy-regex"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b95f7c0680e4142284cf8b22c14a476e87d61b004a3a0861872b32ef7ead40a2"
|
||||
dependencies = [
|
||||
"bit-set",
|
||||
"regex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "filedescriptor"
|
||||
version = "0.8.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e40758ed24c9b2eeb76c35fb0aebc66c626084edd827e07e1552279814c6682d"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"thiserror 1.0.69",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "find-msvc-tools"
|
||||
version = "0.1.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48"
|
||||
|
||||
[[package]]
|
||||
name = "finl_unicode"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "80bb028c8b4148c9ee0cca68fcd9add6044e81d3619f48577ddf13a263d047a2"
|
||||
|
||||
[[package]]
|
||||
name = "fixedbitset"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80"
|
||||
|
||||
[[package]]
|
||||
name = "fixedbitset"
|
||||
version = "0.5.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99"
|
||||
|
||||
[[package]]
|
||||
name = "fnv"
|
||||
version = "1.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
||||
|
||||
[[package]]
|
||||
name = "foldhash"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
|
||||
|
||||
[[package]]
|
||||
name = "foldhash"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb"
|
||||
|
||||
[[package]]
|
||||
name = "foreign-types"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965"
|
||||
dependencies = [
|
||||
"foreign-types-macros",
|
||||
"foreign-types-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "foreign-types-macros"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ea5190182e6915eb873ddbc16e23b711b6eb1f9c00a0d0a3a91b5f6228475225"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 3.0.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "foreign-types-shared"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b"
|
||||
|
||||
[[package]]
|
||||
name = "futures"
|
||||
version = "0.3.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a31d2a3fbaaeb2af2368bbdd904aa8e812d3c04a1ee10d3171f52d556e5d0a3"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-io",
|
||||
"futures-sink",
|
||||
"futures-task",
|
||||
"futures-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-channel"
|
||||
version = "0.3.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-core"
|
||||
version = "0.3.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e"
|
||||
|
||||
[[package]]
|
||||
name = "futures-io"
|
||||
version = "0.3.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed"
|
||||
|
||||
[[package]]
|
||||
name = "futures-macro"
|
||||
version = "0.3.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9fb9654ba8355388abeb8dcb4fc62f511300867002afc858860463bdd9fe0c44"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 3.0.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-sink"
|
||||
version = "0.3.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1944426bf7d03f1d14f708785e4b33efd750b36d48a157b836b3efc15ede8e1d"
|
||||
|
||||
[[package]]
|
||||
name = "futures-task"
|
||||
version = "0.3.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd"
|
||||
|
||||
[[package]]
|
||||
name = "futures-util"
|
||||
version = "0.3.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-io",
|
||||
"futures-macro",
|
||||
"futures-sink",
|
||||
"futures-task",
|
||||
"memchr",
|
||||
"pin-project-lite",
|
||||
"slab",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.14.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
|
||||
dependencies = [
|
||||
"typenum",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"r-efi 5.3.0",
|
||||
"wasip2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"r-efi 6.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.15.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"
|
||||
dependencies = [
|
||||
"foldhash 0.1.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.17.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"
|
||||
dependencies = [
|
||||
"allocator-api2",
|
||||
"equivalent",
|
||||
"foldhash 0.2.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||
|
||||
[[package]]
|
||||
name = "hex"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
|
||||
|
||||
[[package]]
|
||||
name = "ident_case"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.14.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855"
|
||||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown 0.17.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indoc"
|
||||
version = "2.0.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a37b2691796cffeb8a8cd305ac66e65841559f147f4e63231d0eafa4db5384d1"
|
||||
dependencies = [
|
||||
"rustversion",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "instability"
|
||||
version = "0.3.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4c3b5acc1e2fd9375041a388da33d1eb8aed5f7a8c0dd3543e3ea2805adfbe20"
|
||||
dependencies = [
|
||||
"darling",
|
||||
"indoc",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 3.0.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "is_terminal_polyfill"
|
||||
version = "1.70.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695"
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
|
||||
|
||||
[[package]]
|
||||
name = "jiff"
|
||||
version = "0.2.38"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b2b005715dcbeb0089a3c0dab99f2ff1cc3b2525323552703d648585d342a383"
|
||||
dependencies = [
|
||||
"defmt",
|
||||
"jiff-core",
|
||||
"jiff-static",
|
||||
"log",
|
||||
"portable-atomic",
|
||||
"portable-atomic-util",
|
||||
"serde_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jiff-core"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5e52fe76043ccecc9005d2305ebaadf7d7fc0cc89ca6baa10a94d6bc68c7128c"
|
||||
dependencies = [
|
||||
"defmt",
|
||||
"log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jiff-static"
|
||||
version = "0.2.38"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2cc9817253cf7c7ee4684451bd327e88d6f3658014e54a29198625590650695c"
|
||||
dependencies = [
|
||||
"jiff-core",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.119",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.106"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7883d941dae510fb2d978fc3fe018c71c9e2892fd38854de3e8b92c2e5ad9cc5"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"futures-util",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "kasuari"
|
||||
version = "0.4.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72f14c90e40a6133f4805b83542a7ed7364f56070b447f56e7f4e90297122209"
|
||||
dependencies = [
|
||||
"hashbrown 0.17.1",
|
||||
"portable-atomic",
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lab"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bf36173d4167ed999940f804952e6b08197cae5ad5d572eb4db150ce8ad5d58f"
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "20870f649af7073d53e38067b2a84312175d56ea15217e1b15bc83506ec50afb"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.191"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
|
||||
|
||||
[[package]]
|
||||
name = "libdbus-sys"
|
||||
version = "0.2.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "328c4789d42200f1eeec05bd86c9c13c7f091d2ba9a6ea35acdf51f31bc0f043"
|
||||
dependencies = [
|
||||
"pkg-config",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libm"
|
||||
version = "0.2.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981"
|
||||
|
||||
[[package]]
|
||||
name = "libsystemd-sys"
|
||||
version = "0.9.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "976306de183e6046819ef6505888d00996214766a3f4660a2ed5761c84a20aed"
|
||||
dependencies = [
|
||||
"build-env",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"pkg-config",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "line-clipping"
|
||||
version = "0.3.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e752191d037c44ad111a8caa762921926658402f01cc1253f7bef2020ece4f5e"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.4.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab"
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53"
|
||||
|
||||
[[package]]
|
||||
name = "litrs"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4744e383959f0db86ede514b809b1c53251889093803c05267acc7d4e7030d70"
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.4.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965"
|
||||
dependencies = [
|
||||
"scopeguard",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6"
|
||||
|
||||
[[package]]
|
||||
name = "lru"
|
||||
version = "0.18.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ef9ac18847474e638e3702b76c65d4eb93428471a74778ef0f1be711717f89b5"
|
||||
dependencies = [
|
||||
"hashbrown 0.17.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mac_address"
|
||||
version = "1.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f3d0581a75c45969c63afd2bb87b1d8b25cfcc556c7a918cf9bb13b0fe8d2381"
|
||||
dependencies = [
|
||||
"nix 0.31.3",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.8.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
|
||||
|
||||
[[package]]
|
||||
name = "memmem"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a64a92489e2744ce060c349162be1c5f33c6969234104dbd99ddb5feb08b8c15"
|
||||
|
||||
[[package]]
|
||||
name = "memoffset"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "minimal-lexical"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
||||
|
||||
[[package]]
|
||||
name = "mio"
|
||||
version = "1.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1788edb87fdc09c7e26304471e2f5be8cdefb1b6930d6e3985fc02ff53bf86ee"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"log",
|
||||
"wasi",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.29.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"cfg-if",
|
||||
"cfg_aliases",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.31.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf20d2fde8ff38632c426f1165ed7436270b44f199fc55284c38276f9db47c3d"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"cfg-if",
|
||||
"cfg_aliases",
|
||||
"libc",
|
||||
"memoffset",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nom"
|
||||
version = "7.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
"minimal-lexical",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-conv"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441"
|
||||
|
||||
[[package]]
|
||||
name = "num-derive"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.119",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_threads"
|
||||
version = "0.1.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cabcc654086861f9e1bc5115258de62ef92c79b20f4615a1b0cc57c4e82027d4"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "numtoa"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6aa2c4e539b869820a2b82e1aef6ff40aa85e65decdd5185e83fb4b1249cd00f"
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.21.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
||||
|
||||
[[package]]
|
||||
name = "once_cell_polyfill"
|
||||
version = "1.70.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
|
||||
|
||||
[[package]]
|
||||
name = "ordered-float"
|
||||
version = "4.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7bb71e1b3fa6ca1c61f383464aaf2bb0e2f8e772a1f01d486832464de363b951"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "palette"
|
||||
version = "0.7.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ddeed8580d347d2abf3dcf06a5f0b3dc020258338526b277847cd4248a70fc64"
|
||||
dependencies = [
|
||||
"approx",
|
||||
"libm",
|
||||
"palette_derive",
|
||||
"palette_math",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "palette_derive"
|
||||
version = "0.7.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "88537020289b719d81be994ccf1bbf4990f477e2f69ee52fe3e45f43a02e56be"
|
||||
dependencies = [
|
||||
"by_address",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.119",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "palette_math"
|
||||
version = "0.7.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6e6eb142958d64335fb0e345c5b9ead2ecd6fc438c307e9d7d3c4fd428dbaf12"
|
||||
dependencies = [
|
||||
"libm",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot"
|
||||
version = "0.12.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a"
|
||||
dependencies = [
|
||||
"lock_api",
|
||||
"parking_lot_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot_core"
|
||||
version = "0.9.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
"smallvec",
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pest"
|
||||
version = "2.9.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fd47a460a9cbc3b3429c7e22bf0d76653e779319bae45a499ca010c9a990bb23"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
"psm",
|
||||
"stacker",
|
||||
"ucd-trie",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pest_derive"
|
||||
version = "2.9.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "203e46697708f7519ab1608393cf89239cafb46b8e6d08a8ffe359359b11ef44"
|
||||
dependencies = [
|
||||
"pest",
|
||||
"pest_generator",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pest_generator"
|
||||
version = "2.9.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e84ae6340a458d3d6cfc73cf328cf3cfe90b2484cd0de25eb66aa954615ed4d5"
|
||||
dependencies = [
|
||||
"pest",
|
||||
"pest_meta",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 3.0.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pest_meta"
|
||||
version = "2.9.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b57f92f32b3dbce6598fd8f5cdf1f06a6072570b8103fa21728fa9036923e710"
|
||||
dependencies = [
|
||||
"pest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "petgraph"
|
||||
version = "0.8.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8701b58ea97060d5e5b155d383a69952a60943f0e6dfe30b04c287beb0b27455"
|
||||
dependencies = [
|
||||
"fixedbitset 0.5.7",
|
||||
"hashbrown 0.15.5",
|
||||
"indexmap",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "phf"
|
||||
version = "0.11.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078"
|
||||
dependencies = [
|
||||
"phf_macros",
|
||||
"phf_shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "phf_codegen"
|
||||
version = "0.11.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aef8048c789fa5e851558d709946d6d79a8ff88c0440c587967f8e94bfb1216a"
|
||||
dependencies = [
|
||||
"phf_generator",
|
||||
"phf_shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "phf_generator"
|
||||
version = "0.11.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d"
|
||||
dependencies = [
|
||||
"phf_shared",
|
||||
"rand",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "phf_macros"
|
||||
version = "0.11.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f84ac04429c13a7ff43785d75ad27569f2951ce0ffd30a3321230db2fc727216"
|
||||
dependencies = [
|
||||
"phf_generator",
|
||||
"phf_shared",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.119",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "phf_shared"
|
||||
version = "0.11.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5"
|
||||
dependencies = [
|
||||
"siphasher",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"
|
||||
|
||||
[[package]]
|
||||
name = "pkg-config"
|
||||
version = "0.3.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548"
|
||||
|
||||
[[package]]
|
||||
name = "portable-atomic"
|
||||
version = "1.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
|
||||
|
||||
[[package]]
|
||||
name = "portable-atomic-util"
|
||||
version = "0.2.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "10ab3eb7f3becc3a1cbc4f2c6f20267996cfc1a6467a873763411b136a122715"
|
||||
dependencies = [
|
||||
"portable-atomic",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "powerfmt"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4a6394b9e965e73d0a289ee54f589087e2c676aedf60885baf52c76b771e4958"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.107"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "psm"
|
||||
version = "0.1.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "200b9ff220857e53e184257720a14553b2f4aa02577d2ed9842d45d4b9654810"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.47"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "r-efi"
|
||||
version = "5.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
|
||||
|
||||
[[package]]
|
||||
name = "r-efi"
|
||||
version = "6.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e058c7de0b26af77780c769414d6257830bb240f3c38477dbc2c16e5f54d6d4c"
|
||||
dependencies = [
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
||||
|
||||
[[package]]
|
||||
name = "ratatui"
|
||||
version = "0.30.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3274ba0a2c5e1bcad2a2005d20f4dc59dad26b2eb0940fb094500dba4099d57d"
|
||||
dependencies = [
|
||||
"instability",
|
||||
"ratatui-core",
|
||||
"ratatui-crossterm",
|
||||
"ratatui-macros",
|
||||
"ratatui-termina",
|
||||
"ratatui-termion",
|
||||
"ratatui-termwiz",
|
||||
"ratatui-widgets",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ratatui-core"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cbb175c433c8e28a809d1f5773a2ae96e68c0ce40db865cbab1020bf33ae479c"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"compact_str",
|
||||
"critical-section",
|
||||
"hashbrown 0.17.1",
|
||||
"itertools",
|
||||
"kasuari",
|
||||
"lru",
|
||||
"palette",
|
||||
"serde",
|
||||
"strum",
|
||||
"thiserror 2.0.21",
|
||||
"unicode-segmentation",
|
||||
"unicode-truncate",
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ratatui-crossterm"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "567584a3b0e6a8203c23de40b4861497266725eb5363dbfd18a1edd603cca9f0"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"crossterm 0.28.1",
|
||||
"crossterm 0.29.0",
|
||||
"instability",
|
||||
"ratatui-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ratatui-macros"
|
||||
version = "0.7.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed7dc68daa7498a43e4d68e0eb078427e10c38fbcfbb1e42d955f1fa2140d814"
|
||||
dependencies = [
|
||||
"ratatui-core",
|
||||
"ratatui-widgets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ratatui-termina"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c0bf912d9e66f057a759d92e386a280ea886b352ab757d6ac4d653c7ed2c43c2"
|
||||
dependencies = [
|
||||
"instability",
|
||||
"ratatui-core",
|
||||
"termina",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ratatui-termion"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "87c732202fa5a71a9da0991013f0853e53f87048f45198e3a1ca3ee722accc2f"
|
||||
dependencies = [
|
||||
"instability",
|
||||
"ratatui-core",
|
||||
"termion",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ratatui-termwiz"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "faf03e0380b7744054d6cb74224fe3adf062a029754933f575ca1e3b4c2ce977"
|
||||
dependencies = [
|
||||
"ratatui-core",
|
||||
"termwiz",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ratatui-widgets"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "66e3d19bcc9130ca376277d93b60767ff121ace3be06f5f95f81dd68956407d1"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"hashbrown 0.17.1",
|
||||
"indoc",
|
||||
"instability",
|
||||
"itertools",
|
||||
"line-clipping",
|
||||
"ratatui-core",
|
||||
"serde",
|
||||
"strum",
|
||||
"time",
|
||||
"unicode-segmentation",
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.5.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-automata",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.4.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.8.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"
|
||||
|
||||
[[package]]
|
||||
name = "rustc_version"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92"
|
||||
dependencies = [
|
||||
"semver",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.38.44"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys 0.4.15",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "1.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "891efababe418670775f199f0d233d84843c227a0949a883ce15b37c78d6629d"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys 0.12.1",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
version = "1.0.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f"
|
||||
|
||||
[[package]]
|
||||
name = "scopeguard"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||
|
||||
[[package]]
|
||||
name = "scripted-demos"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bootvine",
|
||||
"futures",
|
||||
"ratatui",
|
||||
"tokio",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "1.0.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd"
|
||||
|
||||
[[package]]
|
||||
name = "ser_nix"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "15c4a28964fde1fd104730b0df327697c4e2adc0956d60a6514b832bb2df349d"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.229"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
|
||||
dependencies = [
|
||||
"serde_core",
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_core"
|
||||
version = "1.0.229"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.229"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 3.0.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_plain"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ce1fc6db65a611022b23a0dec6975d63fb80a302cb3388835ff02c097258d50"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_spanned"
|
||||
version = "1.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4e7523beb55eece201a2356bee0bbca0d1ab466c14c07703b2e0ee6d42cb0c2c"
|
||||
dependencies = [
|
||||
"serde_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha2"
|
||||
version = "0.10.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cpufeatures",
|
||||
"digest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shlex"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook"
|
||||
version = "0.3.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d881a16cf4426aa584979d30bd82cb33429027e42122b169753d6ef1085ed6e2"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"signal-hook-registry",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook-mio"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b75a19a7a740b25bc7944bdee6172368f988763b744e3d4dfe753f6b4ece40cc"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"mio",
|
||||
"signal-hook",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook-registry"
|
||||
version = "1.4.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b"
|
||||
dependencies = [
|
||||
"errno",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "siphasher"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "33f4fe9184a62d842c9ef383018f3306d8ba224fd9d836f56d7288308847c256"
|
||||
|
||||
[[package]]
|
||||
name = "slab"
|
||||
version = "0.4.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.16.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b3dc8af474f516a851ff4bd12db780f948b9250ad37211e4eec0bccea54e01b"
|
||||
|
||||
[[package]]
|
||||
name = "socket2"
|
||||
version = "0.6.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "stacker"
|
||||
version = "0.1.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "707f49d46706bacf8a2b00d51dace3f9de527c13eec3778f570c411f89e69967"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"psm",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "static_assertions"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
||||
|
||||
[[package]]
|
||||
name = "strum"
|
||||
version = "0.28.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9628de9b8791db39ceda2b119bbe13134770b56c138ec1d3af810d045c04f9bd"
|
||||
dependencies = [
|
||||
"strum_macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "strum_macros"
|
||||
version = "0.28.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ab85eea0270ee17587ed4156089e10b9e6880ee688791d45a905f5b1ca36f664"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.119",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.109"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.119"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "3.0.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "systemd"
|
||||
version = "0.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "01e9d1976a15b86245def55d20d52b5818e1a1e81aa030b6a608d3ce57709423"
|
||||
dependencies = [
|
||||
"cstr-argument",
|
||||
"foreign-types",
|
||||
"libc",
|
||||
"libsystemd-sys",
|
||||
"log",
|
||||
"memchr",
|
||||
"utf8-cstr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termina"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9048a889effe34a5cddee0af7f53285198b16dca3be510858d38dfdb3e62a04e"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"parking_lot",
|
||||
"rustix 1.1.5",
|
||||
"signal-hook",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "terminfo"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d4ea810f0692f9f51b382fff5893887bb4580f5fa246fde546e0b13e7fcee662"
|
||||
dependencies = [
|
||||
"fnv",
|
||||
"nom",
|
||||
"phf",
|
||||
"phf_codegen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termion"
|
||||
version = "4.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f44138a9ae08f0f502f24104d82517ef4da7330c35acd638f1f29d3cd5475ecb"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"numtoa",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termios"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "411c5bf740737c7918b8b1fe232dca4dc9f8e754b8ad5e20966814001ed0ac6b"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termwiz"
|
||||
version = "0.23.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4676b37242ccbd1aabf56edb093a4827dc49086c0ffd764a5705899e0f35f8f7"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"base64",
|
||||
"bitflags 2.13.2",
|
||||
"fancy-regex",
|
||||
"filedescriptor",
|
||||
"finl_unicode",
|
||||
"fixedbitset 0.4.2",
|
||||
"hex",
|
||||
"lazy_static",
|
||||
"libc",
|
||||
"log",
|
||||
"memmem",
|
||||
"nix 0.29.0",
|
||||
"num-derive",
|
||||
"num-traits",
|
||||
"ordered-float",
|
||||
"pest",
|
||||
"pest_derive",
|
||||
"phf",
|
||||
"serde",
|
||||
"sha2",
|
||||
"signal-hook",
|
||||
"siphasher",
|
||||
"terminfo",
|
||||
"termios",
|
||||
"thiserror 1.0.69",
|
||||
"ucd-trie",
|
||||
"unicode-segmentation",
|
||||
"vtparse",
|
||||
"wezterm-bidi",
|
||||
"wezterm-blob-leases",
|
||||
"wezterm-color-types",
|
||||
"wezterm-dynamic",
|
||||
"wezterm-input-types",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.69"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
|
||||
dependencies = [
|
||||
"thiserror-impl 1.0.69",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "2.0.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e"
|
||||
dependencies = [
|
||||
"thiserror-impl 2.0.21",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.69"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.119",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "2.0.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 3.0.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.3.55"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cdb87b95ec50ddfa440816d227a17b2ccbdda963a316a727fda0fc4334f7d134"
|
||||
dependencies = [
|
||||
"deranged",
|
||||
"libc",
|
||||
"num-conv",
|
||||
"num_threads",
|
||||
"powerfmt",
|
||||
"serde_core",
|
||||
"time-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time-core"
|
||||
version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9e1c906769ad99c88eaa54e728060edef082f8e358ff32030cb7c7d315e81109"
|
||||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "1.54.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a0c168a474b95bfecfe908a65d4bdffc523144b649a74c09c286afb35d53e0bc"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"mio",
|
||||
"pin-project-lite",
|
||||
"signal-hook-registry",
|
||||
"socket2",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "1.1.8+spec-1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "20489e00e4d8741d6be680764cc12e270655e375a20d1011e844a9c3379e678d"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"serde_core",
|
||||
"serde_spanned",
|
||||
"toml_datetime",
|
||||
"toml_parser",
|
||||
"toml_writer",
|
||||
"winnow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_datetime"
|
||||
version = "1.1.2+spec-1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b86d767906c6c42421dcba507eb9d203e779497710a47782a224bb871653053"
|
||||
dependencies = [
|
||||
"serde_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_parser"
|
||||
version = "1.1.5+spec-1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baa693a8032d7e1cada7d0041e96126df243179ff061456783ac7f12bda4744c"
|
||||
dependencies = [
|
||||
"winnow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_writer"
|
||||
version = "1.1.3+spec-1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06bdbd8cfc056b8d2e2e85f29b56a3bdbecb527cef81eb39e3e7b98af4652770"
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
version = "1.20.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20"
|
||||
|
||||
[[package]]
|
||||
name = "ucd-trie"
|
||||
version = "0.1.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-segmentation"
|
||||
version = "1.13.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-truncate"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "16b380a1238663e5f8a691f9039c73e1cdae598a30e9855f541d29b08b53e9a5"
|
||||
dependencies = [
|
||||
"itertools",
|
||||
"unicode-segmentation",
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254"
|
||||
|
||||
[[package]]
|
||||
name = "utf8-cstr"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "55bcbb425141152b10d5693095950b51c3745d019363fc2929ffd8f61449b628"
|
||||
|
||||
[[package]]
|
||||
name = "utf8parse"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||
|
||||
[[package]]
|
||||
name = "uuid"
|
||||
version = "1.28.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7cc1186384beb7dd8eedea376413fd654937285ea6c9cfbb928dc3043ea4b606"
|
||||
dependencies = [
|
||||
"atomic",
|
||||
"getrandom 0.4.3",
|
||||
"js-sys",
|
||||
"serde_core",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
||||
|
||||
[[package]]
|
||||
name = "vtparse"
|
||||
version = "0.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6d9b2acfb050df409c972a37d3b8e08cdea3bddb0c09db9d53137e504cfabed0"
|
||||
dependencies = [
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.11.1+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
|
||||
|
||||
[[package]]
|
||||
name = "wasip2"
|
||||
version = "1.0.4+wasi-0.2.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487"
|
||||
dependencies = [
|
||||
"wit-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.129"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9bb54f33acc68fd454578d9820b0bde1a1a3d17aa17bb7b6595806d02886d409"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"once_cell",
|
||||
"rustversion",
|
||||
"wasm-bindgen-macro",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.129"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2e29d0c35b16e224a7eeb5cd2d25e3e1968fbd65604117b44d3b789d00ee8535"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"wasm-bindgen-macro-support",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.129"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6f501a8bc3719dba86ef8ae4728879c08001bea749eb1333ac5b91e040e2a6b7"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 3.0.9",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.129"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "23f0c9c52aa7cd7d77769a4cfe2a9adb1b331f489a41d912ce14513d5ab995c6"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wezterm-bidi"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0c0a6e355560527dd2d1cf7890652f4f09bb3433b6aadade4c9b5ed76de5f3ec"
|
||||
dependencies = [
|
||||
"log",
|
||||
"wezterm-dynamic",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wezterm-blob-leases"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "692daff6d93d94e29e4114544ef6d5c942a7ed998b37abdc19b17136ea428eb7"
|
||||
dependencies = [
|
||||
"getrandom 0.3.4",
|
||||
"mac_address",
|
||||
"serde",
|
||||
"sha2",
|
||||
"thiserror 1.0.69",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wezterm-color-types"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7de81ef35c9010270d63772bebef2f2d6d1f2d20a983d27505ac850b8c4b4296"
|
||||
dependencies = [
|
||||
"csscolorparser",
|
||||
"deltae",
|
||||
"lazy_static",
|
||||
"serde",
|
||||
"wezterm-dynamic",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wezterm-dynamic"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5f2ab60e120fd6eaa68d9567f3226e876684639d22a4219b313ff69ec0ccd5ac"
|
||||
dependencies = [
|
||||
"log",
|
||||
"ordered-float",
|
||||
"strsim",
|
||||
"thiserror 1.0.69",
|
||||
"wezterm-dynamic-derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wezterm-dynamic-derive"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "46c0cf2d539c645b448eaffec9ec494b8b19bd5077d9e58cb1ae7efece8d575b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wezterm-input-types"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7012add459f951456ec9d6c7e6fc340b1ce15d6fc9629f8c42853412c029e57e"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"euclid",
|
||||
"lazy_static",
|
||||
"serde",
|
||||
"wezterm-dynamic",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "windows-link"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.59.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.61.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
|
||||
dependencies = [
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_gnullvm",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||
|
||||
[[package]]
|
||||
name = "winnow"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81"
|
||||
|
||||
[[package]]
|
||||
name = "wit-bindgen"
|
||||
version = "0.57.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e"
|
||||
|
||||
[[package]]
|
||||
name = "xshell"
|
||||
version = "0.2.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9e7290c623014758632efe00737145b6867b66292c42167f2ec381eb566a373d"
|
||||
dependencies = [
|
||||
"xshell-macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "xshell-macros"
|
||||
version = "0.2.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32ac00cd3f8ec9c1d33fb3e7958a82df6989c42d747bd326c822b1d625283547"
|
||||
|
||||
[[package]]
|
||||
name = "xtask"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"thiserror 2.0.21",
|
||||
"xshell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zeroize"
|
||||
version = "1.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e13084392c5e4bc371903e2935a5eaeed24905a7511356b883835e18a78f6879"
|
||||
@@ -1,15 +0,0 @@
|
||||
[workspace]
|
||||
members = ["bootvine", "scripted-demos", "xtask"]
|
||||
resolver = "3"
|
||||
|
||||
[workspace.lints.clippy]
|
||||
absolute_paths = "warn"
|
||||
missing_errors_doc = "allow"
|
||||
needless_for_each = "allow"
|
||||
pedantic = { priority = -1, level = "warn" }
|
||||
|
||||
[profile.release]
|
||||
codegen-units = 1
|
||||
lto = "fat"
|
||||
opt-level = "z"
|
||||
strip = true
|
||||
@@ -1,674 +0,0 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
@@ -1,60 +0,0 @@
|
||||
# bootvine
|
||||
|
||||
A live tree of systemd jobs on the boot console, in the spirit of
|
||||
[nix-output-monitor](https://github.com/maralorn/nix-output-monitor). It
|
||||
replaces the scrolling kernel and systemd lines with the units still pending
|
||||
and, in the room the tree leaves, a timeline of the slowest ones that ran.
|
||||
|
||||
I started bootvine out of frustration with the boot screen of most Linux
|
||||
distributions: a wall of log lines scrolling past too fast to read, which never
|
||||
gave me any idea of what was going on.
|
||||
|
||||
<img src="https://codeberg.org/wvhulle/bootvine/raw/branch/recordings/boot.gif" width="691" alt="A boot through the initrd into stage 2, with one failed unit">
|
||||
|
||||
It also follows shutdowns, answers passphrase prompts such as a
|
||||
[LUKS](https://gitlab.com/cryptsetup/cryptsetup) unlock in place, and shows why
|
||||
a unit failed with its last journal lines. The
|
||||
[guide](https://codeberg.org/wvhulle/bootvine/src/branch/main/docs/guide.md)
|
||||
walks through each part of the screen.
|
||||
|
||||
## Requirements
|
||||
|
||||
- systemd ≥ 246 as PID 1
|
||||
- [libdbus](https://www.freedesktop.org/wiki/Software/dbus/) and libsystemd
|
||||
- a virtual terminal
|
||||
- a systemd initrd, to show the boot from the initrd as well as stage 2
|
||||
|
||||
See [Install](https://codeberg.org/wvhulle/bootvine/src/branch/main/docs/install.md)
|
||||
for each distribution.
|
||||
|
||||
## Try it without installing
|
||||
|
||||
With [Nix](https://nixos.org/download/), boot a sample [NixOS](https://nixos.org) machine with slow and
|
||||
failing units in a [QEMU](https://www.qemu.org) window, without touching your
|
||||
system's boot:
|
||||
|
||||
```sh
|
||||
nix run git+https://codeberg.org/wvhulle/bootvine#sample-vm-slow-services
|
||||
```
|
||||
|
||||
It logs in as root; `poweroff` shows the shutdown. The
|
||||
[guide](https://codeberg.org/wvhulle/bootvine/src/branch/main/docs/guide.md#trying-it)
|
||||
lists the other sample machines and the scripted demos that play in a terminal.
|
||||
|
||||
## Documentation
|
||||
|
||||
- [Guide](https://codeberg.org/wvhulle/bootvine/src/branch/main/docs/guide.md)
|
||||
to the screen: the tree, the timeline, failures, shutdown and passphrase
|
||||
prompts.
|
||||
- [Install](https://codeberg.org/wvhulle/bootvine/src/branch/main/docs/install.md)
|
||||
on NixOS, Ubuntu and other distributions.
|
||||
- [Configuration](https://codeberg.org/wvhulle/bootvine/src/branch/main/docs/configuration.md)
|
||||
of colours, timing and the console.
|
||||
- [Architecture](https://codeberg.org/wvhulle/bootvine/src/branch/main/docs/architecture.md):
|
||||
how bootvine follows the boot and takes the console.
|
||||
- [Development](https://codeberg.org/wvhulle/bootvine/src/branch/main/docs/development.md)
|
||||
and the [code style](https://codeberg.org/wvhulle/bootvine/src/branch/main/docs/style.md).
|
||||
|
||||
## License
|
||||
|
||||
[GPL-3.0-or-later](https://codeberg.org/wvhulle/bootvine/src/branch/main/LICENSE).
|
||||
@@ -1,69 +0,0 @@
|
||||
[package]
|
||||
categories = ["command-line-utilities", "os::linux-apis"]
|
||||
description = "Boot and shutdown progress for systemd on the console, with each job nested under the units waiting on it"
|
||||
edition = "2024"
|
||||
include = ["/src", "/system-files", "/LICENSE"]
|
||||
keywords = ["systemd", "boot", "initrd", "tui", "console"]
|
||||
license = "GPL-3.0-or-later"
|
||||
name = "bootvine"
|
||||
readme = "../README.md"
|
||||
repository = "https://codeberg.org/wvhulle/bootvine"
|
||||
rust-version = "1.91"
|
||||
version = "0.1.2"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.6.7", default-features = false, features = [
|
||||
"std",
|
||||
"derive",
|
||||
"help",
|
||||
"usage",
|
||||
"error-context",
|
||||
] }
|
||||
crossterm = "0.29.0"
|
||||
dbus = "0.9.12"
|
||||
futures = { version = "0.3.34", default-features = false, features = [
|
||||
"std",
|
||||
"async-await",
|
||||
] }
|
||||
heck = "0.5.0"
|
||||
jiff = { version = "0.2.38", default-features = false, features = [
|
||||
"serde",
|
||||
"std",
|
||||
] }
|
||||
petgraph = { version = "0.8.3", default-features = false, features = [
|
||||
"std",
|
||||
"graphmap",
|
||||
] }
|
||||
ratatui = { version = "0.30.2", features = [
|
||||
"serde",
|
||||
"unstable-rendered-line-info",
|
||||
] }
|
||||
rustix = { version = "1.1.5", features = [
|
||||
"event",
|
||||
"fs",
|
||||
"process",
|
||||
"stdio",
|
||||
"system",
|
||||
"termios",
|
||||
"time",
|
||||
] }
|
||||
ser_nix = "0.2.4"
|
||||
serde = { version = "1.0.229", features = ["derive"] }
|
||||
serde_plain = "1.0.2"
|
||||
systemd = { version = "0.10.1", default-features = false, features = [
|
||||
"journal",
|
||||
] }
|
||||
thiserror = "2.0.12"
|
||||
tokio = { version = "1.54.0", default-features = false, features = [
|
||||
"rt",
|
||||
"time",
|
||||
"net",
|
||||
"signal",
|
||||
] }
|
||||
toml = { version = "1.1.8", features = ["preserve_order"] }
|
||||
unicode-truncate = "2.0.1"
|
||||
unicode-width = "0.2.2"
|
||||
zeroize = "1.9.1"
|
||||
@@ -1 +0,0 @@
|
||||
../LICENSE
|
||||
@@ -1,166 +0,0 @@
|
||||
mod boot_change;
|
||||
pub mod boot_origin;
|
||||
mod job_ingestion;
|
||||
mod reached_milestones;
|
||||
mod unit_facts;
|
||||
mod waiting_tree;
|
||||
|
||||
use std::{collections::HashMap, time::Duration};
|
||||
|
||||
pub use self::{
|
||||
boot_change::BootChange,
|
||||
reached_milestones::MilestoneRow,
|
||||
unit_facts::{ActiveState, Activity, JobKind, JobResult, UnitFacts, UnitKind, UnitTimeouts},
|
||||
waiting_tree::{RowStatus, TreeNode, TreeRow, flatten_forest},
|
||||
};
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum Phase {
|
||||
Initrd,
|
||||
Host,
|
||||
User,
|
||||
Shutdown,
|
||||
}
|
||||
|
||||
impl Phase {
|
||||
#[must_use]
|
||||
pub fn label(self) -> &'static str {
|
||||
match self {
|
||||
Self::Initrd => "Initrd",
|
||||
Self::Host => "Stage 2",
|
||||
Self::User => "User",
|
||||
Self::Shutdown => "Shutdown",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
struct PendingJob {
|
||||
id: u32,
|
||||
queued_at: Duration,
|
||||
kind: JobKind,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum FailureKind {
|
||||
Broke,
|
||||
TimedOut,
|
||||
DependencyFailed,
|
||||
}
|
||||
|
||||
impl FailureKind {
|
||||
#[must_use]
|
||||
pub fn has_own_cause(self) -> bool {
|
||||
self != Self::DependencyFailed
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct FailureCause {
|
||||
pub reason: String,
|
||||
pub log_lines: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub enum FailureExplanation {
|
||||
Unexplained,
|
||||
Explained(FailureCause),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct FailedUnit {
|
||||
pub unit: String,
|
||||
pub label: String,
|
||||
pub kind: FailureKind,
|
||||
pub explanation: FailureExplanation,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
enum Outcome {
|
||||
Succeeded { at: Duration },
|
||||
Failed(FailureKind),
|
||||
Abandoned,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
enum Progress {
|
||||
Untouched,
|
||||
Pending(PendingJob),
|
||||
Finished(Outcome),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
struct UnitRecord {
|
||||
facts: UnitFacts,
|
||||
activity: Activity,
|
||||
progress: Progress,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
pub struct Tally {
|
||||
pub done: usize,
|
||||
pub running: usize,
|
||||
pub waiting: usize,
|
||||
pub failed: usize,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct FinishedRun {
|
||||
pub label: String,
|
||||
pub started_at: Duration,
|
||||
pub finished_at: Duration,
|
||||
pub failed: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct FinishedStage {
|
||||
pub label: &'static str,
|
||||
pub finished_units: usize,
|
||||
pub failed_units: usize,
|
||||
pub started_at: Duration,
|
||||
pub reached_at: Duration,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub enum Root {
|
||||
Unresolved,
|
||||
Awaiting(String),
|
||||
Queued(String),
|
||||
}
|
||||
|
||||
impl Root {
|
||||
#[must_use]
|
||||
pub fn unit(&self) -> Option<&str> {
|
||||
match self {
|
||||
Self::Unresolved => None,
|
||||
Self::Awaiting(unit) | Self::Queued(unit) => Some(unit),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct BootState {
|
||||
pub phase: Phase,
|
||||
pub origin: Duration,
|
||||
pub root: Root,
|
||||
pub failed: Vec<FailedUnit>,
|
||||
pub finished_stages: Vec<FinishedStage>,
|
||||
pub finished_runs: Vec<FinishedRun>,
|
||||
pub handoff_unit: Option<String>,
|
||||
pub manager_exited_at: Option<Duration>,
|
||||
pub milestone_targets: Vec<String>,
|
||||
boot_finished: bool,
|
||||
units: HashMap<String, UnitRecord>,
|
||||
jobs: HashMap<u32, String>,
|
||||
}
|
||||
|
||||
const HOST_MILESTONES: [&str; 4] = [
|
||||
"sysinit.target",
|
||||
"basic.target",
|
||||
"multi-user.target",
|
||||
"graphical.target",
|
||||
];
|
||||
|
||||
const SHUTDOWN_MILESTONES: [&str; 3] = ["shutdown.target", "umount.target", "final.target"];
|
||||
|
||||
pub const HANDOFF_UNIT: &str = "display-manager.service";
|
||||
@@ -1,115 +0,0 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use super::{Activity, BootState, FailureCause, JobKind, JobResult, UnitFacts};
|
||||
|
||||
pub enum BootChange {
|
||||
TrackUnit {
|
||||
facts: UnitFacts,
|
||||
activity: Activity,
|
||||
},
|
||||
UpdateActivity {
|
||||
unit: String,
|
||||
activity: Activity,
|
||||
},
|
||||
QueueJob {
|
||||
id: u32,
|
||||
unit: String,
|
||||
kind: JobKind,
|
||||
at: Duration,
|
||||
},
|
||||
FinishJob {
|
||||
id: u32,
|
||||
result: JobResult,
|
||||
at: Duration,
|
||||
},
|
||||
ExplainFailure {
|
||||
unit: String,
|
||||
cause: FailureCause,
|
||||
},
|
||||
SetRoot(String),
|
||||
SetHandoff(String),
|
||||
SetOrigin(Duration),
|
||||
SwitchRoot {
|
||||
at: Duration,
|
||||
},
|
||||
ForgetJobs,
|
||||
ManagerExited {
|
||||
at: Duration,
|
||||
},
|
||||
BootFinished,
|
||||
}
|
||||
|
||||
impl BootState {
|
||||
pub fn apply(&mut self, change: BootChange) {
|
||||
match change {
|
||||
BootChange::TrackUnit { facts, activity } => self.track_unit(facts, activity),
|
||||
BootChange::UpdateActivity { unit, activity } => self.update_activity(&unit, activity),
|
||||
BootChange::QueueJob { id, unit, kind, at } => self.queue_job(id, &unit, kind, at),
|
||||
BootChange::FinishJob { id, result, at } => self.finish_job(id, result, at),
|
||||
BootChange::ExplainFailure { unit, cause } => self.explain_failure(&unit, cause),
|
||||
BootChange::SetRoot(root) => self.set_root(root),
|
||||
BootChange::SetHandoff(unit) => {
|
||||
if let Some(handoff) = &mut self.handoff_unit {
|
||||
*handoff = unit;
|
||||
}
|
||||
}
|
||||
BootChange::SetOrigin(origin) => self.origin = origin,
|
||||
BootChange::SwitchRoot { at } => self.switch_root(at),
|
||||
BootChange::ForgetJobs => self.forget_jobs(),
|
||||
BootChange::ManagerExited { at } => self.manager_exited_at = Some(at),
|
||||
BootChange::BootFinished => self.boot_finished = true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{
|
||||
boot_model::Phase,
|
||||
boot_test_fixtures::{MS, facts, waiting_rows},
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn applied_changes_match_the_direct_calls() {
|
||||
let mut applied = BootState::new(Phase::Host);
|
||||
[
|
||||
BootChange::SetOrigin(100 * MS),
|
||||
BootChange::TrackUnit {
|
||||
facts: facts("web.service", &[]),
|
||||
activity: Activity::default(),
|
||||
},
|
||||
BootChange::SetRoot("web.service".to_owned()),
|
||||
BootChange::QueueJob {
|
||||
id: 1,
|
||||
unit: "web.service".to_owned(),
|
||||
kind: JobKind::BringsUp,
|
||||
at: 200 * MS,
|
||||
},
|
||||
BootChange::FinishJob {
|
||||
id: 1,
|
||||
result: JobResult::Done,
|
||||
at: 900 * MS,
|
||||
},
|
||||
]
|
||||
.into_iter()
|
||||
.for_each(|change| applied.apply(change));
|
||||
let mut called = BootState::new(Phase::Host);
|
||||
called.origin = 100 * MS;
|
||||
called.track_unit(facts("web.service", &[]), Activity::default());
|
||||
called.set_root("web.service".to_owned());
|
||||
called.queue_job(1, "web.service", JobKind::BringsUp, 200 * MS);
|
||||
called.finish_job(1, JobResult::Done, 900 * MS);
|
||||
assert_eq!(applied.tally(), called.tally());
|
||||
assert_eq!(applied.is_complete(), called.is_complete());
|
||||
assert_eq!(waiting_rows(&applied), waiting_rows(&called));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn boot_finished_change_marks_the_boot_complete() {
|
||||
let mut state = BootState::new(Phase::Host);
|
||||
assert!(!state.is_complete());
|
||||
state.apply(BootChange::BootFinished);
|
||||
assert!(state.is_complete());
|
||||
}
|
||||
}
|
||||
@@ -1,169 +0,0 @@
|
||||
use std::{
|
||||
fs::{read_dir, read_link, read_to_string},
|
||||
iter::once,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
use rustix::system::uname;
|
||||
|
||||
const KERNEL_COMMAND_LINE: &str = "/proc/cmdline";
|
||||
const SYSTEM_PROFILES: &str = "/nix/var/nix/profiles";
|
||||
const OS_RELEASES: [&str; 2] = ["/etc/os-release", "/usr/lib/os-release"];
|
||||
const NIXOS_SYSTEM: &str = "nixos-system-";
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq)]
|
||||
pub struct BootOrigin {
|
||||
pub host: String,
|
||||
pub system: Option<String>,
|
||||
pub generation: Option<String>,
|
||||
pub kernel: String,
|
||||
}
|
||||
|
||||
impl BootOrigin {
|
||||
#[must_use]
|
||||
pub fn read() -> Self {
|
||||
let names = uname();
|
||||
let host = names.nodename().to_string_lossy().into_owned();
|
||||
let command_line = read_to_string(KERNEL_COMMAND_LINE).unwrap_or_default();
|
||||
let system_path = init_system(&command_line);
|
||||
let system = system_path
|
||||
.and_then(|path| nixos_version(path, &host))
|
||||
.map(|version| format!("NixOS {version}"))
|
||||
.or_else(|| {
|
||||
OS_RELEASES
|
||||
.iter()
|
||||
.find_map(|path| read_to_string(path).ok())
|
||||
.and_then(|release| pretty_name(&release))
|
||||
});
|
||||
let generation =
|
||||
system_path.and_then(|path| generation_of(Path::new(path), &system_links()));
|
||||
Self {
|
||||
kernel: format!("Linux {}", names.release().to_string_lossy()),
|
||||
host,
|
||||
system,
|
||||
generation,
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn parts(&self) -> Vec<String> {
|
||||
once(self.host.clone())
|
||||
.chain(self.system.clone())
|
||||
.chain(
|
||||
self.generation
|
||||
.as_ref()
|
||||
.map(|generation| format!("generation {generation}")),
|
||||
)
|
||||
.chain(once(self.kernel.clone()))
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
fn init_system(command_line: &str) -> Option<&str> {
|
||||
command_line
|
||||
.split_whitespace()
|
||||
.find_map(|argument| argument.strip_prefix("init="))
|
||||
.and_then(|init| init.strip_suffix("/init"))
|
||||
}
|
||||
|
||||
fn nixos_version<'a>(system_path: &'a str, host: &str) -> Option<&'a str> {
|
||||
let (_, name) = system_path.rsplit_once('/')?;
|
||||
let (_, rest) = name.split_once('-')?;
|
||||
rest.strip_prefix(NIXOS_SYSTEM)?
|
||||
.strip_prefix(host)?
|
||||
.strip_prefix('-')
|
||||
}
|
||||
|
||||
fn pretty_name(os_release: &str) -> Option<String> {
|
||||
os_release
|
||||
.lines()
|
||||
.find_map(|line| line.strip_prefix("PRETTY_NAME="))
|
||||
.map(|value| value.trim_matches('"').to_owned())
|
||||
}
|
||||
|
||||
struct SystemLink {
|
||||
generation: String,
|
||||
target: PathBuf,
|
||||
}
|
||||
|
||||
fn system_links() -> Vec<SystemLink> {
|
||||
read_dir(SYSTEM_PROFILES)
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.filter_map(Result::ok)
|
||||
.filter_map(|entry| {
|
||||
let name = entry.file_name().into_string().ok()?;
|
||||
let generation = name.strip_prefix("system-")?.strip_suffix("-link")?;
|
||||
Some(SystemLink {
|
||||
generation: generation.to_owned(),
|
||||
target: read_link(entry.path()).ok()?,
|
||||
})
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn generation_of(system_path: &Path, links: &[SystemLink]) -> Option<String> {
|
||||
links
|
||||
.iter()
|
||||
.find(|link| link.target == system_path)
|
||||
.map(|link| link.generation.clone())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
const COMMAND_LINE: &str = "initrd=\\EFI\\nixos\\x-initrd.efi \
|
||||
init=/nix/store/\
|
||||
av1146s7ayap8zgrpindi641v1fmdxsf-nixos-system-ryzen-26.11.\
|
||||
20261007.39ad350/init panic=10 root=fstab";
|
||||
|
||||
#[test]
|
||||
fn the_nixos_version_comes_from_the_init_on_the_command_line() {
|
||||
let system = init_system(COMMAND_LINE).expect("init system");
|
||||
assert_eq!(
|
||||
nixos_version(system, "ryzen"),
|
||||
Some("26.11.20261007.39ad350")
|
||||
);
|
||||
assert_eq!(nixos_version(system, "other-host"), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_generation_is_the_profile_link_to_the_booted_system() {
|
||||
let system = init_system(COMMAND_LINE).expect("init system");
|
||||
let links = [
|
||||
SystemLink {
|
||||
generation: "2770".to_owned(),
|
||||
target: "/nix/store/x43q-nixos-system-ryzen-26.11".into(),
|
||||
},
|
||||
SystemLink {
|
||||
generation: "2771".to_owned(),
|
||||
target: system.into(),
|
||||
},
|
||||
];
|
||||
assert_eq!(
|
||||
generation_of(Path::new(system), &links),
|
||||
Some("2771".to_owned())
|
||||
);
|
||||
assert_eq!(generation_of(Path::new(system), &links[..1]), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn other_distributions_use_their_pretty_name() {
|
||||
assert_eq!(
|
||||
pretty_name("NAME=Arch\nPRETTY_NAME=\"Arch Linux\"\n"),
|
||||
Some("Arch Linux".to_owned())
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unknown_parts_are_left_out() {
|
||||
let origin = BootOrigin {
|
||||
host: "ryzen".to_owned(),
|
||||
system: Some("NixOS 26.11".to_owned()),
|
||||
generation: None,
|
||||
kernel: "Linux 7.2.9".to_owned(),
|
||||
};
|
||||
assert_eq!(origin.parts(), ["ryzen", "NixOS 26.11", "Linux 7.2.9"]);
|
||||
}
|
||||
}
|
||||
@@ -1,565 +0,0 @@
|
||||
use std::{collections::HashMap, time::Duration};
|
||||
|
||||
use super::{
|
||||
ActiveState, Activity, BootState, FailedUnit, FailureCause, FailureExplanation, FailureKind,
|
||||
FinishedRun, FinishedStage, HANDOFF_UNIT, HOST_MILESTONES, JobKind, JobResult, Outcome,
|
||||
PendingJob, Phase, Progress, Root, SHUTDOWN_MILESTONES, Tally, UnitFacts, UnitKind, UnitRecord,
|
||||
unit_facts::display_label,
|
||||
};
|
||||
|
||||
impl UnitRecord {
|
||||
fn transition_started(&self, kind: JobKind) -> Option<Duration> {
|
||||
match kind {
|
||||
JobKind::TakesDown => self.activity.active_exit,
|
||||
JobKind::BringsUp | JobKind::Unknown => self.activity.inactive_exit,
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn running_since(&self) -> Option<Duration> {
|
||||
let Progress::Pending(job) = self.progress else {
|
||||
return None;
|
||||
};
|
||||
let transitioning = matches!(
|
||||
self.activity.state,
|
||||
Some(ActiveState::Activating | ActiveState::Deactivating | ActiveState::Reloading)
|
||||
);
|
||||
transitioning.then(|| self.transition_started(job.kind).unwrap_or(job.queued_at))
|
||||
}
|
||||
|
||||
pub(super) fn deadline(&self) -> Option<Duration> {
|
||||
let Progress::Pending(job) = self.progress else {
|
||||
return None;
|
||||
};
|
||||
let since = self.running_since()?;
|
||||
let timeouts = self.facts.timeouts;
|
||||
let transition = match job.kind {
|
||||
JobKind::TakesDown => timeouts.stop,
|
||||
JobKind::BringsUp | JobKind::Unknown => timeouts.start,
|
||||
};
|
||||
[
|
||||
transition.map(|limit| since + limit),
|
||||
timeouts.job_running.map(|limit| since + limit),
|
||||
timeouts.job.map(|limit| job.queued_at + limit),
|
||||
]
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.min()
|
||||
}
|
||||
|
||||
fn is_finished(&self) -> bool {
|
||||
matches!(self.progress, Progress::Finished(_))
|
||||
}
|
||||
|
||||
pub(super) fn takes_down(&self) -> bool {
|
||||
matches!(
|
||||
self.progress,
|
||||
Progress::Pending(PendingJob {
|
||||
kind: JobKind::TakesDown,
|
||||
..
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl BootState {
|
||||
#[must_use]
|
||||
pub fn new(phase: Phase) -> Self {
|
||||
let (milestone_targets, handoff_unit) = match phase {
|
||||
Phase::Initrd | Phase::Host => (
|
||||
HOST_MILESTONES.iter().map(ToString::to_string).collect(),
|
||||
Some(HANDOFF_UNIT.to_owned()),
|
||||
),
|
||||
Phase::Shutdown => (
|
||||
SHUTDOWN_MILESTONES
|
||||
.iter()
|
||||
.map(ToString::to_string)
|
||||
.collect(),
|
||||
None,
|
||||
),
|
||||
Phase::User => (Vec::new(), None),
|
||||
};
|
||||
Self {
|
||||
phase,
|
||||
origin: Duration::ZERO,
|
||||
root: Root::Unresolved,
|
||||
failed: Vec::new(),
|
||||
finished_stages: Vec::new(),
|
||||
finished_runs: Vec::new(),
|
||||
handoff_unit,
|
||||
manager_exited_at: None,
|
||||
milestone_targets,
|
||||
boot_finished: false,
|
||||
units: HashMap::new(),
|
||||
jobs: HashMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn awaits_manager(&self) -> bool {
|
||||
self.root == Root::Unresolved
|
||||
}
|
||||
|
||||
pub fn set_root(&mut self, root: String) {
|
||||
if self.phase == Phase::User && !self.milestone_targets.contains(&root) {
|
||||
self.milestone_targets.push(root.clone());
|
||||
}
|
||||
if self.root.unit() != Some(&root) {
|
||||
self.root = Root::Awaiting(root);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn track_unit(&mut self, facts: UnitFacts, activity: Activity) {
|
||||
let record = self
|
||||
.units
|
||||
.entry(facts.name.clone())
|
||||
.or_insert_with(|| UnitRecord {
|
||||
facts: facts.clone(),
|
||||
activity: Activity::default(),
|
||||
progress: Progress::Untouched,
|
||||
});
|
||||
record.facts = facts;
|
||||
record.activity = record.activity.merge(activity);
|
||||
}
|
||||
|
||||
pub fn update_activity(&mut self, unit: &str, activity: Activity) {
|
||||
let Some(record) = self.units.get_mut(unit) else {
|
||||
return;
|
||||
};
|
||||
record.activity = record.activity.merge(activity);
|
||||
if activity.state == Some(ActiveState::Failed) {
|
||||
let label = display_label(&record.facts);
|
||||
self.record_failure(unit, label, FailureKind::Broke);
|
||||
}
|
||||
}
|
||||
|
||||
fn record_failure(&mut self, unit: &str, label: String, kind: FailureKind) {
|
||||
match self.failed.iter_mut().find(|failed| failed.unit == unit) {
|
||||
Some(known) if kind != FailureKind::Broke => known.kind = kind,
|
||||
Some(_) => {}
|
||||
None => self.failed.push(FailedUnit {
|
||||
unit: unit.to_owned(),
|
||||
label,
|
||||
kind,
|
||||
explanation: FailureExplanation::Unexplained,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn explain_failure(&mut self, unit: &str, cause: FailureCause) {
|
||||
if let Some(failed) = self.failed.iter_mut().find(|failed| failed.unit == unit) {
|
||||
failed.explanation = FailureExplanation::Explained(cause);
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn has_failed(&self, unit: &str) -> bool {
|
||||
self.failed.iter().any(|failed| failed.unit == unit)
|
||||
}
|
||||
|
||||
pub fn queue_job(&mut self, id: u32, unit: &str, kind: JobKind, at: Duration) {
|
||||
if self.enqueue(id, unit, kind, at)
|
||||
&& kind == JobKind::BringsUp
|
||||
&& self.root == Root::Awaiting(unit.to_owned())
|
||||
{
|
||||
self.root = Root::Queued(unit.to_owned());
|
||||
}
|
||||
}
|
||||
|
||||
fn enqueue(&mut self, id: u32, unit: &str, kind: JobKind, at: Duration) -> bool {
|
||||
if let Some(tracked) = self.jobs.get(&id) {
|
||||
return tracked == unit;
|
||||
}
|
||||
let Some(record) = self.units.get_mut(unit) else {
|
||||
return false;
|
||||
};
|
||||
record.progress = Progress::Pending(PendingJob {
|
||||
id,
|
||||
queued_at: at,
|
||||
kind,
|
||||
});
|
||||
self.jobs.insert(id, unit.to_owned());
|
||||
true
|
||||
}
|
||||
|
||||
pub fn finish_job(&mut self, id: u32, result: JobResult, at: Duration) {
|
||||
let Some(unit) = self.jobs.remove(&id) else {
|
||||
return;
|
||||
};
|
||||
let Some(label) = self
|
||||
.units
|
||||
.get(&unit)
|
||||
.map(|record| display_label(&record.facts))
|
||||
else {
|
||||
return;
|
||||
};
|
||||
let outcome = match result {
|
||||
JobResult::Done => Outcome::Succeeded { at },
|
||||
JobResult::Skipped | JobResult::Canceled => Outcome::Abandoned,
|
||||
JobResult::Failed => Outcome::Failed(FailureKind::Broke),
|
||||
JobResult::Timeout => Outcome::Failed(FailureKind::TimedOut),
|
||||
JobResult::Dependency => Outcome::Failed(FailureKind::DependencyFailed),
|
||||
};
|
||||
if let Outcome::Failed(kind) = outcome {
|
||||
self.record_failure(&unit, label.clone(), kind);
|
||||
}
|
||||
let Some(record) = self.units.get_mut(&unit) else {
|
||||
return;
|
||||
};
|
||||
let job = match record.progress {
|
||||
Progress::Pending(job) if job.id == id => job,
|
||||
_ => return,
|
||||
};
|
||||
record.progress = Progress::Finished(outcome);
|
||||
if let Some(started_at) = record
|
||||
.transition_started(job.kind)
|
||||
.filter(|started| job.kind != JobKind::Unknown && (self.origin..=at).contains(started))
|
||||
&& UnitKind::of(&record.facts.name) != UnitKind::Target
|
||||
{
|
||||
self.finished_runs.push(FinishedRun {
|
||||
label,
|
||||
started_at,
|
||||
finished_at: at,
|
||||
failed: matches!(outcome, Outcome::Failed(_)),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
pub fn switch_root(&mut self, at: Duration) {
|
||||
let finished_here = self
|
||||
.units
|
||||
.values()
|
||||
.filter(|record| record.is_finished())
|
||||
.count();
|
||||
self.finished_stages.push(FinishedStage {
|
||||
label: Phase::Initrd.label(),
|
||||
finished_units: finished_here,
|
||||
failed_units: self
|
||||
.units
|
||||
.values()
|
||||
.filter(|record| matches!(record.progress, Progress::Finished(Outcome::Failed(_))))
|
||||
.count(),
|
||||
started_at: self.origin,
|
||||
reached_at: at,
|
||||
});
|
||||
self.phase = Phase::Host;
|
||||
self.root = Root::Unresolved;
|
||||
self.units.clear();
|
||||
self.jobs.clear();
|
||||
}
|
||||
|
||||
pub fn forget_jobs(&mut self) {
|
||||
self.jobs.clear();
|
||||
self.units
|
||||
.values_mut()
|
||||
.filter(|record| matches!(record.progress, Progress::Pending(_)))
|
||||
.for_each(|record| record.progress = Progress::Untouched);
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn is_complete(&self) -> bool {
|
||||
if matches!(self.phase, Phase::Initrd | Phase::Shutdown) {
|
||||
return false;
|
||||
}
|
||||
if self.boot_finished {
|
||||
return true;
|
||||
}
|
||||
let Root::Queued(root) = &self.root else {
|
||||
return false;
|
||||
};
|
||||
self.units.get(root).is_some_and(UnitRecord::is_finished)
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn started_display_manager(&self) -> Option<&str> {
|
||||
self.handoff_unit.as_deref().filter(|unit| {
|
||||
self.units
|
||||
.get(*unit)
|
||||
.and_then(|handoff| handoff.activity.state)
|
||||
.is_some_and(|state| state != ActiveState::Inactive)
|
||||
})
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn tally(&self) -> Tally {
|
||||
let carried = Tally {
|
||||
done: self
|
||||
.finished_stages
|
||||
.iter()
|
||||
.map(|stage| stage.finished_units)
|
||||
.sum::<usize>(),
|
||||
failed: self.failed.len(),
|
||||
..Tally::default()
|
||||
};
|
||||
self.units.values().fold(carried, |mut tally, record| {
|
||||
match record.progress {
|
||||
Progress::Pending(_) if record.running_since().is_some() => tally.running += 1,
|
||||
Progress::Pending(_) => tally.waiting += 1,
|
||||
Progress::Finished(Outcome::Succeeded { .. } | Outcome::Abandoned) => {
|
||||
tally.done += 1;
|
||||
}
|
||||
Progress::Finished(Outcome::Failed(_)) | Progress::Untouched => {}
|
||||
}
|
||||
tally
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{
|
||||
boot_model::{BootChange, RowStatus, UnitTimeouts},
|
||||
boot_test_fixtures::{
|
||||
MS, activating, facts, nested_boot_sample as sample, queue_unit, queued_boot, running,
|
||||
waiting, waiting_rows,
|
||||
},
|
||||
};
|
||||
|
||||
fn failure_kinds(state: &BootState) -> Vec<(&str, FailureKind)> {
|
||||
state
|
||||
.failed
|
||||
.iter()
|
||||
.map(|failed| (failed.unit.as_str(), failed.kind))
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn job_results_keep_their_failure_kind() {
|
||||
let mut state = sample();
|
||||
state.finish_job(4, JobResult::Timeout, 2000 * MS);
|
||||
state.finish_job(3, JobResult::Dependency, 2000 * MS);
|
||||
assert_eq!(
|
||||
failure_kinds(&state),
|
||||
[
|
||||
("nm.service", FailureKind::TimedOut),
|
||||
("nm-wait.service", FailureKind::DependencyFailed),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_unit_entering_the_failed_state_counts_without_a_failed_job() {
|
||||
let mut state = sample();
|
||||
state.update_activity(
|
||||
"nm.service",
|
||||
Activity {
|
||||
state: Some(ActiveState::Failed),
|
||||
..Activity::default()
|
||||
},
|
||||
);
|
||||
assert_eq!(failure_kinds(&state), [("nm.service", FailureKind::Broke)]);
|
||||
state.finish_job(4, JobResult::Timeout, 2000 * MS);
|
||||
assert_eq!(
|
||||
failure_kinds(&state),
|
||||
[("nm.service", FailureKind::TimedOut)]
|
||||
);
|
||||
assert_eq!(state.tally().failed, 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_explanation_attaches_to_its_failed_unit() {
|
||||
let mut state = sample();
|
||||
let cause = FailureCause {
|
||||
reason: "exited with status 1".to_owned(),
|
||||
log_lines: vec!["no carrier".to_owned()],
|
||||
};
|
||||
state.explain_failure("nm.service", cause.clone());
|
||||
assert!(state.failed.is_empty());
|
||||
state.finish_job(4, JobResult::Failed, 2000 * MS);
|
||||
state.explain_failure("nm.service", cause.clone());
|
||||
assert_eq!(
|
||||
state.failed[0].explanation,
|
||||
FailureExplanation::Explained(cause)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn failures_are_listed_and_not_counted_as_done() {
|
||||
let mut state = sample();
|
||||
state.finish_job(4, JobResult::Failed, 2000 * MS);
|
||||
assert_eq!(
|
||||
state
|
||||
.failed
|
||||
.iter()
|
||||
.map(|failed| failed.label.as_str())
|
||||
.collect::<Vec<_>>(),
|
||||
["nm"]
|
||||
);
|
||||
let tally = state.tally();
|
||||
assert_eq!(tally.failed, 1);
|
||||
assert_eq!(tally.done, 0);
|
||||
assert_eq!(tally.running, 1);
|
||||
assert_eq!(tally.waiting, 5);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn boot_completes_when_the_root_job_is_gone() {
|
||||
let mut state = sample();
|
||||
assert!(!state.is_complete());
|
||||
(1..=7).for_each(|id| state.finish_job(id, JobResult::Done, 5000 * MS));
|
||||
assert!(state.is_complete());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reconnecting_keeps_the_boot_running() {
|
||||
let mut state = sample();
|
||||
state.forget_jobs();
|
||||
assert!(!state.is_complete());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reconnecting_keeps_the_finished_units() {
|
||||
let mut state = sample();
|
||||
state.finish_job(7, JobResult::Done, 2000 * MS);
|
||||
let tally = state.tally();
|
||||
let milestones = state.milestones();
|
||||
state.forget_jobs();
|
||||
assert_eq!(state.tally().done, tally.done);
|
||||
assert_eq!(state.milestones(), milestones);
|
||||
assert!(!milestones.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn boot_completes_once_the_requeued_root_job_is_gone() {
|
||||
let mut state = sample();
|
||||
state.forget_jobs();
|
||||
state.queue_job(20, "graphical.target", JobKind::BringsUp, 6000 * MS);
|
||||
assert!(!state.is_complete());
|
||||
state.finish_job(20, JobResult::Done, 7000 * MS);
|
||||
assert!(state.is_complete());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn display_manager_activation_does_not_complete_the_boot() {
|
||||
let mut state = sample();
|
||||
queue_unit(&mut state, 20, waiting(HANDOFF_UNIT, &[]), 500 * MS);
|
||||
assert_eq!(state.started_display_manager(), None);
|
||||
state.update_activity(HANDOFF_UNIT, activating(6000 * MS));
|
||||
assert!(!state.is_complete());
|
||||
assert_eq!(state.started_display_manager(), Some(HANDOFF_UNIT));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn boot_finished_hands_the_console_over() {
|
||||
let mut state = sample();
|
||||
queue_unit(&mut state, 20, waiting(HANDOFF_UNIT, &[]), 500 * MS);
|
||||
state.apply(BootChange::BootFinished);
|
||||
assert!(state.is_complete());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn boot_finished_is_ignored_in_the_initrd() {
|
||||
let mut state = BootState::new(Phase::Initrd);
|
||||
state.apply(BootChange::BootFinished);
|
||||
assert!(!state.is_complete());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn switching_root_freezes_the_initrd_summary() {
|
||||
let mut state = queued_boot(
|
||||
Phase::Initrd,
|
||||
Duration::ZERO,
|
||||
[waiting("initrd.target", &[]), waiting("sysroot.mount", &[])],
|
||||
);
|
||||
state.finish_job(2, JobResult::Done, 1000 * MS);
|
||||
state.finish_job(1, JobResult::Done, 1500 * MS);
|
||||
assert!(!state.is_complete());
|
||||
state.switch_root(2000 * MS);
|
||||
assert_eq!(state.phase, Phase::Host);
|
||||
assert_eq!(
|
||||
state.finished_stages,
|
||||
[FinishedStage {
|
||||
label: "Initrd",
|
||||
finished_units: 2,
|
||||
failed_units: 0,
|
||||
started_at: Duration::ZERO,
|
||||
reached_at: 2000 * MS,
|
||||
}]
|
||||
);
|
||||
assert_eq!(state.milestones()[0].reached_at, 2000 * MS);
|
||||
assert_eq!(state.tally().done, 2);
|
||||
assert!(waiting_rows(&state).is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stopped_units_join_the_timeline_from_when_they_began_stopping() {
|
||||
let mut state = BootState::new(Phase::Shutdown);
|
||||
state.origin = 1000 * MS;
|
||||
state.track_unit(facts("db.service", &[]), Activity::default());
|
||||
state.queue_job(1, "db.service", JobKind::TakesDown, 1000 * MS);
|
||||
state.update_activity(
|
||||
"db.service",
|
||||
Activity {
|
||||
state: Some(ActiveState::Deactivating),
|
||||
active_exit: Some(1200 * MS),
|
||||
..Activity::default()
|
||||
},
|
||||
);
|
||||
assert_eq!(
|
||||
waiting_rows(&state)[0].status,
|
||||
RowStatus::Running {
|
||||
queued_at: 1000 * MS,
|
||||
since: 1200 * MS,
|
||||
deadline: None,
|
||||
}
|
||||
);
|
||||
state.finish_job(1, JobResult::Done, 1700 * MS);
|
||||
assert_eq!(
|
||||
state.finished_runs,
|
||||
[FinishedRun {
|
||||
label: "db".to_owned(),
|
||||
started_at: 1200 * MS,
|
||||
finished_at: 1700 * MS,
|
||||
failed: false,
|
||||
}]
|
||||
);
|
||||
}
|
||||
|
||||
fn deadline_of(state: &BootState) -> Option<Duration> {
|
||||
match waiting_rows(state)[0].status {
|
||||
RowStatus::Running { deadline, .. } => deadline,
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_earliest_timer_sets_the_deadline() {
|
||||
let state = queued_boot(
|
||||
Phase::Host,
|
||||
1000 * MS,
|
||||
[
|
||||
running("web.service", &[], 3000 * MS).timing_out(UnitTimeouts {
|
||||
start: Some(90_000 * MS),
|
||||
job: Some(10_000 * MS),
|
||||
..UnitTimeouts::default()
|
||||
}),
|
||||
],
|
||||
);
|
||||
assert_eq!(deadline_of(&state), Some(11_000 * MS));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stopping_units_run_against_the_stop_timeout() {
|
||||
let mut state = queued_boot(
|
||||
Phase::Shutdown,
|
||||
Duration::ZERO,
|
||||
[waiting("db.service", &[])
|
||||
.stopping()
|
||||
.timing_out(UnitTimeouts {
|
||||
start: Some(5000 * MS),
|
||||
stop: Some(90_000 * MS),
|
||||
..UnitTimeouts::default()
|
||||
})],
|
||||
);
|
||||
assert_eq!(deadline_of(&state), None);
|
||||
state.update_activity(
|
||||
"db.service",
|
||||
Activity {
|
||||
state: Some(ActiveState::Deactivating),
|
||||
active_exit: Some(2000 * MS),
|
||||
..Activity::default()
|
||||
},
|
||||
);
|
||||
assert_eq!(deadline_of(&state), Some(92_000 * MS));
|
||||
}
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use super::{ActiveState, BootState, Outcome, Progress};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct MilestoneRow {
|
||||
pub label: String,
|
||||
pub finished_units: usize,
|
||||
pub started_at: Duration,
|
||||
pub reached_at: Duration,
|
||||
}
|
||||
|
||||
struct MilestoneCursor {
|
||||
previous: Duration,
|
||||
consumed: usize,
|
||||
}
|
||||
|
||||
impl BootState {
|
||||
fn milestone_reached_at(&self, target: &str) -> Option<Duration> {
|
||||
let record = self.units.get(target)?;
|
||||
match record.progress {
|
||||
Progress::Finished(Outcome::Succeeded { at }) => Some(at),
|
||||
Progress::Untouched => record.activity.active_enter.filter(|entered| {
|
||||
record.activity.state == Some(ActiveState::Active) && *entered >= self.origin
|
||||
}),
|
||||
Progress::Pending(_) | Progress::Finished(Outcome::Failed(_) | Outcome::Abandoned) => {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn milestones(&self) -> Vec<MilestoneRow> {
|
||||
let mut succeeded: Vec<Duration> = self
|
||||
.units
|
||||
.values()
|
||||
.filter_map(|record| match record.progress {
|
||||
Progress::Finished(Outcome::Succeeded { at }) => Some(at),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
succeeded.sort_unstable();
|
||||
let start = MilestoneCursor {
|
||||
previous: self
|
||||
.finished_stages
|
||||
.last()
|
||||
.map_or(self.origin, |stage| stage.reached_at),
|
||||
consumed: 0,
|
||||
};
|
||||
let reached_rows = self
|
||||
.milestone_targets
|
||||
.iter()
|
||||
.scan(start, |cursor, target| {
|
||||
Some(self.milestone_reached_at(target).map(|reached_at| {
|
||||
let upto = succeeded.partition_point(|at| *at <= reached_at);
|
||||
let row = MilestoneRow {
|
||||
label: target.clone(),
|
||||
finished_units: upto.saturating_sub(cursor.consumed),
|
||||
started_at: cursor.previous.min(reached_at),
|
||||
reached_at,
|
||||
};
|
||||
cursor.consumed = cursor.consumed.max(upto);
|
||||
cursor.previous = reached_at;
|
||||
row
|
||||
}))
|
||||
})
|
||||
.flatten();
|
||||
self.finished_stages
|
||||
.iter()
|
||||
.map(|stage| MilestoneRow {
|
||||
label: stage.label.to_owned(),
|
||||
finished_units: stage.finished_units,
|
||||
started_at: stage.started_at,
|
||||
reached_at: stage.reached_at,
|
||||
})
|
||||
.chain(reached_rows)
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{
|
||||
boot_model::{Activity, JobResult, Phase},
|
||||
boot_test_fixtures::{MS, nested_boot_sample, queued_boot, waiting, waiting_rows},
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn finished_jobs_leave_the_tree_and_count_toward_their_milestone() {
|
||||
let mut state = nested_boot_sample();
|
||||
state.finish_job(6, JobResult::Done, 3500 * MS);
|
||||
state.finish_job(7, JobResult::Done, 4000 * MS);
|
||||
state.update_activity(
|
||||
"basic.target",
|
||||
Activity {
|
||||
state: Some(ActiveState::Active),
|
||||
inactive_exit: None,
|
||||
active_enter: Some(4000 * MS),
|
||||
active_exit: None,
|
||||
},
|
||||
);
|
||||
assert!(
|
||||
waiting_rows(&state)
|
||||
.iter()
|
||||
.all(|row| row.label != "containerd" && row.label != "basic.target")
|
||||
);
|
||||
let milestones = state.milestones();
|
||||
assert_eq!(milestones.len(), 1);
|
||||
assert_eq!(milestones[0].label, "basic.target");
|
||||
assert_eq!(milestones[0].finished_units, 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shutdown_counts_toward_its_own_milestones_and_never_completes() {
|
||||
let mut state = queued_boot(
|
||||
Phase::Shutdown,
|
||||
Duration::ZERO,
|
||||
[
|
||||
waiting("poweroff.target", &[]),
|
||||
waiting("shutdown.target", &[]),
|
||||
waiting("db.service", &[]).stopping(),
|
||||
],
|
||||
);
|
||||
state.finish_job(3, JobResult::Done, 500 * MS);
|
||||
state.finish_job(2, JobResult::Done, 600 * MS);
|
||||
state.finish_job(1, JobResult::Done, 700 * MS);
|
||||
let milestones = state.milestones();
|
||||
assert_eq!(milestones[0].label, "shutdown.target");
|
||||
assert_eq!(milestones[0].finished_units, 2);
|
||||
assert!(!state.is_complete());
|
||||
}
|
||||
}
|
||||
@@ -1,198 +0,0 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum ActiveState {
|
||||
Activating,
|
||||
Active,
|
||||
Deactivating,
|
||||
Reloading,
|
||||
Failed,
|
||||
#[serde(other)]
|
||||
Inactive,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum JobResult {
|
||||
Done,
|
||||
Skipped,
|
||||
Canceled,
|
||||
Timeout,
|
||||
Dependency,
|
||||
#[serde(other)]
|
||||
Failed,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
pub struct UnitTimeouts {
|
||||
pub start: Option<Duration>,
|
||||
pub stop: Option<Duration>,
|
||||
pub job: Option<Duration>,
|
||||
pub job_running: Option<Duration>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct UnitFacts {
|
||||
pub name: String,
|
||||
pub description: Option<String>,
|
||||
pub after: Vec<String>,
|
||||
pub before: Vec<String>,
|
||||
pub timeouts: UnitTimeouts,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
pub struct Activity {
|
||||
pub state: Option<ActiveState>,
|
||||
pub inactive_exit: Option<Duration>,
|
||||
pub active_enter: Option<Duration>,
|
||||
pub active_exit: Option<Duration>,
|
||||
}
|
||||
|
||||
impl Activity {
|
||||
pub(super) fn merge(self, newer: Self) -> Self {
|
||||
Self {
|
||||
state: newer.state.or(self.state),
|
||||
inactive_exit: newer.inactive_exit.or(self.inactive_exit),
|
||||
active_enter: newer.active_enter.or(self.active_enter),
|
||||
active_exit: newer.active_exit.or(self.active_exit),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize)]
|
||||
pub enum JobKind {
|
||||
#[serde(rename = "stop")]
|
||||
TakesDown,
|
||||
#[serde(skip)]
|
||||
Unknown,
|
||||
#[serde(other)]
|
||||
BringsUp,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum UnitKind {
|
||||
Service,
|
||||
Target,
|
||||
Socket,
|
||||
Mount,
|
||||
Automount,
|
||||
Device,
|
||||
Swap,
|
||||
Path,
|
||||
Timer,
|
||||
Slice,
|
||||
Scope,
|
||||
#[serde(other)]
|
||||
Other,
|
||||
}
|
||||
|
||||
impl UnitKind {
|
||||
#[must_use]
|
||||
pub fn of(name: &str) -> Self {
|
||||
name.rsplit_once('.')
|
||||
.and_then(|(_, suffix)| serde_plain::from_str(suffix).ok())
|
||||
.unwrap_or(Self::Other)
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn tag(self) -> Option<&'static str> {
|
||||
match self {
|
||||
Self::Service | Self::Target | Self::Other => None,
|
||||
Self::Socket => Some("Socket"),
|
||||
Self::Mount => Some("Mount"),
|
||||
Self::Automount => Some("Automount"),
|
||||
Self::Device => Some("Device"),
|
||||
Self::Swap => Some("Swap"),
|
||||
Self::Path => Some("Path"),
|
||||
Self::Timer => Some("Timer"),
|
||||
Self::Slice => Some("Slice"),
|
||||
Self::Scope => Some("Scope"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn description_label(facts: &UnitFacts) -> Option<&String> {
|
||||
facts.description.as_ref().filter(|_| {
|
||||
matches!(
|
||||
UnitKind::of(&facts.name),
|
||||
UnitKind::Device | UnitKind::Mount | UnitKind::Swap | UnitKind::Automount
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) fn display_label(facts: &UnitFacts) -> String {
|
||||
if let Some(description) = description_label(facts) {
|
||||
return description.clone();
|
||||
}
|
||||
match UnitKind::of(&facts.name) {
|
||||
UnitKind::Target | UnitKind::Other => facts.name.clone(),
|
||||
_ => facts
|
||||
.name
|
||||
.rsplit_once('.')
|
||||
.map_or_else(|| facts.name.clone(), |(stem, _)| stem.to_owned()),
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn summary(facts: &UnitFacts) -> Option<String> {
|
||||
let repeats_the_name = facts.description.as_deref().is_some_and(|description| {
|
||||
description == facts.name || description.eq_ignore_ascii_case(&display_label(facts))
|
||||
});
|
||||
if description_label(facts).is_some() || repeats_the_name {
|
||||
return None;
|
||||
}
|
||||
facts.description.clone()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use serde_plain::from_str;
|
||||
|
||||
use super::*;
|
||||
use crate::boot_test_fixtures::{facts, waiting};
|
||||
|
||||
#[test]
|
||||
fn unknown_systemd_strings_fall_back_instead_of_failing() {
|
||||
assert_eq!(
|
||||
from_str("deactivating").ok(),
|
||||
Some(ActiveState::Deactivating)
|
||||
);
|
||||
assert_eq!(from_str("maintenance").ok(), Some(ActiveState::Inactive));
|
||||
assert_eq!(from_str("dependency").ok(), Some(JobResult::Dependency));
|
||||
assert_eq!(from_str("frozen").ok(), Some(JobResult::Failed));
|
||||
assert_eq!(from_str("stop").ok(), Some(JobKind::TakesDown));
|
||||
assert_eq!(from_str("restart").ok(), Some(JobKind::BringsUp));
|
||||
assert_eq!(UnitKind::of("dev-sda.swap"), UnitKind::Swap);
|
||||
assert_eq!(UnitKind::of("init.scope.d"), UnitKind::Other);
|
||||
assert_eq!(UnitKind::of("no-suffix"), UnitKind::Other);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn kinds_with_a_tag_drop_their_suffix() {
|
||||
let socket = facts("docker.socket", &[]);
|
||||
assert_eq!(UnitKind::of(&socket.name), UnitKind::Socket);
|
||||
assert_eq!(UnitKind::Socket.tag(), Some("Socket"));
|
||||
assert_eq!(display_label(&socket), "docker");
|
||||
assert_eq!(display_label(&facts("sshd.service", &[])), "sshd");
|
||||
assert_eq!(display_label(&facts("basic.target", &[])), "basic.target");
|
||||
assert_eq!(UnitKind::Target.tag(), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn descriptions_that_repeat_the_label_are_dropped() {
|
||||
let described = |name: &str, description: &str| {
|
||||
summary(&waiting(name, &[]).described(description).facts)
|
||||
};
|
||||
assert_eq!(
|
||||
described("multi-user.target", "Multi-User System"),
|
||||
Some("Multi-User System".to_owned())
|
||||
);
|
||||
assert_eq!(described("greetd.service", "greetd.service"), None);
|
||||
assert_eq!(described("greetd.service", "Greetd"), None);
|
||||
assert_eq!(described("dev-sda.device", "Samsung SSD"), None);
|
||||
assert_eq!(described("demo.service", ""), None);
|
||||
}
|
||||
}
|
||||
@@ -1,382 +0,0 @@
|
||||
use std::{collections::HashSet, time::Duration};
|
||||
|
||||
use petgraph::{
|
||||
Direction::Incoming,
|
||||
graphmap::DiGraphMap,
|
||||
visit::{Dfs, Walker},
|
||||
};
|
||||
|
||||
use super::{
|
||||
BootState, FailureKind, Outcome, Phase, Progress, UnitKind, UnitRecord,
|
||||
unit_facts::{display_label, summary},
|
||||
};
|
||||
|
||||
type WaitingGraph<'a> = DiGraphMap<&'a str, ()>;
|
||||
|
||||
struct WaitingEdge<'a> {
|
||||
waiter: &'a str,
|
||||
dependency: &'a str,
|
||||
}
|
||||
|
||||
struct ReachableSibling<'a> {
|
||||
unit: &'a str,
|
||||
reaches: HashSet<&'a str>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum RowStatus {
|
||||
Waiting,
|
||||
Running {
|
||||
queued_at: Duration,
|
||||
since: Duration,
|
||||
deadline: Option<Duration>,
|
||||
},
|
||||
Failed(FailureKind),
|
||||
Done,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct TreeRow {
|
||||
pub depth: usize,
|
||||
pub label: String,
|
||||
pub description: Option<String>,
|
||||
pub kind: UnitKind,
|
||||
pub status: RowStatus,
|
||||
pub chain: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct TreeNode {
|
||||
pub row: TreeRow,
|
||||
pub children: Vec<TreeNode>,
|
||||
}
|
||||
|
||||
impl TreeNode {
|
||||
fn flatten_into(self, depth: usize, rows: &mut Vec<TreeRow>) {
|
||||
rows.push(TreeRow { depth, ..self.row });
|
||||
self.children
|
||||
.into_iter()
|
||||
.for_each(|child| child.flatten_into(depth + 1, rows));
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn flatten_forest(forest: Vec<TreeNode>) -> Vec<TreeRow> {
|
||||
let mut rows = Vec::new();
|
||||
forest
|
||||
.into_iter()
|
||||
.for_each(|root| root.flatten_into(0, &mut rows));
|
||||
rows
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
||||
enum SiblingRank {
|
||||
RunningSince(Duration),
|
||||
Failed,
|
||||
Waiting,
|
||||
}
|
||||
|
||||
impl UnitRecord {
|
||||
fn row_status(&self) -> RowStatus {
|
||||
match self.progress {
|
||||
Progress::Pending(job) => {
|
||||
self.running_since()
|
||||
.map_or(RowStatus::Waiting, |since| RowStatus::Running {
|
||||
queued_at: job.queued_at,
|
||||
since,
|
||||
deadline: self.deadline(),
|
||||
})
|
||||
}
|
||||
Progress::Finished(Outcome::Failed(kind)) => RowStatus::Failed(kind),
|
||||
Progress::Finished(_) | Progress::Untouched => RowStatus::Done,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl BootState {
|
||||
#[must_use]
|
||||
pub fn waiting_forest(&self, finished_since: Duration) -> Vec<TreeNode> {
|
||||
let mut graph = WaitingGraph::new();
|
||||
self.units
|
||||
.iter()
|
||||
.filter(|(name, record)| match record.progress {
|
||||
Progress::Pending(_) | Progress::Finished(Outcome::Failed(_)) => true,
|
||||
Progress::Finished(Outcome::Succeeded { at }) => {
|
||||
at >= finished_since || self.is_milestone(name)
|
||||
}
|
||||
Progress::Finished(Outcome::Abandoned) => self.is_milestone(name),
|
||||
Progress::Untouched => false,
|
||||
})
|
||||
.for_each(|(name, _)| {
|
||||
graph.add_node(name.as_str());
|
||||
});
|
||||
let edges: Vec<WaitingEdge> = graph
|
||||
.nodes()
|
||||
.flat_map(|waiter| {
|
||||
self.waits_for(waiter, &graph)
|
||||
.into_iter()
|
||||
.map(move |dependency| WaitingEdge { waiter, dependency })
|
||||
})
|
||||
.collect();
|
||||
graph.extend(edges.into_iter().map(|edge| (edge.waiter, edge.dependency)));
|
||||
let root = self.root.unit().filter(|root| graph.contains_node(root));
|
||||
let stages: Vec<&str> = self
|
||||
.milestone_targets
|
||||
.iter()
|
||||
.map(String::as_str)
|
||||
.filter(|target| graph.contains_node(target))
|
||||
.chain(root.filter(|root| !self.is_milestone(root)))
|
||||
.collect();
|
||||
let mut unblocked: Vec<&str> = graph
|
||||
.nodes()
|
||||
.filter(|name| {
|
||||
graph.neighbors_directed(name, Incoming).next().is_none() && !stages.contains(name)
|
||||
})
|
||||
.collect();
|
||||
self.sort_siblings(&mut unblocked);
|
||||
let mut leftovers: Vec<&str> = graph.nodes().collect();
|
||||
self.sort_siblings(&mut leftovers);
|
||||
if self.phase == Phase::User {
|
||||
unblocked.clear();
|
||||
leftovers.clear();
|
||||
}
|
||||
let mut visited = HashSet::new();
|
||||
let mut forest = Vec::new();
|
||||
stages
|
||||
.iter()
|
||||
.copied()
|
||||
.chain(unblocked)
|
||||
.chain(leftovers)
|
||||
.for_each(|top| {
|
||||
if visited.contains(top) {
|
||||
return;
|
||||
}
|
||||
let stage = self.grow(top, &graph, &mut visited);
|
||||
if stage.row.status != RowStatus::Done || !stage.children.is_empty() {
|
||||
forest.push(stage);
|
||||
}
|
||||
});
|
||||
forest
|
||||
}
|
||||
|
||||
fn grow<'a>(
|
||||
&'a self,
|
||||
unit: &'a str,
|
||||
graph: &WaitingGraph<'a>,
|
||||
visited: &mut HashSet<&'a str>,
|
||||
) -> TreeNode {
|
||||
visited.insert(unit);
|
||||
let record = &self.units[unit];
|
||||
let row = TreeRow {
|
||||
depth: 0,
|
||||
label: display_label(&record.facts),
|
||||
description: summary(&record.facts),
|
||||
kind: UnitKind::of(&record.facts.name),
|
||||
status: record.row_status(),
|
||||
chain: Vec::new(),
|
||||
};
|
||||
let siblings: Vec<ReachableSibling> = graph
|
||||
.neighbors(unit)
|
||||
.filter(|dependency| !visited.contains(dependency) && !self.is_milestone(dependency))
|
||||
.map(|sibling| ReachableSibling {
|
||||
unit: sibling,
|
||||
reaches: Dfs::new(graph, sibling).iter(graph).collect(),
|
||||
})
|
||||
.collect();
|
||||
let mut children: Vec<&str> = siblings
|
||||
.iter()
|
||||
.filter(|child| {
|
||||
!siblings.iter().any(|sibling| {
|
||||
sibling.unit != child.unit
|
||||
&& sibling.reaches.contains(child.unit)
|
||||
&& !child.reaches.contains(sibling.unit)
|
||||
})
|
||||
})
|
||||
.map(|child| child.unit)
|
||||
.collect();
|
||||
self.sort_siblings(&mut children);
|
||||
visited.extend(children.iter().copied());
|
||||
TreeNode {
|
||||
row,
|
||||
children: children
|
||||
.into_iter()
|
||||
.map(|child| {
|
||||
visited.remove(child);
|
||||
self.grow(child, graph, visited)
|
||||
})
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
|
||||
fn is_milestone(&self, unit: &str) -> bool {
|
||||
self.milestone_targets.iter().any(|target| target == unit)
|
||||
}
|
||||
|
||||
fn waits_for<'a>(&'a self, waiter: &str, graph: &WaitingGraph) -> Vec<&'a str> {
|
||||
let Some(record) = self.units.get(waiter) else {
|
||||
return Vec::new();
|
||||
};
|
||||
let pending_job = |dependency: &&'a str| graph.contains_node(dependency);
|
||||
let taking_down = |dependency: &&'a str| self.units[*dependency].takes_down();
|
||||
let after = record.facts.after.iter().map(String::as_str);
|
||||
let before = record.facts.before.iter().map(String::as_str);
|
||||
if record.takes_down() {
|
||||
before.filter(pending_job).filter(taking_down).collect()
|
||||
} else {
|
||||
after
|
||||
.filter(pending_job)
|
||||
.chain(before.filter(pending_job).filter(taking_down))
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
fn sort_siblings(&self, names: &mut [&str]) {
|
||||
let rank = |name: &str| {
|
||||
let record = &self.units[name];
|
||||
match record.progress {
|
||||
Progress::Pending(_) => record
|
||||
.running_since()
|
||||
.map_or(SiblingRank::Waiting, SiblingRank::RunningSince),
|
||||
Progress::Finished(Outcome::Succeeded { at }) => {
|
||||
SiblingRank::RunningSince(record.activity.inactive_exit.unwrap_or(at))
|
||||
}
|
||||
Progress::Finished(Outcome::Failed(_)) => SiblingRank::Failed,
|
||||
Progress::Finished(Outcome::Abandoned) | Progress::Untouched => {
|
||||
SiblingRank::Waiting
|
||||
}
|
||||
}
|
||||
};
|
||||
names.sort_by(|left, right| rank(left).cmp(&rank(right)).then_with(|| left.cmp(right)));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::boot_test_fixtures::{
|
||||
nested_boot_sample, queued_boot, tree_outline, waiting, waiting_rows,
|
||||
};
|
||||
|
||||
fn outline(state: &BootState) -> Vec<String> {
|
||||
tree_outline(&waiting_rows(state))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pending_units_nest_under_what_waits_on_them() {
|
||||
assert_eq!(
|
||||
outline(&nested_boot_sample()),
|
||||
[
|
||||
"basic.target",
|
||||
"multi-user.target",
|
||||
" docker",
|
||||
" containerd",
|
||||
" nm-wait",
|
||||
" nm",
|
||||
"graphical.target",
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_unit_sits_in_the_earliest_stage_that_waits_on_it() {
|
||||
let state = queued_boot(
|
||||
Phase::Host,
|
||||
Duration::ZERO,
|
||||
[
|
||||
waiting(
|
||||
"multi-user.target",
|
||||
&["basic.target", "dbus.service", "web.service"],
|
||||
),
|
||||
waiting("basic.target", &["dbus.service"]),
|
||||
waiting("dbus.service", &[]),
|
||||
waiting("web.service", &[]),
|
||||
],
|
||||
);
|
||||
assert_eq!(
|
||||
outline(&state),
|
||||
["basic.target", " dbus", "multi-user.target", " web"]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn devices_show_their_description() {
|
||||
let state = queued_boot(
|
||||
Phase::Host,
|
||||
Duration::ZERO,
|
||||
[waiting("dev-nvme1n1.device", &[]).described("Lexar SSD NM790 2TB")],
|
||||
);
|
||||
assert_eq!(waiting_rows(&state)[0].label, "Lexar SSD NM790 2TB");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn units_nest_under_the_deepest_pending_waiter() {
|
||||
let state = queued_boot(
|
||||
Phase::Host,
|
||||
Duration::ZERO,
|
||||
[
|
||||
waiting(
|
||||
"demo.target",
|
||||
&["report.service", "web.service", "db.service"],
|
||||
),
|
||||
waiting("report.service", &["web.service"]),
|
||||
waiting("web.service", &["db.service"]),
|
||||
waiting("db.service", &[]),
|
||||
],
|
||||
);
|
||||
assert_eq!(
|
||||
outline(&state),
|
||||
["demo.target", " report", " web", " db"]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stopping_units_wait_on_what_was_ordered_after_them() {
|
||||
let state = queued_boot(
|
||||
Phase::Shutdown,
|
||||
Duration::ZERO,
|
||||
[
|
||||
waiting("poweroff.target", &["shutdown.target"]),
|
||||
waiting("shutdown.target", &[]).ordered_before(&["poweroff.target"]),
|
||||
waiting("network.target", &[])
|
||||
.ordered_before(&["web.service"])
|
||||
.stopping(),
|
||||
waiting("web.service", &["network.target"]).stopping(),
|
||||
],
|
||||
);
|
||||
assert_eq!(
|
||||
outline(&state),
|
||||
[
|
||||
"shutdown.target",
|
||||
"poweroff.target",
|
||||
"network.target",
|
||||
" web",
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn starting_units_wait_on_stops_in_either_direction() {
|
||||
let state = queued_boot(
|
||||
Phase::Shutdown,
|
||||
Duration::ZERO,
|
||||
[
|
||||
waiting("shutdown.target", &[]).ordered_before(&["db.service"]),
|
||||
waiting("db.service", &["shutdown.target"]).stopping(),
|
||||
],
|
||||
);
|
||||
assert_eq!(outline(&state), ["shutdown.target", " db"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ordering_cycles_do_not_repeat_units() {
|
||||
let state = queued_boot(
|
||||
Phase::Host,
|
||||
Duration::ZERO,
|
||||
[
|
||||
waiting("a.service", &["b.service"]),
|
||||
waiting("b.service", &["a.service"]),
|
||||
],
|
||||
);
|
||||
assert_eq!(waiting_rows(&state).len(), 2);
|
||||
}
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
use std::{iter::once, time::Duration};
|
||||
|
||||
use crate::boot_model::{
|
||||
ActiveState, Activity, BootState, JobKind, Phase, TreeRow, UnitFacts, UnitTimeouts,
|
||||
flatten_forest,
|
||||
};
|
||||
|
||||
pub const MS: Duration = Duration::from_millis(1);
|
||||
|
||||
pub struct QueuedUnit {
|
||||
pub facts: UnitFacts,
|
||||
pub activity: Activity,
|
||||
pub kind: JobKind,
|
||||
}
|
||||
|
||||
pub fn facts(name: &str, after: &[&str]) -> UnitFacts {
|
||||
UnitFacts {
|
||||
name: name.to_owned(),
|
||||
description: None,
|
||||
after: after.iter().map(ToString::to_string).collect(),
|
||||
before: Vec::new(),
|
||||
timeouts: UnitTimeouts::default(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn activating(since: Duration) -> Activity {
|
||||
Activity {
|
||||
state: Some(ActiveState::Activating),
|
||||
inactive_exit: Some(since),
|
||||
..Activity::default()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn waiting(name: &str, after: &[&str]) -> QueuedUnit {
|
||||
QueuedUnit {
|
||||
facts: facts(name, after),
|
||||
activity: Activity::default(),
|
||||
kind: JobKind::BringsUp,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn running(name: &str, after: &[&str], since: Duration) -> QueuedUnit {
|
||||
QueuedUnit {
|
||||
activity: activating(since),
|
||||
..waiting(name, after)
|
||||
}
|
||||
}
|
||||
|
||||
impl QueuedUnit {
|
||||
pub fn stopping(self) -> Self {
|
||||
Self {
|
||||
kind: JobKind::TakesDown,
|
||||
..self
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ordered_before(mut self, before: &[&str]) -> Self {
|
||||
self.facts.before = before.iter().map(ToString::to_string).collect();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn timing_out(mut self, timeouts: UnitTimeouts) -> Self {
|
||||
self.facts.timeouts = timeouts;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn described(mut self, description: &str) -> Self {
|
||||
self.facts.description = (!description.is_empty()).then(|| description.to_owned());
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
pub fn queued_boot(
|
||||
phase: Phase,
|
||||
queued_at: Duration,
|
||||
units: impl IntoIterator<Item = QueuedUnit>,
|
||||
) -> BootState {
|
||||
let mut state = BootState::new(phase);
|
||||
units.into_iter().zip(1..).for_each(|(unit, id)| {
|
||||
if id == 1 {
|
||||
state.set_root(unit.facts.name.clone());
|
||||
}
|
||||
queue_unit(&mut state, id, unit, queued_at);
|
||||
});
|
||||
state
|
||||
}
|
||||
|
||||
pub fn nested_boot_sample() -> BootState {
|
||||
queued_boot(
|
||||
Phase::Host,
|
||||
500 * MS,
|
||||
[
|
||||
waiting("graphical.target", &["multi-user.target"]),
|
||||
waiting(
|
||||
"multi-user.target",
|
||||
&["docker.service", "nm-wait.service", "basic.target"],
|
||||
),
|
||||
waiting("nm-wait.service", &["nm.service"]),
|
||||
running("nm.service", &[], 1000 * MS),
|
||||
running("docker.service", &["containerd.service"], 3000 * MS),
|
||||
waiting("containerd.service", &[]),
|
||||
waiting("basic.target", &[]),
|
||||
],
|
||||
)
|
||||
}
|
||||
|
||||
pub fn queue_unit(state: &mut BootState, id: u32, unit: QueuedUnit, queued_at: Duration) {
|
||||
let name = unit.facts.name.clone();
|
||||
state.track_unit(unit.facts, unit.activity);
|
||||
state.queue_job(id, &name, unit.kind, queued_at);
|
||||
}
|
||||
|
||||
pub fn waiting_rows(state: &BootState) -> Vec<TreeRow> {
|
||||
flatten_forest(state.waiting_forest(Duration::MAX))
|
||||
}
|
||||
|
||||
pub fn tree_outline(rows: &[TreeRow]) -> Vec<String> {
|
||||
rows.iter()
|
||||
.map(|row| {
|
||||
let chain = once(row.label.as_str())
|
||||
.chain(row.chain.iter().map(String::as_str))
|
||||
.collect::<Vec<_>>()
|
||||
.join(" > ");
|
||||
format!("{}{chain}", " ".repeat(row.depth))
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
@@ -1,325 +0,0 @@
|
||||
mod failure_panel;
|
||||
#[cfg(test)]
|
||||
mod frame_cost_bench;
|
||||
#[cfg(test)]
|
||||
mod panel_render_tests;
|
||||
mod run_timeline;
|
||||
mod screen_chrome;
|
||||
#[cfg(test)]
|
||||
mod screen_render_fixtures;
|
||||
mod screen_spacing;
|
||||
mod stage_summary;
|
||||
mod tree_height_fitting;
|
||||
#[cfg(test)]
|
||||
mod tree_render_tests;
|
||||
mod unit_tree;
|
||||
|
||||
use std::time::Duration;
|
||||
|
||||
use jiff::fmt::friendly::{Designator, FractionalUnit, Spacing, SpanPrinter};
|
||||
use ratatui::{
|
||||
buffer::Buffer,
|
||||
layout::{
|
||||
Constraint::{Fill, Length},
|
||||
Layout, Rect,
|
||||
},
|
||||
style::Color,
|
||||
text::Line,
|
||||
widgets::{Block, Borders, Widget},
|
||||
};
|
||||
use unicode_truncate::UnicodeTruncateStr;
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
|
||||
pub use self::screen_chrome::PasswordPrompt;
|
||||
use self::{
|
||||
failure_panel::FailurePanel,
|
||||
run_timeline::{RunningRun, Timeline, timeline_fits},
|
||||
screen_chrome::{Footer, Header, PasswordPopup},
|
||||
screen_spacing::{PANEL_MINIMUM_HEIGHT, RULED_ROW_HEIGHT, TEXT_ROW_HEIGHT},
|
||||
stage_summary::Stages,
|
||||
tree_height_fitting::rows_within_height,
|
||||
unit_tree::UnitTree,
|
||||
};
|
||||
use crate::{
|
||||
boot_model::{
|
||||
BootState, MilestoneRow, RowStatus, TreeNode, TreeRow, UnitKind, boot_origin::BootOrigin,
|
||||
flatten_forest,
|
||||
},
|
||||
screen_settings::{color_scheme::Colors, config_file::Timing, font_glyphs::Glyphs},
|
||||
};
|
||||
|
||||
const MIN_TIMELINE_HEIGHT: u16 = RULED_ROW_HEIGHT + PANEL_MINIMUM_HEIGHT;
|
||||
const BRANCH: &str = "├─ ";
|
||||
const LAST_BRANCH: &str = "└─ ";
|
||||
const PASSING_TRUNK: &str = "│ ";
|
||||
const ENDED_TRUNK: &str = " ";
|
||||
|
||||
const ELAPSED: SpanPrinter = SpanPrinter::new()
|
||||
.designator(Designator::Compact)
|
||||
.spacing(Spacing::None)
|
||||
.fractional(Some(FractionalUnit::Second))
|
||||
.precision(Some(1));
|
||||
|
||||
const RUNNING_ELAPSED: SpanPrinter = ELAPSED.precision(Some(2));
|
||||
|
||||
const WHOLE_UNITS: SpanPrinter = SpanPrinter::new()
|
||||
.designator(Designator::Compact)
|
||||
.spacing(Spacing::None);
|
||||
|
||||
pub struct BootView<'a> {
|
||||
pub state: &'a BootState,
|
||||
pub projection: &'a BootProjection,
|
||||
pub colors: &'a Colors,
|
||||
pub timing: &'a Timing,
|
||||
pub glyphs: &'a Glyphs,
|
||||
pub now: Duration,
|
||||
pub origin: &'a BootOrigin,
|
||||
pub password_prompt: Option<PasswordPrompt<'a>>,
|
||||
}
|
||||
|
||||
impl BootView<'_> {
|
||||
fn failure_panel(&self) -> FailurePanel<'_> {
|
||||
FailurePanel {
|
||||
newest_first: self
|
||||
.state
|
||||
.failed
|
||||
.iter()
|
||||
.rev()
|
||||
.filter(|failed| failed.kind.has_own_cause())
|
||||
.collect(),
|
||||
colors: &self.colors.failures,
|
||||
glyphs: self.glyphs,
|
||||
}
|
||||
}
|
||||
|
||||
fn timeline<'a>(&'a self, rows: &'a [TreeRow]) -> Timeline<'a> {
|
||||
let mut running: Vec<RunningRun> = rows
|
||||
.iter()
|
||||
.filter(|row| row.kind != UnitKind::Target)
|
||||
.filter_map(|row| match row.status {
|
||||
RowStatus::Running {
|
||||
queued_at, since, ..
|
||||
} => Some(RunningRun {
|
||||
label: &row.label,
|
||||
queued_at,
|
||||
since,
|
||||
}),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
running.sort_by_key(|run| run.since);
|
||||
Timeline {
|
||||
origin: self.state.origin,
|
||||
now: self.now,
|
||||
root_switches: self
|
||||
.state
|
||||
.finished_stages
|
||||
.iter()
|
||||
.map(|stage| stage.reached_at)
|
||||
.collect(),
|
||||
milestones: &self.projection.milestones,
|
||||
finished: self
|
||||
.state
|
||||
.finished_runs
|
||||
.iter()
|
||||
.filter(|run| {
|
||||
run.finished_at.saturating_sub(run.started_at)
|
||||
>= self.timing.hide_runs_shorter_than
|
||||
})
|
||||
.collect(),
|
||||
running,
|
||||
colors: &self.colors.timeline,
|
||||
glyphs: self.glyphs,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Widget for BootView<'_> {
|
||||
fn render(self, area: Rect, buf: &mut Buffer) {
|
||||
let forest = &self.projection.forest;
|
||||
let all_rows = flatten_forest(forest.clone());
|
||||
let pending_count = all_rows.len();
|
||||
let header = Header {
|
||||
origin: self.origin,
|
||||
total: (!self.state.finished_stages.is_empty())
|
||||
.then(|| self.now.saturating_sub(self.state.origin)),
|
||||
colors: &self.colors.header,
|
||||
};
|
||||
let stages = Stages {
|
||||
state: self.state,
|
||||
now: self.now,
|
||||
colors: &self.colors.stages,
|
||||
glyphs: self.glyphs,
|
||||
};
|
||||
let timeline = self.timeline(&all_rows);
|
||||
let failure_panel = self.failure_panel();
|
||||
let footer = Footer {
|
||||
tally: self.state.tally(),
|
||||
colors: &self.colors.footer,
|
||||
glyphs: self.glyphs,
|
||||
};
|
||||
let [header_area, stage_area, body_area, footer_area] = area.layout(&Layout::vertical([
|
||||
Length(TEXT_ROW_HEIGHT),
|
||||
Length(stages.height()),
|
||||
Fill(1),
|
||||
Length(RULED_ROW_HEIGHT),
|
||||
]));
|
||||
let heights = Heights::share(
|
||||
body_area.height,
|
||||
UnitTree::height_of(pending_count, 0),
|
||||
failure_panel.height(),
|
||||
if timeline_fits(body_area) {
|
||||
timeline.height()
|
||||
} else {
|
||||
0
|
||||
},
|
||||
);
|
||||
let budget = usize::from(heights.tree.saturating_sub(TEXT_ROW_HEIGHT));
|
||||
let rows = rows_within_height(forest, budget);
|
||||
let tree = UnitTree {
|
||||
phase: stages.current_phase(),
|
||||
rows: &rows,
|
||||
hidden: pending_count - shown_units(&rows),
|
||||
now: self.now,
|
||||
hide_runs_shorter_than: self.timing.hide_runs_shorter_than,
|
||||
colors: &self.colors.tree,
|
||||
glyphs: self.glyphs,
|
||||
};
|
||||
let tree_height = tree.height().min(heights.tree);
|
||||
|
||||
let [tree_area, _, failure_area, timeline_area] = body_area.layout(&Layout::vertical([
|
||||
Length(tree_height),
|
||||
Fill(1),
|
||||
Length(heights.failures),
|
||||
Length(heights.timeline),
|
||||
]));
|
||||
|
||||
header.render(header_area, buf);
|
||||
stages.render(stage_area, buf);
|
||||
tree.render(tree_area, buf);
|
||||
if heights.failures > 0 {
|
||||
failure_panel.render(failure_area, buf);
|
||||
}
|
||||
if heights.timeline > 0 {
|
||||
timeline.render(timeline_area, buf);
|
||||
}
|
||||
footer.render(footer_area, buf);
|
||||
if let Some(asking) = &self.password_prompt {
|
||||
PasswordPopup {
|
||||
asking,
|
||||
colors: &self.colors.password,
|
||||
glyphs: self.glyphs,
|
||||
}
|
||||
.render(area, buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct Heights {
|
||||
tree: u16,
|
||||
failures: u16,
|
||||
timeline: u16,
|
||||
}
|
||||
|
||||
impl Heights {
|
||||
fn share(free: u16, tree_need: u16, failures_need: u16, timeline_need: u16) -> Self {
|
||||
let reserved = PANEL_MINIMUM_HEIGHT
|
||||
.min(failures_need)
|
||||
.min(free.saturating_sub(PANEL_MINIMUM_HEIGHT));
|
||||
let failures = failures_need
|
||||
.min(free.saturating_sub(tree_need))
|
||||
.max(reserved);
|
||||
let failures = if failures >= RULED_ROW_HEIGHT {
|
||||
failures
|
||||
} else {
|
||||
0
|
||||
};
|
||||
let leftover = free.saturating_sub(tree_need).saturating_sub(failures);
|
||||
let timeline = if leftover >= MIN_TIMELINE_HEIGHT {
|
||||
timeline_need.min(leftover)
|
||||
} else {
|
||||
0
|
||||
};
|
||||
Self {
|
||||
tree: free - failures - timeline,
|
||||
failures,
|
||||
timeline,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct BootProjection {
|
||||
pub forest: Vec<TreeNode>,
|
||||
pub milestones: Vec<MilestoneRow>,
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn project_boot(state: &BootState, timing: &Timing, now: Duration) -> BootProjection {
|
||||
BootProjection {
|
||||
forest: state.waiting_forest(now.saturating_sub(timing.keep_finished_units_for)),
|
||||
milestones: state.milestones(),
|
||||
}
|
||||
}
|
||||
|
||||
fn rule(color: Color, left: Line<'static>) -> Block<'static> {
|
||||
Block::new()
|
||||
.borders(Borders::TOP)
|
||||
.border_style(color)
|
||||
.title(left)
|
||||
}
|
||||
|
||||
fn shown_units(rows: &[TreeRow]) -> usize {
|
||||
rows.iter().map(|row| 1 + row.chain.len()).sum()
|
||||
}
|
||||
|
||||
fn fit_width(text: &str, room: usize, ellipsis: &str) -> String {
|
||||
if text.width() <= room {
|
||||
return text.to_owned();
|
||||
}
|
||||
let (kept, _) = text.unicode_truncate(room.saturating_sub(ellipsis.width()));
|
||||
format!("{kept}{ellipsis}")
|
||||
}
|
||||
|
||||
fn unit_count(count: usize) -> String {
|
||||
match count {
|
||||
1 => "1 unit".to_owned(),
|
||||
count => format!("{count} units"),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn the_tree_takes_the_room_and_the_timeline_only_what_is_left() {
|
||||
let heights = Heights::share(30, 40, 0, 50);
|
||||
assert_eq!((heights.tree, heights.timeline), (30, 0));
|
||||
let heights = Heights::share(30, 12, 0, 50);
|
||||
assert_eq!((heights.tree, heights.timeline), (12, 18));
|
||||
let heights = Heights::share(30, 25, 0, 50);
|
||||
assert_eq!((heights.tree, heights.timeline), (30, 0));
|
||||
let heights = Heights::share(30, 12, 0, 8);
|
||||
assert_eq!((heights.tree, heights.timeline), (22, 8));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn failures_come_before_the_timeline_and_keep_a_few_rows_beside_a_full_tree() {
|
||||
let heights = Heights::share(30, 12, 6, 50);
|
||||
assert_eq!(
|
||||
(heights.tree, heights.failures, heights.timeline),
|
||||
(12, 6, 12)
|
||||
);
|
||||
let heights = Heights::share(30, 40, 9, 50);
|
||||
assert_eq!(
|
||||
(heights.tree, heights.failures, heights.timeline),
|
||||
(26, 4, 0)
|
||||
);
|
||||
let heights = Heights::share(5, 40, 9, 50);
|
||||
assert_eq!(
|
||||
(heights.tree, heights.failures, heights.timeline),
|
||||
(5, 0, 0)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,226 +0,0 @@
|
||||
use std::iter::once;
|
||||
|
||||
use ratatui::{
|
||||
buffer::Buffer,
|
||||
layout::Rect,
|
||||
style::Stylize,
|
||||
text::{Line, Span},
|
||||
widgets::{Paragraph, Widget},
|
||||
};
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
|
||||
use super::{
|
||||
fit_width, rule,
|
||||
screen_spacing::{TEXT_GAP, TEXT_INDENT, TEXT_ROW_HEIGHT},
|
||||
};
|
||||
use crate::{
|
||||
boot_model::{FailedUnit, FailureExplanation},
|
||||
screen_settings::{color_scheme::FailureColors, font_glyphs::Glyphs},
|
||||
};
|
||||
|
||||
pub struct FailurePanel<'a> {
|
||||
pub newest_first: Vec<&'a FailedUnit>,
|
||||
pub colors: &'a FailureColors,
|
||||
pub glyphs: &'a Glyphs,
|
||||
}
|
||||
|
||||
fn log_lines(failed: &FailedUnit) -> &[String] {
|
||||
match &failed.explanation {
|
||||
FailureExplanation::Explained(cause) => &cause.log_lines,
|
||||
FailureExplanation::Unexplained => &[],
|
||||
}
|
||||
}
|
||||
|
||||
impl FailurePanel<'_> {
|
||||
pub fn height(&self) -> u16 {
|
||||
if self.newest_first.is_empty() {
|
||||
return 0;
|
||||
}
|
||||
let rows: usize = self
|
||||
.newest_first
|
||||
.iter()
|
||||
.map(|failed| 1 + log_lines(failed).len())
|
||||
.sum();
|
||||
TEXT_ROW_HEIGHT.saturating_add(u16::try_from(rows).unwrap_or(u16::MAX))
|
||||
}
|
||||
|
||||
fn headline(&self, failed: &FailedUnit, width: usize) -> Line<'static> {
|
||||
let marker = format!("{} ", self.glyphs.failed);
|
||||
let label_room = width.saturating_sub(marker.width());
|
||||
let label = fit_width(&failed.label, label_room, self.glyphs.ellipsis);
|
||||
let reason_room = label_room.saturating_sub(label.width() + TEXT_GAP.width());
|
||||
let reason = match &failed.explanation {
|
||||
FailureExplanation::Explained(cause) if reason_room > 0 => {
|
||||
fit_width(&cause.reason, reason_room, self.glyphs.ellipsis)
|
||||
}
|
||||
_ => String::new(),
|
||||
};
|
||||
let reason_span =
|
||||
(!reason.is_empty()).then(|| format!("{TEXT_GAP}{reason}").fg(self.colors.reason));
|
||||
Line::from(
|
||||
[
|
||||
marker.fg(self.colors.unit),
|
||||
label.fg(self.colors.unit).bold(),
|
||||
]
|
||||
.into_iter()
|
||||
.chain(reason_span)
|
||||
.collect::<Vec<Span>>(),
|
||||
)
|
||||
}
|
||||
|
||||
fn block(&self, failed: &FailedUnit, width: usize) -> Vec<Line<'static>> {
|
||||
let log_room = width.saturating_sub(TEXT_INDENT.width());
|
||||
once(self.headline(failed, width))
|
||||
.chain(log_lines(failed).iter().map(|line| {
|
||||
format!(
|
||||
"{TEXT_INDENT}{}",
|
||||
fit_width(line, log_room, self.glyphs.ellipsis)
|
||||
)
|
||||
.fg(self.colors.log)
|
||||
.into()
|
||||
}))
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn lines_within(&self, rows: usize, width: usize) -> Vec<Line<'static>> {
|
||||
if self.newest_first.len() > rows {
|
||||
return self.headlines_with_overflow(rows, width);
|
||||
}
|
||||
let mut spare_rows = rows - self.newest_first.len();
|
||||
self.newest_first
|
||||
.iter()
|
||||
.flat_map(|failed| {
|
||||
let mut block = self.block(failed, width);
|
||||
let kept_log_lines = (block.len() - 1).min(spare_rows);
|
||||
spare_rows -= kept_log_lines;
|
||||
block.truncate(1 + kept_log_lines);
|
||||
block
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn headlines_with_overflow(&self, rows: usize, width: usize) -> Vec<Line<'static>> {
|
||||
let Some(headline_rows) = rows.checked_sub(1) else {
|
||||
return Vec::new();
|
||||
};
|
||||
let hidden = self.newest_first.len() - headline_rows;
|
||||
self.newest_first
|
||||
.iter()
|
||||
.take(headline_rows)
|
||||
.map(|failed| self.headline(failed, width))
|
||||
.chain(once(
|
||||
Line::from(format!("{} {hidden} more failed", self.glyphs.ellipsis))
|
||||
.fg(self.colors.overflow),
|
||||
))
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
impl Widget for FailurePanel<'_> {
|
||||
fn render(self, area: Rect, buf: &mut Buffer) {
|
||||
let block = rule(
|
||||
self.colors.rule,
|
||||
Line::from(" Failures ".fg(self.colors.title)),
|
||||
);
|
||||
let inner = block.inner(area);
|
||||
block.render(area, buf);
|
||||
Paragraph::new(self.lines_within(usize::from(inner.height), usize::from(inner.width)))
|
||||
.render(inner, buf);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::boot_model::{FailureCause, FailureKind};
|
||||
|
||||
fn explained(label: &str, log_lines: &[&str]) -> FailedUnit {
|
||||
FailedUnit {
|
||||
unit: format!("{label}.service"),
|
||||
label: label.to_owned(),
|
||||
kind: FailureKind::Broke,
|
||||
explanation: FailureExplanation::Explained(FailureCause {
|
||||
reason: "exited with status 1".to_owned(),
|
||||
log_lines: log_lines.iter().map(ToString::to_string).collect(),
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
fn panel_text(failures: &[FailedUnit], rows: usize) -> Vec<String> {
|
||||
FailurePanel {
|
||||
newest_first: failures.iter().collect(),
|
||||
colors: &FailureColors::default(),
|
||||
glyphs: &Glyphs::fitting(|_| true),
|
||||
}
|
||||
.lines_within(rows, 60)
|
||||
.iter()
|
||||
.map(ToString::to_string)
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_newest_failure_keeps_its_lines_and_older_ones_shrink_to_a_headline() {
|
||||
let failures = [
|
||||
explained("web", &["bind: address in use", "giving up"]),
|
||||
explained("db", &["disk full"]),
|
||||
explained("cache", &["no memory"]),
|
||||
];
|
||||
assert_eq!(
|
||||
panel_text(&failures, 5),
|
||||
[
|
||||
"× web exited with status 1",
|
||||
" bind: address in use",
|
||||
" giving up",
|
||||
"× db exited with status 1",
|
||||
"× cache exited with status 1",
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn room_left_by_the_newest_failure_goes_to_older_ones() {
|
||||
let failures = [
|
||||
explained("web", &["giving up"]),
|
||||
explained("db", &["disk full", "read-only file system"]),
|
||||
explained("cache", &["no memory"]),
|
||||
];
|
||||
assert_eq!(
|
||||
panel_text(&failures, 6),
|
||||
[
|
||||
"× web exited with status 1",
|
||||
" giving up",
|
||||
"× db exited with status 1",
|
||||
" disk full",
|
||||
" read-only file system",
|
||||
"× cache exited with status 1",
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn failures_beyond_the_room_are_counted() {
|
||||
let failures = [
|
||||
explained("web", &["giving up"]),
|
||||
explained("db", &[]),
|
||||
explained("cache", &[]),
|
||||
explained("queue", &[]),
|
||||
];
|
||||
assert_eq!(
|
||||
panel_text(&failures, 3),
|
||||
[
|
||||
"× web exited with status 1",
|
||||
"× db exited with status 1",
|
||||
"… 2 more failed"
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_unexplained_failure_shows_only_its_name() {
|
||||
let failures = [FailedUnit {
|
||||
explanation: FailureExplanation::Unexplained,
|
||||
..explained("web", &[])
|
||||
}];
|
||||
assert_eq!(panel_text(&failures, 4), ["× web"]);
|
||||
}
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
use std::{
|
||||
hint::black_box,
|
||||
iter::once,
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
|
||||
use ratatui::{Terminal, backend::TestBackend};
|
||||
|
||||
use super::{BootProjection, BootView, project_boot, screen_render_fixtures::ryzen_origin};
|
||||
use crate::{
|
||||
boot_model::{BootState, JobResult, Phase, flatten_forest},
|
||||
boot_test_fixtures::{MS, QueuedUnit, queued_boot, running, waiting},
|
||||
screen_settings::{color_scheme::Colors, config_file::Timing, font_glyphs::Glyphs},
|
||||
};
|
||||
|
||||
const SERVICE_COUNT: u32 = 200;
|
||||
const CHAIN_LENGTH: u32 = 5;
|
||||
const FINISHED_SERVICES: u32 = 40;
|
||||
const DRAW_COUNT: u32 = 200;
|
||||
const DRAW_SPACING: Duration = Duration::from_millis(16);
|
||||
|
||||
fn service_name(index: u32) -> String {
|
||||
format!("unit{index:03}.service")
|
||||
}
|
||||
|
||||
fn crowded_service(index: u32, names: &[String]) -> QueuedUnit {
|
||||
let earlier = (!index.is_multiple_of(CHAIN_LENGTH)).then(|| names[index as usize - 1].as_str());
|
||||
let after: Vec<&str> = earlier.into_iter().collect();
|
||||
let name = &names[index as usize];
|
||||
if index.is_multiple_of(3) {
|
||||
running(name, &after, MS * index)
|
||||
} else {
|
||||
waiting(name, &after)
|
||||
}
|
||||
}
|
||||
|
||||
fn crowded_boot() -> BootState {
|
||||
let names: Vec<String> = (0..SERVICE_COUNT).map(service_name).collect();
|
||||
let services: Vec<&str> = names.iter().map(String::as_str).collect();
|
||||
let mut state = queued_boot(
|
||||
Phase::Host,
|
||||
Duration::ZERO,
|
||||
once(waiting("crowded.target", &services))
|
||||
.chain((0..SERVICE_COUNT).map(|index| crowded_service(index, &names))),
|
||||
);
|
||||
(2..FINISHED_SERVICES + 2).for_each(|id| {
|
||||
state.finish_job(id, JobResult::Done, MS * 1500 * id);
|
||||
});
|
||||
state
|
||||
}
|
||||
|
||||
fn report_timed_draws(label: &str, mut work: impl FnMut(Duration)) {
|
||||
let mut timings: Vec<Duration> = (0..DRAW_COUNT)
|
||||
.map(|draw| {
|
||||
let started = Instant::now();
|
||||
work(Duration::from_secs(90) + DRAW_SPACING * draw);
|
||||
started.elapsed()
|
||||
})
|
||||
.collect();
|
||||
timings.sort_unstable();
|
||||
let median = timings[timings.len() / 2];
|
||||
let slowest_tenth = timings[timings.len() * 9 / 10];
|
||||
println!("{label} over {DRAW_COUNT} draws: median {median:?}, p90 {slowest_tenth:?}");
|
||||
}
|
||||
|
||||
fn draw_boot_frame(
|
||||
terminal: &mut Terminal<TestBackend>,
|
||||
state: &BootState,
|
||||
projection: &BootProjection,
|
||||
now: Duration,
|
||||
) {
|
||||
terminal
|
||||
.draw(|frame| {
|
||||
frame.render_widget(
|
||||
BootView {
|
||||
state,
|
||||
projection,
|
||||
colors: &Colors::default(),
|
||||
timing: &Timing::default(),
|
||||
glyphs: &Glyphs::default(),
|
||||
now,
|
||||
origin: &ryzen_origin(),
|
||||
password_prompt: None,
|
||||
},
|
||||
frame.area(),
|
||||
);
|
||||
})
|
||||
.expect("draw");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "benchmark: cargo test --release frame_cost -- --ignored --nocapture"]
|
||||
fn frame_cost_of_a_crowded_boot() {
|
||||
let state = crowded_boot();
|
||||
let mut terminal = Terminal::new(TestBackend::new(110, 40)).expect("test backend");
|
||||
report_timed_draws("whole frame", |now| {
|
||||
let projection = project_boot(&state, &Timing::default(), now);
|
||||
draw_boot_frame(&mut terminal, &state, &projection, now);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "benchmark: cargo test --release frame_cost -- --ignored --nocapture"]
|
||||
fn frame_cost_with_a_cached_projection() {
|
||||
let state = crowded_boot();
|
||||
let projection = project_boot(&state, &Timing::default(), Duration::from_secs(90));
|
||||
let mut terminal = Terminal::new(TestBackend::new(110, 40)).expect("test backend");
|
||||
report_timed_draws("cached frame", |now| {
|
||||
draw_boot_frame(&mut terminal, &state, &projection, now);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "benchmark: cargo test --release frame_cost -- --ignored --nocapture"]
|
||||
fn frame_cost_of_the_model_projection() {
|
||||
let state = crowded_boot();
|
||||
report_timed_draws("model projection", |now| {
|
||||
black_box(flatten_forest(state.waiting_forest(now)));
|
||||
black_box(state.milestones());
|
||||
});
|
||||
}
|
||||
@@ -1,490 +0,0 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use super::{
|
||||
PasswordPrompt,
|
||||
screen_render_fixtures::{boot_in_progress, render, render_prompted, screen_lines},
|
||||
};
|
||||
use crate::{
|
||||
boot_model::{ActiveState, Activity, BootState, FailureCause, HANDOFF_UNIT, JobResult, Phase},
|
||||
boot_test_fixtures::{MS, queue_unit, queued_boot, running, waiting},
|
||||
screen_settings::color_scheme::Colors,
|
||||
};
|
||||
|
||||
const CRYPTSETUP_MESSAGE: &str =
|
||||
"Please enter passphrase for disk Samsung SSD 980 PRO 1TB (cryptroot):";
|
||||
|
||||
#[test]
|
||||
fn the_stage_says_when_the_manager_has_not_answered_yet() {
|
||||
let mut state = BootState::new(Phase::Host);
|
||||
let lines = render(&state, 500 * MS, 110, 24);
|
||||
assert!(
|
||||
lines[1].contains("Stage 2") && lines[1].contains("waiting for the system manager"),
|
||||
"{}",
|
||||
lines.join("\n")
|
||||
);
|
||||
state.set_root("graphical.target".to_owned());
|
||||
let lines = render(&state, 500 * MS, 110, 24);
|
||||
assert!(
|
||||
lines.iter().all(|line| !line.contains("system manager")),
|
||||
"{}",
|
||||
lines.join("\n")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tree_on_top_timeline_below() {
|
||||
let lines = render(&boot_in_progress(), 12_400 * MS, 110, 24);
|
||||
let screen = lines.join("\n");
|
||||
assert_eq!(
|
||||
lines[0], "ryzen · NixOS 26.11 · generation 2771 · Linux 7.2.9",
|
||||
"{screen}"
|
||||
);
|
||||
assert!(lines[1].starts_with("└─ Stage 2 12.4s"), "{screen}");
|
||||
assert!(lines[1].ends_with("Running"), "{screen}");
|
||||
assert!(
|
||||
lines[2].starts_with(" ├─ ◆ multi-user.target"),
|
||||
"{screen}"
|
||||
);
|
||||
assert!(
|
||||
lines[3].starts_with(" │ ├─ [|] systemd-rfkill"),
|
||||
"{screen}"
|
||||
);
|
||||
assert!(lines[4].starts_with(" │ ├─ [|] docker"), "{screen}");
|
||||
assert!(lines[5].starts_with(" │ └─ [ ] web"), "{screen}");
|
||||
assert!(lines[6].starts_with(" ├─ ◇ graphical.target"), "{screen}");
|
||||
assert!(lines[7].starts_with(" └─ [×] nvidia-powerd"), "{screen}");
|
||||
let timeline = lines
|
||||
.iter()
|
||||
.position(|line| line.contains(" Timeline "))
|
||||
.expect("timeline panel");
|
||||
assert!(
|
||||
lines[timeline + 1].starts_with(&format!("{:29}Kernel", "")),
|
||||
"{screen}"
|
||||
);
|
||||
assert!(
|
||||
lines[timeline + 2].starts_with("√ sysinit.target (2 units)"),
|
||||
"{screen}"
|
||||
);
|
||||
assert!(lines[timeline + 3].starts_with("√ udev-settle"), "{screen}");
|
||||
assert!(lines[timeline + 3].contains('■'), "{screen}");
|
||||
assert!(
|
||||
lines[timeline + 4].starts_with("► systemd-rfkill"),
|
||||
"{screen}"
|
||||
);
|
||||
assert!(
|
||||
lines[timeline + 4].contains("·█")
|
||||
&& lines[timeline + 4].ends_with(['▏', '▎', '▍', '▌', '▋', '▊', '▉', '█']),
|
||||
"{screen}"
|
||||
);
|
||||
assert!(lines[timeline + 5].starts_with("► docker"), "{screen}");
|
||||
assert!(
|
||||
lines[timeline..].iter().all(|line| !line.contains(" web")),
|
||||
"{screen}"
|
||||
);
|
||||
assert!(!screen.contains("root switch"), "{screen}");
|
||||
assert!(
|
||||
lines[23].starts_with("√ 2 done 2 running 3 waiting × 1 failed"),
|
||||
"{screen}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn password_prompt_floats_over_a_dimmed_view() {
|
||||
let buffer = render_prompted(
|
||||
&boot_in_progress(),
|
||||
12_400 * MS,
|
||||
110,
|
||||
24,
|
||||
Some(PasswordPrompt {
|
||||
message: CRYPTSETUP_MESSAGE,
|
||||
hint: None,
|
||||
input: "***".to_owned(),
|
||||
sent: false,
|
||||
rejected: false,
|
||||
}),
|
||||
);
|
||||
let lines = screen_lines(&buffer);
|
||||
let screen = lines.join("\n");
|
||||
let title_row = lines
|
||||
.iter()
|
||||
.position(|line| line.contains("┌ Password "))
|
||||
.unwrap_or_else(|| panic!("{screen}"));
|
||||
assert!(lines[title_row].starts_with(' '), "{screen}");
|
||||
assert!(
|
||||
lines[title_row + 1].contains(&format!("│ {CRYPTSETUP_MESSAGE}")),
|
||||
"{screen}"
|
||||
);
|
||||
assert!(lines[title_row + 3].contains("│ > ***_"), "{screen}");
|
||||
assert!(lines[title_row + 4].contains("Enter unlock"), "{screen}");
|
||||
assert!(
|
||||
lines[23].starts_with("√ 2 done 2 running 3 waiting × 1 failed"),
|
||||
"{screen}"
|
||||
);
|
||||
assert_eq!(
|
||||
buffer[(0, 0)].fg,
|
||||
Colors::default().password.backdrop,
|
||||
"{screen}"
|
||||
);
|
||||
let corner = buffer
|
||||
.content
|
||||
.iter()
|
||||
.find(|cell| cell.symbol() == "┌")
|
||||
.unwrap_or_else(|| panic!("{screen}"));
|
||||
assert_eq!(corner.fg, Colors::default().password.frame, "{screen}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn answered_password_prompt_shows_it_is_checking() {
|
||||
let lines = screen_lines(&render_prompted(
|
||||
&boot_in_progress(),
|
||||
12_400 * MS,
|
||||
110,
|
||||
24,
|
||||
Some(PasswordPrompt {
|
||||
message: CRYPTSETUP_MESSAGE,
|
||||
hint: None,
|
||||
input: String::new(),
|
||||
sent: true,
|
||||
rejected: false,
|
||||
}),
|
||||
));
|
||||
assert!(
|
||||
lines.iter().any(|line| line.contains("│ Checking…")),
|
||||
"{}",
|
||||
lines.join("\n")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn long_password_messages_wrap_inside_narrow_screens() {
|
||||
let lines = screen_lines(&render_prompted(
|
||||
&boot_in_progress(),
|
||||
12_400 * MS,
|
||||
50,
|
||||
24,
|
||||
Some(PasswordPrompt {
|
||||
message: CRYPTSETUP_MESSAGE,
|
||||
hint: None,
|
||||
input: String::new(),
|
||||
sent: false,
|
||||
rejected: false,
|
||||
}),
|
||||
));
|
||||
let screen = lines.join("\n");
|
||||
assert!(
|
||||
lines.iter().any(|line| line.contains("(cryptroot):")),
|
||||
"{screen}"
|
||||
);
|
||||
assert!(lines.iter().any(|line| line.contains("> _")), "{screen}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_rejected_passphrase_is_called_out_under_the_hint() {
|
||||
let buffer = render_prompted(
|
||||
&boot_in_progress(),
|
||||
12_400 * MS,
|
||||
110,
|
||||
24,
|
||||
Some(PasswordPrompt {
|
||||
message: CRYPTSETUP_MESSAGE,
|
||||
hint: Some("This demo unlocks with the passphrase \"demo\""),
|
||||
input: String::new(),
|
||||
sent: false,
|
||||
rejected: true,
|
||||
}),
|
||||
);
|
||||
let lines = screen_lines(&buffer);
|
||||
let screen = lines.join("\n");
|
||||
let message_row = lines
|
||||
.iter()
|
||||
.position(|line| line.contains(CRYPTSETUP_MESSAGE))
|
||||
.unwrap_or_else(|| panic!("{screen}"));
|
||||
assert!(
|
||||
lines[message_row + 1].contains("│ This demo unlocks with the passphrase \"demo\""),
|
||||
"{screen}"
|
||||
);
|
||||
assert!(
|
||||
lines[message_row + 3].contains("│ Wrong passphrase, try again"),
|
||||
"{screen}"
|
||||
);
|
||||
assert!(lines[message_row + 4].contains("│ > _"), "{screen}");
|
||||
let rejection_row = u16::try_from(message_row + 3).expect("row fits the screen");
|
||||
let warning = (0..buffer.area.width)
|
||||
.map(|column| &buffer[(column, rejection_row)])
|
||||
.find(|cell| cell.symbol() == "W")
|
||||
.unwrap_or_else(|| panic!("{screen}"));
|
||||
assert_eq!(warning.fg, Colors::default().password.rejected, "{screen}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sub_second_runs_stay_off_the_timeline() {
|
||||
let mut state = boot_in_progress();
|
||||
queue_unit(
|
||||
&mut state,
|
||||
20,
|
||||
running("blink.service", &[], 4000 * MS),
|
||||
4000 * MS,
|
||||
);
|
||||
state.finish_job(20, JobResult::Done, 4400 * MS);
|
||||
let lines = render(&state, 12_400 * MS, 110, 24);
|
||||
assert!(
|
||||
lines.iter().all(|line| !line.contains("blink")),
|
||||
"{}",
|
||||
lines.join("\n")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn long_timeline_labels_end_in_an_ellipsis() {
|
||||
let mut state = boot_in_progress();
|
||||
queue_unit(
|
||||
&mut state,
|
||||
30,
|
||||
running("sys-kernel-config.mount", &[], 2000 * MS)
|
||||
.described("Kernel Configuration File System"),
|
||||
2000 * MS,
|
||||
);
|
||||
state.finish_job(30, JobResult::Done, 4000 * MS);
|
||||
let lines = render(&state, 12_400 * MS, 110, 24);
|
||||
assert!(
|
||||
lines
|
||||
.iter()
|
||||
.any(|line| line.starts_with("√ Kernel Configuration File…")),
|
||||
"{}",
|
||||
lines.join("\n")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn narrow_screens_drop_the_timeline() {
|
||||
let lines = render(&boot_in_progress(), 12_400 * MS, 37, 24);
|
||||
assert!(
|
||||
lines.iter().all(|line| !line.contains('■')),
|
||||
"{}",
|
||||
lines.join("\n")
|
||||
);
|
||||
assert!(lines[3].contains("systemd-rfkill"), "{}", lines.join("\n"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn finished_stages_collapse_into_a_summary_rule() {
|
||||
let mut state = queued_boot(
|
||||
Phase::Initrd,
|
||||
Duration::ZERO,
|
||||
[waiting("initrd.target", &[])],
|
||||
);
|
||||
state.finish_job(1, JobResult::Done, 6000 * MS);
|
||||
state.switch_root(7200 * MS);
|
||||
state.set_root("graphical.target".to_owned());
|
||||
queue_unit(&mut state, 2, waiting("graphical.target", &[]), 7300 * MS);
|
||||
let lines = render(&state, 17_300 * MS, 110, 24);
|
||||
let screen = lines.join("\n");
|
||||
assert!(lines[0].ends_with("17.3s"), "{screen}");
|
||||
assert!(
|
||||
lines[1].starts_with("├─ Initrd ■ done in 7.2s · 1 unit"),
|
||||
"{screen}"
|
||||
);
|
||||
assert!(lines[2].starts_with("└─ Stage 2 10.1s"), "{screen}");
|
||||
assert!(lines[3].starts_with(" └─ ◆ graphical.target"), "{screen}");
|
||||
let timeline = lines
|
||||
.iter()
|
||||
.position(|line| line.contains(" Timeline "))
|
||||
.expect("timeline panel");
|
||||
let initrd_bar = &lines[timeline + 2];
|
||||
assert!(initrd_bar.starts_with("√ Initrd (1 unit)"), "{screen}");
|
||||
assert!(initrd_bar.ends_with("■│"), "{screen}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn completion_without_a_display_manager_hands_back_the_console() {
|
||||
let mut state = queued_boot(
|
||||
Phase::Host,
|
||||
Duration::ZERO,
|
||||
[waiting("graphical.target", &[])],
|
||||
);
|
||||
state.finish_job(1, JobResult::Done, 9000 * MS);
|
||||
let lines = render(&state, 9500 * MS, 110, 24);
|
||||
assert!(
|
||||
lines[1].starts_with("└─ ■ Boot finished in 9.5s · handing over to the console"),
|
||||
"{}",
|
||||
lines.join("\n")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn completion_names_the_display_manager_that_started() {
|
||||
let mut state = queued_boot(
|
||||
Phase::Host,
|
||||
Duration::ZERO,
|
||||
[waiting("graphical.target", &[])],
|
||||
);
|
||||
queue_unit(&mut state, 2, waiting(HANDOFF_UNIT, &[]), 500 * MS);
|
||||
state.update_activity(
|
||||
HANDOFF_UNIT,
|
||||
Activity {
|
||||
state: Some(ActiveState::Active),
|
||||
..Activity::default()
|
||||
},
|
||||
);
|
||||
state.finish_job(1, JobResult::Done, 9000 * MS);
|
||||
let lines = render(&state, 9500 * MS, 110, 24);
|
||||
assert!(
|
||||
lines[1]
|
||||
.starts_with("└─ ■ Boot finished in 9.5s · handing over to display-manager.service"),
|
||||
"{}",
|
||||
lines.join("\n")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shutdown_in_progress_names_its_stage() {
|
||||
let mut state = queued_boot(
|
||||
Phase::Shutdown,
|
||||
20_000 * MS,
|
||||
[waiting("poweroff.target", &[])],
|
||||
);
|
||||
state.origin = 20_000 * MS;
|
||||
let lines = render(&state, 21_500 * MS, 110, 24);
|
||||
assert!(
|
||||
lines[1].starts_with("└─ Shutdown 1.5s") && lines[1].ends_with("Running"),
|
||||
"{}",
|
||||
lines.join("\n")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shutdown_announces_the_handover_once_the_manager_exits() {
|
||||
let mut state = BootState::new(Phase::Shutdown);
|
||||
state.origin = 20_000 * MS;
|
||||
state.manager_exited_at = Some(24_200 * MS);
|
||||
let lines = render(&state, 30_000 * MS, 110, 24);
|
||||
assert!(
|
||||
lines[1].starts_with("└─ ■ Shutdown finished in 4.2s · handing over to systemd-shutdown"),
|
||||
"{}",
|
||||
lines.join("\n")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_timeline_keeps_only_the_slowest_finished_runs() {
|
||||
let quick_units: Vec<String> = (0..10).map(|n| format!("run{n:02}.service")).collect();
|
||||
let after: Vec<&str> = quick_units
|
||||
.iter()
|
||||
.map(String::as_str)
|
||||
.chain(["slow.service"])
|
||||
.collect();
|
||||
let mut state = queued_boot(
|
||||
Phase::Host,
|
||||
Duration::ZERO,
|
||||
[
|
||||
waiting("multi-user.target", &after),
|
||||
running("slow.service", &[], Duration::ZERO),
|
||||
],
|
||||
);
|
||||
quick_units.iter().zip(10..).for_each(|(name, id)| {
|
||||
queue_unit(
|
||||
&mut state,
|
||||
id,
|
||||
running(name, &[], Duration::ZERO),
|
||||
Duration::ZERO,
|
||||
);
|
||||
state.finish_job(id, JobResult::Done, (1000 * id - 9000) * MS);
|
||||
});
|
||||
let lines = render(&state, 20_000 * MS, 110, 40);
|
||||
let screen = lines.join("\n");
|
||||
let timeline = lines
|
||||
.iter()
|
||||
.position(|line| line.contains(" Timeline "))
|
||||
.expect("timeline panel");
|
||||
let (tree, panel) = lines.split_at(timeline);
|
||||
assert!(tree.iter().all(|line| !line.contains('…')), "{screen}");
|
||||
let shown: Vec<&str> = quick_units
|
||||
.iter()
|
||||
.map(|name| name.trim_end_matches(".service"))
|
||||
.filter(|label| panel.iter().any(|line| line.contains(label)))
|
||||
.collect();
|
||||
assert_eq!(
|
||||
shown,
|
||||
["run05", "run06", "run07", "run08", "run09"],
|
||||
"{screen}"
|
||||
);
|
||||
}
|
||||
|
||||
fn explained_nvidia_failure() -> BootState {
|
||||
let mut state = boot_in_progress();
|
||||
state.explain_failure(
|
||||
"nvidia-powerd.service",
|
||||
FailureCause {
|
||||
reason: "exited with status 1".to_owned(),
|
||||
log_lines: vec![
|
||||
"ERROR! Failed to get system power limits".to_owned(),
|
||||
"giving up".to_owned(),
|
||||
],
|
||||
},
|
||||
);
|
||||
state
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn failures_show_their_reason_and_journal_lines_above_the_timeline() {
|
||||
let lines = render(&explained_nvidia_failure(), 12_400 * MS, 110, 30);
|
||||
let screen = lines.join("\n");
|
||||
let failures = lines
|
||||
.iter()
|
||||
.position(|line| line.contains(" Failures "))
|
||||
.expect("failure panel");
|
||||
let timeline = lines
|
||||
.iter()
|
||||
.position(|line| line.contains(" Timeline "))
|
||||
.expect("timeline panel");
|
||||
assert!(failures < timeline, "{screen}");
|
||||
assert_eq!(
|
||||
lines[failures + 1],
|
||||
"× nvidia-powerd exited with status 1",
|
||||
"{screen}"
|
||||
);
|
||||
assert_eq!(
|
||||
lines[failures + 2],
|
||||
" ERROR! Failed to get system power limits",
|
||||
"{screen}"
|
||||
);
|
||||
assert_eq!(lines[failures + 3], " giving up", "{screen}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn failure_lines_are_cut_to_a_narrow_screen() {
|
||||
let lines = render(&explained_nvidia_failure(), 12_400 * MS, 30, 30);
|
||||
let screen = lines.join("\n");
|
||||
let failures = lines
|
||||
.iter()
|
||||
.position(|line| line.contains(" Failures "))
|
||||
.expect("failure panel");
|
||||
assert_eq!(
|
||||
lines[failures + 1],
|
||||
"× nvidia-powerd exited with …",
|
||||
"{screen}"
|
||||
);
|
||||
assert_eq!(
|
||||
lines[failures + 2],
|
||||
" ERROR! Failed to get syste…",
|
||||
"{screen}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dependency_failures_stay_out_of_the_failure_panel() {
|
||||
let mut state = queued_boot(
|
||||
Phase::Host,
|
||||
1000 * MS,
|
||||
[
|
||||
waiting("multi-user.target", &["web.service"]),
|
||||
waiting("web.service", &[]),
|
||||
],
|
||||
);
|
||||
state.finish_job(2, JobResult::Dependency, 2000 * MS);
|
||||
let lines = render(&state, 3000 * MS, 110, 24);
|
||||
let screen = lines.join("\n");
|
||||
assert!(!screen.contains(" Failures "), "{screen}");
|
||||
assert!(screen.contains("[×] web"), "{screen}");
|
||||
assert!(screen.contains("× 1 failed"), "{screen}");
|
||||
}
|
||||
@@ -1,354 +0,0 @@
|
||||
use std::{cmp::Reverse, iter::once, time::Duration};
|
||||
|
||||
use ratatui::{
|
||||
buffer::Buffer,
|
||||
layout::{
|
||||
Constraint::{Fill, Length},
|
||||
Layout, Rect,
|
||||
},
|
||||
style::{Color, Stylize},
|
||||
symbols::Marker,
|
||||
text::{Line, Span},
|
||||
widgets::{
|
||||
Paragraph, Widget,
|
||||
canvas::{Canvas, Line as Stroke, Points},
|
||||
},
|
||||
};
|
||||
|
||||
use super::{
|
||||
WHOLE_UNITS, fit_width, rule,
|
||||
screen_spacing::{
|
||||
ANNOTATION_COLUMN_WIDTH, COLUMN_GAP_WIDTH, RULED_ROW_HEIGHT, TEXT_ROW_HEIGHT,
|
||||
TIMELINE_LABEL_WIDTH,
|
||||
},
|
||||
unit_count,
|
||||
};
|
||||
use crate::{
|
||||
boot_model::{FinishedRun, MilestoneRow},
|
||||
screen_settings::{color_scheme::TimelineColors, font_glyphs::Glyphs},
|
||||
};
|
||||
|
||||
const MARK_WIDTH: u16 = 2;
|
||||
const SLOWEST_RUNS_SHOWN: usize = 5;
|
||||
const KERNEL_ORIGIN_LABEL: &str = "Kernel";
|
||||
const AXIS_STEPS: [Duration; 12] = [
|
||||
Duration::from_secs(1),
|
||||
Duration::from_secs(2),
|
||||
Duration::from_secs(5),
|
||||
Duration::from_secs(10),
|
||||
Duration::from_secs(15),
|
||||
Duration::from_secs(30),
|
||||
Duration::from_mins(1),
|
||||
Duration::from_mins(2),
|
||||
Duration::from_mins(5),
|
||||
Duration::from_mins(10),
|
||||
Duration::from_mins(30),
|
||||
Duration::from_hours(1),
|
||||
];
|
||||
|
||||
pub struct Timeline<'a> {
|
||||
pub origin: Duration,
|
||||
pub now: Duration,
|
||||
pub root_switches: Vec<Duration>,
|
||||
pub milestones: &'a [MilestoneRow],
|
||||
pub finished: Vec<&'a FinishedRun>,
|
||||
pub running: Vec<RunningRun<'a>>,
|
||||
pub colors: &'a TimelineColors,
|
||||
pub glyphs: &'a Glyphs,
|
||||
}
|
||||
|
||||
pub struct RunningRun<'a> {
|
||||
pub label: &'a str,
|
||||
pub queued_at: Duration,
|
||||
pub since: Duration,
|
||||
}
|
||||
|
||||
fn label_and_bar_areas(area: Rect) -> [Rect; 2] {
|
||||
area.layout(
|
||||
&Layout::horizontal([Length(TIMELINE_LABEL_WIDTH), Fill(1)]).spacing(COLUMN_GAP_WIDTH),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn timeline_fits(area: Rect) -> bool {
|
||||
let [_, bar_area] = label_and_bar_areas(area);
|
||||
bar_area.width >= ANNOTATION_COLUMN_WIDTH
|
||||
}
|
||||
|
||||
impl Timeline<'_> {
|
||||
pub fn height(&self) -> u16 {
|
||||
let entries = self.milestones.len()
|
||||
+ self.finished.len().min(SLOWEST_RUNS_SHOWN)
|
||||
+ self.running.len();
|
||||
if entries == 0 {
|
||||
return 0;
|
||||
}
|
||||
RULED_ROW_HEIGHT.saturating_add(u16::try_from(entries).unwrap_or(u16::MAX))
|
||||
}
|
||||
|
||||
fn finished_that_fit(&self, height: u16) -> Vec<&FinishedRun> {
|
||||
let bar_rows = usize::from(height.saturating_sub(RULED_ROW_HEIGHT));
|
||||
let room = bar_rows.saturating_sub(self.milestones.len() + self.running.len());
|
||||
let mut longest_first = self.finished.clone();
|
||||
longest_first
|
||||
.sort_unstable_by_key(|run| Reverse(run.finished_at.saturating_sub(run.started_at)));
|
||||
longest_first.truncate(room.min(SLOWEST_RUNS_SHOWN));
|
||||
longest_first.sort_unstable_by_key(|run| run.started_at);
|
||||
longest_first
|
||||
}
|
||||
|
||||
fn milestone_entry(&self, row: &MilestoneRow) -> TimelineEntry<'static> {
|
||||
TimelineEntry {
|
||||
label: Line::styled(
|
||||
format!(
|
||||
"{} {} ({})",
|
||||
self.glyphs.done,
|
||||
row.label,
|
||||
unit_count(row.finished_units)
|
||||
),
|
||||
self.colors.milestone,
|
||||
),
|
||||
segments: vec![Segment {
|
||||
from: row.started_at,
|
||||
to: row.reached_at,
|
||||
symbol: self.glyphs.bead,
|
||||
color: self.colors.milestone,
|
||||
}],
|
||||
still_going: false,
|
||||
}
|
||||
}
|
||||
|
||||
fn finished_entry<'a>(&self, run: &'a FinishedRun) -> TimelineEntry<'a> {
|
||||
let mark = if run.failed {
|
||||
self.glyphs.failed
|
||||
} else {
|
||||
self.glyphs.done
|
||||
};
|
||||
let outcome = if run.failed {
|
||||
self.colors.failed
|
||||
} else {
|
||||
self.colors.finished
|
||||
};
|
||||
TimelineEntry {
|
||||
label: Line::from(vec![
|
||||
Span::styled(format!("{mark} "), outcome),
|
||||
self.fitted(&run.label).fg(self.colors.finished_label),
|
||||
]),
|
||||
segments: vec![Segment {
|
||||
from: run.started_at,
|
||||
to: run.finished_at,
|
||||
symbol: self.glyphs.bead,
|
||||
color: outcome,
|
||||
}],
|
||||
still_going: false,
|
||||
}
|
||||
}
|
||||
|
||||
fn fitted(&self, label: &str) -> String {
|
||||
fit_width(
|
||||
label,
|
||||
usize::from(TIMELINE_LABEL_WIDTH - MARK_WIDTH),
|
||||
self.glyphs.ellipsis,
|
||||
)
|
||||
}
|
||||
|
||||
fn running_entry(&self, run: &RunningRun) -> TimelineEntry<'static> {
|
||||
let waited = (run.since > run.queued_at).then_some(Segment {
|
||||
from: run.queued_at,
|
||||
to: run.since,
|
||||
symbol: self.glyphs.waiting_bead,
|
||||
color: self.colors.queued_bar,
|
||||
});
|
||||
let running_bar = self
|
||||
.glyphs
|
||||
.growing_tip
|
||||
.map_or(self.glyphs.bead, |tips| tips[7]);
|
||||
let ran = Segment {
|
||||
from: run.since,
|
||||
to: self.now,
|
||||
symbol: running_bar,
|
||||
color: self.colors.running,
|
||||
};
|
||||
TimelineEntry {
|
||||
label: Line::from(vec![
|
||||
format!("{} ", self.glyphs.running_mark).fg(self.colors.running),
|
||||
self.fitted(run.label).fg(self.colors.running_label),
|
||||
]),
|
||||
segments: waited.into_iter().chain(once(ran)).collect(),
|
||||
still_going: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Widget for Timeline<'_> {
|
||||
fn render(self, area: Rect, buf: &mut Buffer) {
|
||||
let block = rule(
|
||||
self.colors.rule,
|
||||
Line::from(" Timeline ".fg(self.colors.title)),
|
||||
);
|
||||
let inner = block.inner(area);
|
||||
block.render(area, buf);
|
||||
let [label_area, bar_area] = label_and_bar_areas(inner);
|
||||
let entries: Vec<TimelineEntry> = self
|
||||
.milestones
|
||||
.iter()
|
||||
.map(|row| self.milestone_entry(row))
|
||||
.chain(
|
||||
self.finished_that_fit(area.height)
|
||||
.into_iter()
|
||||
.map(|run| self.finished_entry(run)),
|
||||
)
|
||||
.chain(self.running.iter().map(|row| self.running_entry(row)))
|
||||
.collect();
|
||||
let [_, entry_labels_area] =
|
||||
label_area.layout(&Layout::vertical([Length(TEXT_ROW_HEIGHT), Fill(1)]));
|
||||
Paragraph::new(
|
||||
entries
|
||||
.iter()
|
||||
.map(|entry| entry.label.clone())
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
.render(entry_labels_area, buf);
|
||||
let axis = TimeAxis::new(self.origin, self.now, bar_area.width);
|
||||
let label_row = f64::from(bar_area.height.saturating_sub(1).max(1));
|
||||
let axis_color = self.colors.axis;
|
||||
Canvas::default()
|
||||
.x_bounds(axis.bounds())
|
||||
.y_bounds([0.0, label_row])
|
||||
.paint(|ctx| {
|
||||
entries.iter().zip(1_u16..).for_each(|(entry, row)| {
|
||||
let y = label_row - f64::from(row);
|
||||
entry.segments.iter().for_each(|segment| {
|
||||
ctx.marker(Marker::Custom(segment.symbol));
|
||||
ctx.draw(&Stroke::new(
|
||||
segment.from.as_secs_f64(),
|
||||
y,
|
||||
segment.to.as_secs_f64(),
|
||||
y,
|
||||
segment.color,
|
||||
));
|
||||
});
|
||||
if entry.still_going {
|
||||
let tip = self
|
||||
.glyphs
|
||||
.growing_tip
|
||||
.map_or(self.glyphs.still_going, |tips| {
|
||||
tips[axis.eighths_into_column(self.now)]
|
||||
});
|
||||
let tip_color = if self.glyphs.growing_tip.is_some() {
|
||||
self.colors.running
|
||||
} else {
|
||||
axis_color
|
||||
};
|
||||
ctx.marker(Marker::Custom(tip));
|
||||
ctx.draw(&Points::new(&[(self.now.as_secs_f64(), y)], tip_color));
|
||||
}
|
||||
});
|
||||
ctx.marker(Marker::Custom(self.glyphs.root_switch_mark));
|
||||
self.root_switches.iter().for_each(|at| {
|
||||
let x = at.as_secs_f64();
|
||||
ctx.draw(&Stroke::new(x, 0.0, x, label_row - 1.0, axis_color));
|
||||
});
|
||||
axis.tick_offsets().for_each(|offset| {
|
||||
let label = axis.label(offset);
|
||||
let x = (axis.origin + offset)
|
||||
.as_secs_f64()
|
||||
.min(axis.bounds()[1] - axis.columns_to_seconds(label.len() - 1));
|
||||
ctx.print(x, label_row, label.fg(axis_color));
|
||||
});
|
||||
})
|
||||
.render(bar_area, buf);
|
||||
}
|
||||
}
|
||||
|
||||
struct TimelineEntry<'a> {
|
||||
label: Line<'a>,
|
||||
segments: Vec<Segment>,
|
||||
still_going: bool,
|
||||
}
|
||||
|
||||
struct Segment {
|
||||
from: Duration,
|
||||
to: Duration,
|
||||
symbol: char,
|
||||
color: Color,
|
||||
}
|
||||
|
||||
struct TimeAxis {
|
||||
origin: Duration,
|
||||
span: Duration,
|
||||
step: Duration,
|
||||
width: u16,
|
||||
}
|
||||
|
||||
impl TimeAxis {
|
||||
fn new(origin: Duration, now: Duration, width: u16) -> Self {
|
||||
let elapsed = now.saturating_sub(origin).max(AXIS_STEPS[0]);
|
||||
let max_labels = u128::from((width / ANNOTATION_COLUMN_WIDTH).max(1));
|
||||
let step = AXIS_STEPS
|
||||
.into_iter()
|
||||
.find(|step| elapsed.as_nanos().div_ceil(step.as_nanos()) <= max_labels)
|
||||
.unwrap_or(AXIS_STEPS[AXIS_STEPS.len() - 1]);
|
||||
let steps = u32::try_from(elapsed.as_nanos().div_ceil(step.as_nanos())).unwrap_or(u32::MAX);
|
||||
Self {
|
||||
origin,
|
||||
span: step * steps.max(1),
|
||||
step,
|
||||
width,
|
||||
}
|
||||
}
|
||||
|
||||
fn bounds(&self) -> [f64; 2] {
|
||||
[
|
||||
self.origin.as_secs_f64(),
|
||||
(self.origin + self.span).as_secs_f64(),
|
||||
]
|
||||
}
|
||||
|
||||
fn eighths_into_column(&self, at: Duration) -> usize {
|
||||
let last_column = u128::from(self.width.saturating_sub(1).max(1));
|
||||
let span = self.span.as_nanos().max(1);
|
||||
let scaled = at.saturating_sub(self.origin).as_nanos() * last_column;
|
||||
usize::try_from(scaled % span * 8 / span).unwrap_or_default()
|
||||
}
|
||||
|
||||
fn columns_to_seconds(&self, columns: usize) -> f64 {
|
||||
let last_column = self.width.saturating_sub(1).max(1);
|
||||
let columns = u16::try_from(columns).unwrap_or(last_column);
|
||||
self.span.as_secs_f64() * f64::from(columns) / f64::from(last_column)
|
||||
}
|
||||
|
||||
fn tick_offsets(&self) -> impl Iterator<Item = Duration> + '_ {
|
||||
(0..)
|
||||
.map(|index: u32| self.step * index)
|
||||
.take_while(|offset| *offset <= self.span)
|
||||
}
|
||||
|
||||
fn label(&self, offset: Duration) -> String {
|
||||
if offset.is_zero() && self.origin.is_zero() {
|
||||
KERNEL_ORIGIN_LABEL.to_owned()
|
||||
} else {
|
||||
WHOLE_UNITS.unsigned_duration_to_string(&offset)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn the_tip_fills_its_column_in_eighths() {
|
||||
let axis = TimeAxis {
|
||||
origin: Duration::ZERO,
|
||||
span: Duration::from_secs(10),
|
||||
step: Duration::from_secs(1),
|
||||
width: 11,
|
||||
};
|
||||
let eighths = |millis: u64| axis.eighths_into_column(Duration::from_millis(millis));
|
||||
assert_eq!(eighths(2000), 0);
|
||||
assert_eq!(eighths(2125), 1);
|
||||
assert_eq!(eighths(2500), 4);
|
||||
assert_eq!(eighths(2999), 7);
|
||||
assert_eq!(eighths(3000), 0);
|
||||
}
|
||||
}
|
||||
@@ -1,166 +0,0 @@
|
||||
use std::{iter::once, time::Duration};
|
||||
|
||||
use ratatui::{
|
||||
buffer::Buffer,
|
||||
layout::{
|
||||
Constraint::{self, Fill, Length},
|
||||
Layout, Rect,
|
||||
},
|
||||
style::{Style, Stylize},
|
||||
text::{Line, Span},
|
||||
widgets::{Block, Clear, Padding, Paragraph, Widget, Wrap},
|
||||
};
|
||||
|
||||
use super::{
|
||||
ELAPSED, rule,
|
||||
screen_spacing::{ANNOTATION_COLUMN_WIDTH, TEXT_GAP},
|
||||
};
|
||||
use crate::{
|
||||
boot_model::{Tally, boot_origin::BootOrigin},
|
||||
screen_settings::{
|
||||
color_scheme::{FooterColors, HeaderColors, PasswordColors},
|
||||
font_glyphs::Glyphs,
|
||||
},
|
||||
};
|
||||
|
||||
const SEPARATOR: &str = " · ";
|
||||
const REJECTED_PASSPHRASE: &str = "Wrong passphrase, try again";
|
||||
|
||||
pub struct Header<'a> {
|
||||
pub origin: &'a BootOrigin,
|
||||
pub total: Option<Duration>,
|
||||
pub colors: &'a HeaderColors,
|
||||
}
|
||||
|
||||
impl Header<'_> {
|
||||
fn origin(&self) -> Line<'static> {
|
||||
Line::from(
|
||||
self.origin
|
||||
.parts()
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
.flat_map(|(index, part)| {
|
||||
let separator = (index > 0).then(|| SEPARATOR.fg(self.colors.separators));
|
||||
let part = Span::from(part).fg(self.colors.origin);
|
||||
let part = if index == 0 { part.bold() } else { part };
|
||||
separator.into_iter().chain(once(part))
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl Widget for Header<'_> {
|
||||
fn render(self, area: Rect, buf: &mut Buffer) {
|
||||
let [origin_area, total_area] = area.layout(&Layout::horizontal([
|
||||
Fill(1),
|
||||
Length(ANNOTATION_COLUMN_WIDTH),
|
||||
]));
|
||||
self.origin().render(origin_area, buf);
|
||||
if let Some(total) = self.total {
|
||||
Line::from(ELAPSED.unsigned_duration_to_string(&total))
|
||||
.fg(self.colors.total_time)
|
||||
.bold()
|
||||
.right_aligned()
|
||||
.render(total_area, buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Footer<'a> {
|
||||
pub tally: Tally,
|
||||
pub colors: &'a FooterColors,
|
||||
pub glyphs: &'a Glyphs,
|
||||
}
|
||||
|
||||
impl Widget for Footer<'_> {
|
||||
fn render(self, area: Rect, buf: &mut Buffer) {
|
||||
let failed = format!(
|
||||
"{TEXT_GAP}{} {} failed",
|
||||
self.glyphs.failed, self.tally.failed
|
||||
);
|
||||
let failed = if self.tally.failed > 0 {
|
||||
failed.fg(self.colors.failed).bold()
|
||||
} else {
|
||||
failed.fg(self.colors.no_failures)
|
||||
};
|
||||
Paragraph::new(Line::from(vec![
|
||||
format!("{} {} done", self.glyphs.done, self.tally.done).fg(self.colors.done),
|
||||
format!("{TEXT_GAP}{} running", self.tally.running).fg(self.colors.running),
|
||||
format!("{TEXT_GAP}{} waiting", self.tally.waiting).fg(self.colors.waiting),
|
||||
failed,
|
||||
]))
|
||||
.block(rule(self.colors.rule, Line::default()))
|
||||
.render(area, buf);
|
||||
}
|
||||
}
|
||||
|
||||
pub struct PasswordPrompt<'a> {
|
||||
pub message: &'a str,
|
||||
pub hint: Option<&'a str>,
|
||||
pub input: String,
|
||||
pub sent: bool,
|
||||
pub rejected: bool,
|
||||
}
|
||||
|
||||
pub struct PasswordPopup<'a> {
|
||||
pub asking: &'a PasswordPrompt<'a>,
|
||||
pub colors: &'a PasswordColors,
|
||||
pub glyphs: &'a Glyphs,
|
||||
}
|
||||
|
||||
impl PasswordPopup<'_> {
|
||||
const MIN_WIDTH: u16 = 40;
|
||||
|
||||
fn input(&self) -> Line<'static> {
|
||||
if self.asking.sent {
|
||||
Line::from(format!("Checking{}", self.glyphs.ellipsis).fg(self.colors.checking))
|
||||
} else {
|
||||
Line::from(vec![
|
||||
"> ".fg(self.colors.frame),
|
||||
format!("{}_", self.asking.input).fg(self.colors.message),
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
fn paragraph(&self) -> Paragraph<'_> {
|
||||
let message = Line::from(self.asking.message.fg(self.colors.message).bold());
|
||||
let hint = self
|
||||
.asking
|
||||
.hint
|
||||
.map(|hint| Line::from(hint.fg(self.colors.hint)));
|
||||
let rejection = (self.asking.rejected && !self.asking.sent)
|
||||
.then(|| Line::from(REJECTED_PASSPHRASE.fg(self.colors.rejected).bold()));
|
||||
let lines: Vec<Line> = once(message)
|
||||
.chain(hint)
|
||||
.chain(once(Line::default()))
|
||||
.chain(rejection)
|
||||
.chain(once(self.input()))
|
||||
.collect();
|
||||
Paragraph::new(lines).wrap(Wrap { trim: false }).block(
|
||||
Block::bordered()
|
||||
.border_style(self.colors.frame)
|
||||
.padding(Padding::horizontal(2))
|
||||
.title(" Password ".fg(self.colors.frame).bold())
|
||||
.title_bottom(
|
||||
Line::from(" Enter unlock · Ctrl+U clear ".fg(self.colors.hint))
|
||||
.right_aligned(),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl Widget for PasswordPopup<'_> {
|
||||
fn render(self, area: Rect, buf: &mut Buffer) {
|
||||
buf.set_style(area, Style::new().fg(self.colors.backdrop));
|
||||
let paragraph = self.paragraph();
|
||||
let width = u16::try_from(paragraph.line_width())
|
||||
.unwrap_or(u16::MAX)
|
||||
.max(Self::MIN_WIDTH)
|
||||
.min(area.width);
|
||||
let height = u16::try_from(paragraph.line_count(width)).unwrap_or(u16::MAX);
|
||||
let popup = area.centered(Constraint::Length(width), Constraint::Length(height));
|
||||
Clear.render(popup, buf);
|
||||
paragraph.render(popup, buf);
|
||||
}
|
||||
}
|
||||
@@ -1,123 +0,0 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use ratatui::{Terminal, backend::TestBackend, buffer::Buffer};
|
||||
|
||||
use super::{BootView, PasswordPrompt, project_boot};
|
||||
use crate::{
|
||||
boot_model::{BootState, JobResult, Phase, boot_origin::BootOrigin},
|
||||
boot_test_fixtures::{MS, queued_boot, running, waiting},
|
||||
screen_settings::{color_scheme::Colors, config_file::Timing, font_glyphs::Glyphs},
|
||||
};
|
||||
|
||||
pub fn render(state: &BootState, now: Duration, width: u16, height: u16) -> Vec<String> {
|
||||
screen_lines(&render_prompted(state, now, width, height, None))
|
||||
}
|
||||
|
||||
pub fn render_prompted(
|
||||
state: &BootState,
|
||||
now: Duration,
|
||||
width: u16,
|
||||
height: u16,
|
||||
password_prompt: Option<PasswordPrompt>,
|
||||
) -> Buffer {
|
||||
let mut terminal = Terminal::new(TestBackend::new(width, height)).expect("test backend");
|
||||
let timing = Timing::default();
|
||||
let projection = project_boot(state, &timing, now);
|
||||
terminal
|
||||
.draw(|frame| {
|
||||
frame.render_widget(
|
||||
BootView {
|
||||
state,
|
||||
projection: &projection,
|
||||
colors: &Colors::default(),
|
||||
timing: &timing,
|
||||
glyphs: &Glyphs::default(),
|
||||
now,
|
||||
origin: &ryzen_origin(),
|
||||
password_prompt,
|
||||
},
|
||||
frame.area(),
|
||||
);
|
||||
})
|
||||
.expect("draw");
|
||||
terminal.backend().buffer().clone()
|
||||
}
|
||||
|
||||
pub fn ryzen_origin() -> BootOrigin {
|
||||
BootOrigin {
|
||||
host: "ryzen".to_owned(),
|
||||
system: Some("NixOS 26.11".to_owned()),
|
||||
generation: Some("2771".to_owned()),
|
||||
kernel: "Linux 7.2.9".to_owned(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn screen_lines(buffer: &Buffer) -> Vec<String> {
|
||||
let area = buffer.area;
|
||||
(0..area.height)
|
||||
.map(|y| {
|
||||
let line: String = (0..area.width)
|
||||
.map(|x| buffer[(x, y)].symbol().to_owned())
|
||||
.collect();
|
||||
line.trim_end().to_owned()
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn boot_in_progress() -> BootState {
|
||||
let mut state = queued_boot(
|
||||
Phase::Host,
|
||||
1000 * MS,
|
||||
[
|
||||
waiting("graphical.target", &["multi-user.target"]),
|
||||
waiting(
|
||||
"multi-user.target",
|
||||
&["docker.service", "systemd-rfkill.service", "web.service"],
|
||||
),
|
||||
running("docker.service", &[], 9000 * MS),
|
||||
running("systemd-rfkill.service", &[], 6000 * MS),
|
||||
waiting("web.service", &[]),
|
||||
waiting("sysinit.target", &[]),
|
||||
waiting("nvidia-powerd.service", &[]),
|
||||
running("udev-settle.service", &[], 2000 * MS),
|
||||
],
|
||||
);
|
||||
state.finish_job(6, JobResult::Done, 4000 * MS);
|
||||
state.finish_job(7, JobResult::Failed, 5000 * MS);
|
||||
state.finish_job(8, JobResult::Done, 3500 * MS);
|
||||
state
|
||||
}
|
||||
|
||||
pub fn chain_boot() -> BootState {
|
||||
queued_boot(
|
||||
Phase::Host,
|
||||
Duration::ZERO,
|
||||
[
|
||||
waiting("graphical.target", &["network-wait.service"]),
|
||||
waiting("network-wait.service", &["network.target"]),
|
||||
waiting("network.target", &["network-manager.service"]),
|
||||
waiting("network-manager.service", &["dbus.service"]),
|
||||
waiting("dbus.service", &["udev-settle.service"]),
|
||||
running("udev-settle.service", &[], 1000 * MS),
|
||||
],
|
||||
)
|
||||
}
|
||||
|
||||
pub fn described_boot() -> BootState {
|
||||
queued_boot(
|
||||
Phase::Host,
|
||||
Duration::ZERO,
|
||||
[
|
||||
running(
|
||||
"multi-user.target",
|
||||
&["docker.service", "systemd-rfkill.service"],
|
||||
1000 * MS,
|
||||
)
|
||||
.described("Multi-User System"),
|
||||
running("docker.service", &[], 1000 * MS)
|
||||
.described("Docker Application Container Engine"),
|
||||
running("systemd-rfkill.service", &[], 1000 * MS)
|
||||
.described("Load/Save RF Kill Switch Status"),
|
||||
],
|
||||
)
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
pub const TEXT_ROW_HEIGHT: u16 = 1;
|
||||
pub const RULED_ROW_HEIGHT: u16 = 2;
|
||||
pub const PANEL_MINIMUM_HEIGHT: u16 = 4;
|
||||
pub const COLUMN_GAP_WIDTH: u16 = 1;
|
||||
pub const ANNOTATION_COLUMN_WIDTH: u16 = 9;
|
||||
pub const TIMELINE_LABEL_WIDTH: u16 = 28;
|
||||
pub const TEXT_GAP: &str = " ";
|
||||
pub const TEXT_INDENT: &str = " ";
|
||||
@@ -1,132 +0,0 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use ratatui::{
|
||||
buffer::Buffer,
|
||||
layout::Rect,
|
||||
style::Stylize,
|
||||
text::{Line, Span},
|
||||
widgets::{Paragraph, Widget},
|
||||
};
|
||||
|
||||
use super::{BRANCH, ELAPSED, LAST_BRANCH, screen_spacing::ANNOTATION_COLUMN_WIDTH, unit_count};
|
||||
use crate::{
|
||||
boot_model::BootState,
|
||||
screen_settings::{color_scheme::StageColors, font_glyphs::Glyphs},
|
||||
};
|
||||
|
||||
const SHUTDOWN_SUCCESSOR: &str = "systemd-shutdown";
|
||||
const AWAITING_MANAGER: &str = " · waiting for the system manager";
|
||||
|
||||
fn padded_phase_label(label: &str) -> String {
|
||||
format!(
|
||||
"{label:phase_width$}",
|
||||
phase_width = usize::from(ANNOTATION_COLUMN_WIDTH)
|
||||
)
|
||||
}
|
||||
|
||||
pub struct Stages<'a> {
|
||||
pub state: &'a BootState,
|
||||
pub now: Duration,
|
||||
pub colors: &'a StageColors,
|
||||
pub glyphs: &'a Glyphs,
|
||||
}
|
||||
|
||||
struct Conclusion<'a> {
|
||||
finished: &'static str,
|
||||
took: Duration,
|
||||
handed_to: &'a str,
|
||||
}
|
||||
|
||||
impl Stages<'_> {
|
||||
pub fn height(&self) -> u16 {
|
||||
u16::try_from(self.state.finished_stages.len()).unwrap_or(u16::MAX)
|
||||
}
|
||||
|
||||
fn conclusion(&self) -> Option<Conclusion<'_>> {
|
||||
if let Some(exited_at) = self.state.manager_exited_at {
|
||||
return Some(Conclusion {
|
||||
finished: "Shutdown",
|
||||
took: exited_at.saturating_sub(self.state.origin),
|
||||
handed_to: SHUTDOWN_SUCCESSOR,
|
||||
});
|
||||
}
|
||||
self.state.is_complete().then(|| Conclusion {
|
||||
finished: "Boot",
|
||||
took: self.now.saturating_sub(self.state.origin),
|
||||
handed_to: self
|
||||
.state
|
||||
.started_display_manager()
|
||||
.unwrap_or("the console"),
|
||||
})
|
||||
}
|
||||
|
||||
fn finished_phases(&self) -> impl Iterator<Item = Line<'static>> + '_ {
|
||||
self.state.finished_stages.iter().map(|stage| {
|
||||
Line::from(vec![
|
||||
BRANCH.fg(self.colors.branches),
|
||||
padded_phase_label(stage.label).fg(self.colors.finished_label),
|
||||
format!(
|
||||
"{} done in {}",
|
||||
self.glyphs.bead,
|
||||
ELAPSED.unsigned_duration_to_string(
|
||||
&stage.reached_at.saturating_sub(stage.started_at)
|
||||
)
|
||||
)
|
||||
.fg(self.colors.finished_time),
|
||||
format!(" · {}", unit_count(stage.finished_units)).fg(self.colors.unit_count),
|
||||
if stage.failed_units > 0 {
|
||||
format!(" · {} {} failed", self.glyphs.failed, stage.failed_units)
|
||||
.fg(self.colors.failed_count)
|
||||
.bold()
|
||||
} else {
|
||||
Span::default()
|
||||
},
|
||||
])
|
||||
})
|
||||
}
|
||||
|
||||
fn concluded_phase(&self, conclusion: &Conclusion) -> Line<'static> {
|
||||
Line::from(vec![
|
||||
LAST_BRANCH.fg(self.colors.branches),
|
||||
format!(
|
||||
"{} {} finished in {}",
|
||||
self.glyphs.bead,
|
||||
conclusion.finished,
|
||||
ELAPSED.unsigned_duration_to_string(&conclusion.took)
|
||||
)
|
||||
.fg(self.colors.finished_time)
|
||||
.bold(),
|
||||
format!(" · handing over to {}", conclusion.handed_to).fg(self.colors.current),
|
||||
])
|
||||
}
|
||||
|
||||
pub fn current_phase(&self) -> Line<'static> {
|
||||
if let Some(conclusion) = self.conclusion() {
|
||||
return self.concluded_phase(&conclusion);
|
||||
}
|
||||
let started_at = self
|
||||
.state
|
||||
.finished_stages
|
||||
.last()
|
||||
.map_or(self.state.origin, |stage| stage.reached_at);
|
||||
let elapsed = ELAPSED.unsigned_duration_to_string(&self.now.saturating_sub(started_at));
|
||||
Line::from(vec![
|
||||
LAST_BRANCH.fg(self.colors.branches),
|
||||
padded_phase_label(self.state.phase.label())
|
||||
.fg(self.colors.current)
|
||||
.bold(),
|
||||
elapsed.fg(self.colors.current),
|
||||
if self.state.awaits_manager() {
|
||||
AWAITING_MANAGER.fg(self.colors.current)
|
||||
} else {
|
||||
Span::default()
|
||||
},
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
impl Widget for Stages<'_> {
|
||||
fn render(self, area: Rect, buf: &mut Buffer) {
|
||||
Paragraph::new(self.finished_phases().collect::<Vec<_>>()).render(area, buf);
|
||||
}
|
||||
}
|
||||
@@ -1,220 +0,0 @@
|
||||
use std::iter::successors;
|
||||
|
||||
use crate::boot_model::{RowStatus, TreeNode, TreeRow, UnitKind, flatten_forest};
|
||||
|
||||
const MIN_FOLDED_LINKS: usize = 2;
|
||||
|
||||
pub fn rows_within_height(forest: &[TreeNode], budget: usize) -> Vec<TreeRow> {
|
||||
[forest.to_vec(), fold_forest(forest.to_vec())]
|
||||
.into_iter()
|
||||
.map(flatten_forest)
|
||||
.find(|rows| rows.len() <= budget)
|
||||
.unwrap_or_else(|| {
|
||||
let essential = flatten_forest(prune_to_running(forest.to_vec(), 0)).len();
|
||||
let spare = budget.saturating_sub(essential + 1);
|
||||
flatten_forest(fold_forest(prune_to_running(forest.to_vec(), spare)))
|
||||
})
|
||||
}
|
||||
|
||||
fn fold_forest(forest: Vec<TreeNode>) -> Vec<TreeNode> {
|
||||
forest.into_iter().map(|root| root.fold(false)).collect()
|
||||
}
|
||||
|
||||
fn prune_to_running(forest: Vec<TreeNode>, mut spare: usize) -> Vec<TreeNode> {
|
||||
forest
|
||||
.into_iter()
|
||||
.filter_map(|root| {
|
||||
let anchors_the_tree = root.row.kind == UnitKind::Target;
|
||||
root.keep_on_paths_to_running(anchors_the_tree, &mut spare)
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
impl TreeNode {
|
||||
fn leads_to_running(&self) -> bool {
|
||||
matches!(
|
||||
self.row.status,
|
||||
RowStatus::Running { .. } | RowStatus::Failed(_)
|
||||
) || self.children.iter().any(Self::leads_to_running)
|
||||
}
|
||||
|
||||
fn keep_on_paths_to_running(self, anchored: bool, spare: &mut usize) -> Option<Self> {
|
||||
if !anchored && !self.leads_to_running() {
|
||||
*spare = spare.checked_sub(1)?;
|
||||
}
|
||||
Some(Self {
|
||||
children: self
|
||||
.children
|
||||
.into_iter()
|
||||
.filter_map(|child| child.keep_on_paths_to_running(false, spare))
|
||||
.collect(),
|
||||
row: self.row,
|
||||
})
|
||||
}
|
||||
|
||||
fn is_chain_link(&self) -> bool {
|
||||
self.row.status == RowStatus::Waiting && self.children.len() == 1
|
||||
}
|
||||
|
||||
fn foldable_links(&self) -> usize {
|
||||
successors(Some(self), |cursor| {
|
||||
(cursor.is_chain_link() && cursor.children[0].is_chain_link())
|
||||
.then(|| &cursor.children[0])
|
||||
})
|
||||
.count()
|
||||
.saturating_sub(1)
|
||||
}
|
||||
|
||||
fn fold(mut self, may_absorb: bool) -> Self {
|
||||
let links = if may_absorb { self.foldable_links() } else { 0 };
|
||||
if links >= MIN_FOLDED_LINKS {
|
||||
let (chain, below) = (0..links).fold(
|
||||
(Vec::new(), self.children),
|
||||
|(mut chain, mut children), _| {
|
||||
let only = children.remove(0);
|
||||
chain.push(only.row.label);
|
||||
(chain, only.children)
|
||||
},
|
||||
);
|
||||
self.row.chain = chain;
|
||||
self.children = below;
|
||||
}
|
||||
self.children = self
|
||||
.children
|
||||
.into_iter()
|
||||
.map(|child| child.fold(true))
|
||||
.collect();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::time::Duration;
|
||||
|
||||
use super::*;
|
||||
use crate::{
|
||||
boot_model::{BootState, Phase},
|
||||
boot_test_fixtures::{
|
||||
activating, nested_boot_sample, queued_boot, running, tree_outline, waiting,
|
||||
},
|
||||
};
|
||||
|
||||
fn chain_state(waits: &[(&str, &[&str])], running_unit: &str) -> BootState {
|
||||
queued_boot(
|
||||
Phase::Host,
|
||||
Duration::ZERO,
|
||||
waits.iter().map(|(name, after)| {
|
||||
if *name == running_unit {
|
||||
running(name, after, Duration::ZERO)
|
||||
} else {
|
||||
waiting(name, after)
|
||||
}
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
fn fitted_outline(state: &BootState, budget: usize) -> Vec<String> {
|
||||
tree_outline(&rows_within_height(
|
||||
&state.waiting_forest(Duration::MAX),
|
||||
budget,
|
||||
))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn only_chains_leading_to_running_units_stay_in_view() {
|
||||
assert_eq!(
|
||||
fitted_outline(&nested_boot_sample(), 0),
|
||||
[
|
||||
"basic.target",
|
||||
"multi-user.target",
|
||||
" docker",
|
||||
" nm-wait",
|
||||
" nm",
|
||||
"graphical.target",
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn spare_rows_bring_back_waiting_units_under_kept_parents() {
|
||||
let state = chain_state(
|
||||
&[
|
||||
("root.target", &["a.service", "b.service"]),
|
||||
("a.service", &["a1.service"]),
|
||||
("a1.service", &["a2.service"]),
|
||||
("a2.service", &[]),
|
||||
("b.service", &[]),
|
||||
],
|
||||
"b.service",
|
||||
);
|
||||
assert_eq!(fitted_outline(&state, 4), ["root.target", " b", " a"]);
|
||||
assert_eq!(
|
||||
fitted_outline(&state, 5),
|
||||
["root.target", " b", " a", " a1", " a2"]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn single_child_waiting_chains_fold_into_one_row() {
|
||||
let state = chain_state(
|
||||
&[
|
||||
("root.target", &["a.service"]),
|
||||
("a.service", &["b.target"]),
|
||||
("b.target", &["c.service"]),
|
||||
("c.service", &["d.service"]),
|
||||
("d.service", &[]),
|
||||
],
|
||||
"d.service",
|
||||
);
|
||||
assert_eq!(
|
||||
fitted_outline(&state, 0),
|
||||
["root.target", " a > b.target > c", " d"]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn branches_and_short_chains_stay_unfolded() {
|
||||
let state = chain_state(
|
||||
&[
|
||||
("root.target", &["a.service"]),
|
||||
("a.service", &["b.service", "c.service"]),
|
||||
("b.service", &["d.service"]),
|
||||
("c.service", &[]),
|
||||
("d.service", &[]),
|
||||
],
|
||||
"d.service",
|
||||
);
|
||||
let mut both = chain_state(
|
||||
&[
|
||||
("root.target", &["a.service"]),
|
||||
("a.service", &["b.service", "c.service"]),
|
||||
("b.service", &[]),
|
||||
("c.service", &[]),
|
||||
],
|
||||
"b.service",
|
||||
);
|
||||
both.update_activity("c.service", activating(Duration::ZERO));
|
||||
assert_eq!(
|
||||
fitted_outline(&state, 0),
|
||||
["root.target", " a", " b", " d"]
|
||||
);
|
||||
assert_eq!(
|
||||
fitted_outline(&both, 0),
|
||||
["root.target", " a", " b", " c"]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn with_nothing_running_only_the_root_target_stays_in_view() {
|
||||
let state = queued_boot(
|
||||
Phase::Host,
|
||||
Duration::ZERO,
|
||||
[
|
||||
waiting("demo.target", &["idle.service"]),
|
||||
waiting("idle.service", &[]),
|
||||
],
|
||||
);
|
||||
assert_eq!(fitted_outline(&state, 0), ["demo.target"]);
|
||||
}
|
||||
}
|
||||
@@ -1,250 +0,0 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
|
||||
use super::screen_render_fixtures::{boot_in_progress, chain_boot, described_boot, render};
|
||||
use crate::{
|
||||
boot_model::{BootState, JobResult, Phase, UnitTimeouts},
|
||||
boot_test_fixtures::{MS, queue_unit, queued_boot, running, waiting},
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn failures_stay_in_the_stage_that_wanted_them() {
|
||||
let mut state = queued_boot(
|
||||
Phase::Host,
|
||||
Duration::ZERO,
|
||||
[
|
||||
waiting("multi-user.target", &["basic.target", "web.service"]),
|
||||
waiting("basic.target", &["flaky.service", "quick.service"]),
|
||||
waiting("flaky.service", &[]),
|
||||
waiting("quick.service", &[]),
|
||||
waiting("web.service", &[]),
|
||||
],
|
||||
);
|
||||
state.finish_job(3, JobResult::Failed, 1000 * MS);
|
||||
state.finish_job(4, JobResult::Done, 1000 * MS);
|
||||
state.finish_job(2, JobResult::Done, 1500 * MS);
|
||||
let lines = render(&state, 5000 * MS, 110, 24);
|
||||
let screen = lines.join("\n");
|
||||
assert!(lines[2].starts_with(" ├─ √ basic.target"), "{screen}");
|
||||
assert!(lines[3].starts_with(" │ └─ [×] flaky"), "{screen}");
|
||||
assert!(
|
||||
lines[4].starts_with(" └─ ◆ multi-user.target"),
|
||||
"{screen}"
|
||||
);
|
||||
assert!(lines[5].starts_with(" └─ [ ] web"), "{screen}");
|
||||
assert!(!screen.contains("quick"), "{screen}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn finished_units_linger_in_place_before_leaving() {
|
||||
let mut state = queued_boot(
|
||||
Phase::Host,
|
||||
Duration::ZERO,
|
||||
[
|
||||
waiting("multi-user.target", &["early.service", "late.service"]),
|
||||
running("early.service", &[], Duration::ZERO),
|
||||
running("late.service", &[], Duration::ZERO),
|
||||
],
|
||||
);
|
||||
state.finish_job(2, JobResult::Done, 3000 * MS);
|
||||
let lingering = render(&state, 4000 * MS, 110, 24);
|
||||
let screen = lingering.join("\n");
|
||||
assert!(lingering[3].starts_with(" ├─ [√] early"), "{screen}");
|
||||
assert!(lingering[4].starts_with(" └─ [|] late"), "{screen}");
|
||||
let gone = render(&state, 5500 * MS, 110, 24);
|
||||
let tree: Vec<&String> = gone
|
||||
.iter()
|
||||
.take_while(|line| !line.contains(" Timeline "))
|
||||
.collect();
|
||||
assert!(
|
||||
tree.iter().all(|line| !line.contains("early")),
|
||||
"{}",
|
||||
gone.join("\n")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn only_running_units_carry_a_timer() {
|
||||
let lines = render(&boot_in_progress(), 12_400 * MS, 110, 24);
|
||||
let screen = lines.join("\n");
|
||||
assert!(lines[2].ends_with("multi-user.target"), "{screen}");
|
||||
assert!(lines[3].ends_with("6.40s"), "{screen}");
|
||||
assert!(lines[5].ends_with("web"), "{screen}");
|
||||
}
|
||||
|
||||
fn timing_out_boot() -> BootState {
|
||||
let start_timeout = UnitTimeouts {
|
||||
start: Some(Duration::from_secs(90)),
|
||||
..UnitTimeouts::default()
|
||||
};
|
||||
queued_boot(
|
||||
Phase::Host,
|
||||
Duration::ZERO,
|
||||
[
|
||||
waiting(
|
||||
"multi-user.target",
|
||||
&["slow.service", "quick.service", "unlimited.service"],
|
||||
),
|
||||
running("slow.service", &[], 1000 * MS).timing_out(start_timeout),
|
||||
running("quick.service", &[], 5000 * MS).timing_out(start_timeout),
|
||||
running("unlimited.service", &[], 1000 * MS),
|
||||
],
|
||||
)
|
||||
}
|
||||
|
||||
fn line_with<'a>(lines: &'a [String], text: &str) -> &'a str {
|
||||
lines
|
||||
.iter()
|
||||
.find(|line| line.contains(text))
|
||||
.unwrap_or_else(|| panic!("{text} missing\n{}", lines.join("\n")))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn slow_runs_show_their_timeout_in_a_column() {
|
||||
let lines = render(&timing_out_boot(), 7400 * MS, 110, 24);
|
||||
let screen = lines.join("\n");
|
||||
assert!(
|
||||
line_with(&lines, "Running").ends_with("Timeout"),
|
||||
"{screen}"
|
||||
);
|
||||
assert!(
|
||||
line_with(&lines, "slow").ends_with("6.40s 1m30s"),
|
||||
"{screen}"
|
||||
);
|
||||
assert!(line_with(&lines, "quick").ends_with("2.40s"), "{screen}");
|
||||
assert!(
|
||||
line_with(&lines, "unlimited").ends_with("6.40s"),
|
||||
"{screen}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_timeout_column_waits_for_a_slow_run() {
|
||||
let lines = render(&timing_out_boot(), 4000 * MS, 110, 24);
|
||||
assert!(
|
||||
lines.iter().all(|line| !line.contains("Timeout")),
|
||||
"{}",
|
||||
lines.join("\n")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn narrow_screens_keep_the_timeout() {
|
||||
let lines = render(&timing_out_boot(), 7400 * MS, 50, 24);
|
||||
assert!(
|
||||
line_with(&lines, "slow").ends_with("1m30s"),
|
||||
"{}",
|
||||
lines.join("\n")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn chains_stay_unfolded_while_they_fit() {
|
||||
let lines = render(&chain_boot(), 5000 * MS, 110, 24);
|
||||
let screen = lines.join("\n");
|
||||
assert!(
|
||||
lines[3].starts_with(" └─ [ ] network-wait"),
|
||||
"{screen}"
|
||||
);
|
||||
assert!(
|
||||
lines[4].starts_with(" └─ network.target"),
|
||||
"{screen}"
|
||||
);
|
||||
assert!(
|
||||
lines[7].starts_with(" └─ [-] udev-settle"),
|
||||
"{screen}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn chains_fold_when_short_and_shorten_to_their_ends_when_narrow() {
|
||||
let short = render(&chain_boot(), 5000 * MS, 110, 9);
|
||||
assert!(
|
||||
short[3].starts_with(" └─ [ ] network-wait ─ network.target ─ network-manager ─ dbus"),
|
||||
"{}",
|
||||
short.join("\n")
|
||||
);
|
||||
assert!(
|
||||
short[4].starts_with(" └─ [-] udev-settle"),
|
||||
"{}",
|
||||
short.join("\n")
|
||||
);
|
||||
let narrow = render(&chain_boot(), 5000 * MS, 46, 8);
|
||||
assert!(
|
||||
narrow[3].starts_with(" └─ [ ] network-wait ─ … ─ dbus"),
|
||||
"{}",
|
||||
narrow.join("\n")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn descriptions_line_up_in_a_column() {
|
||||
let lines = render(&described_boot(), 3000 * MS, 110, 24);
|
||||
let screen = lines.join("\n");
|
||||
let column_of = |text: &str| {
|
||||
lines
|
||||
.iter()
|
||||
.find_map(|line| line.find(text).map(|at| line[..at].width()))
|
||||
.unwrap_or_else(|| panic!("{text} missing\n{screen}"))
|
||||
};
|
||||
assert_eq!(column_of("Multi-User System"), column_of("Description"));
|
||||
assert_eq!(
|
||||
column_of("Multi-User System"),
|
||||
column_of("Docker Application")
|
||||
);
|
||||
assert_eq!(
|
||||
column_of("Multi-User System"),
|
||||
column_of("Load/Save RF Kill")
|
||||
);
|
||||
assert!(column_of("Multi-User System") > column_of("systemd-rfkill"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn non_service_units_carry_their_kind() {
|
||||
let mut state = described_boot();
|
||||
queue_unit(
|
||||
&mut state,
|
||||
9,
|
||||
running("docker.socket", &[], 1000 * MS).described("Docker Socket for the API"),
|
||||
Duration::ZERO,
|
||||
);
|
||||
let lines = render(&state, 3000 * MS, 110, 24);
|
||||
let screen = lines.join("\n");
|
||||
let socket_row = lines
|
||||
.iter()
|
||||
.find(|line| line.contains("Docker Socket"))
|
||||
.unwrap_or_else(|| panic!("{screen}"));
|
||||
assert!(socket_row.contains("[-] docker "), "{screen}");
|
||||
assert!(socket_row.contains(" Socket "), "{screen}");
|
||||
assert!(
|
||||
render(&described_boot(), 3000 * MS, 110, 24)
|
||||
.iter()
|
||||
.all(|line| !line.contains(" Socket ")),
|
||||
"{screen}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn narrow_screens_keep_names_and_drop_descriptions() {
|
||||
let lines = render(&described_boot(), 3000 * MS, 40, 24);
|
||||
let screen = lines.join("\n");
|
||||
assert!(screen.contains("systemd-rfkill"), "{screen}");
|
||||
assert!(!screen.contains("Docker"), "{screen}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn overflowing_trees_are_cut_with_a_count() {
|
||||
let names: Vec<String> = (0..30).map(|id| format!("unit{id:02}.service")).collect();
|
||||
let state = queued_boot(
|
||||
Phase::Host,
|
||||
Duration::ZERO,
|
||||
names.iter().map(|name| waiting(name, &[])),
|
||||
);
|
||||
let lines = render(&state, 1000 * MS, 110, 20);
|
||||
assert!(
|
||||
lines.iter().any(|line| line.starts_with(" … ")),
|
||||
"{}",
|
||||
lines.join("\n")
|
||||
);
|
||||
}
|
||||
@@ -1,421 +0,0 @@
|
||||
use std::{iter::once, time::Duration};
|
||||
|
||||
use ratatui::{
|
||||
buffer::Buffer,
|
||||
layout::{
|
||||
Constraint::{self, Fill, Length},
|
||||
Layout, Rect,
|
||||
},
|
||||
style::{Style, Stylize},
|
||||
text::{Line, Span},
|
||||
widgets::{Row, Table, Widget},
|
||||
};
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
|
||||
use super::{
|
||||
BRANCH, ENDED_TRUNK, LAST_BRANCH, PASSING_TRUNK, RUNNING_ELAPSED, WHOLE_UNITS, fit_width,
|
||||
screen_spacing::{ANNOTATION_COLUMN_WIDTH, COLUMN_GAP_WIDTH, TEXT_ROW_HEIGHT},
|
||||
};
|
||||
use crate::{
|
||||
boot_model::{RowStatus, TreeRow, UnitKind},
|
||||
screen_settings::{color_scheme::TreeColors, font_glyphs::Glyphs},
|
||||
};
|
||||
|
||||
const SPINNER: [char; 4] = ['|', '/', '-', '\\'];
|
||||
const SPINNER_STEP: Duration = Duration::from_millis(100);
|
||||
const LABEL_SHARE: u16 = 3;
|
||||
const DESCRIPTION_SHARE: u16 = 2;
|
||||
const SHOW_TIMEOUT_AFTER: Duration = Duration::from_secs(5);
|
||||
const TIMEOUT_HEADER: &str = "Timeout";
|
||||
|
||||
struct RunTimeout {
|
||||
limit: Duration,
|
||||
exceeded: bool,
|
||||
}
|
||||
|
||||
pub struct UnitTree<'a> {
|
||||
pub phase: Line<'static>,
|
||||
pub rows: &'a [TreeRow],
|
||||
pub hidden: usize,
|
||||
pub now: Duration,
|
||||
pub hide_runs_shorter_than: Duration,
|
||||
pub colors: &'a TreeColors,
|
||||
pub glyphs: &'a Glyphs,
|
||||
}
|
||||
|
||||
struct Columns {
|
||||
constraints: Vec<Constraint>,
|
||||
label: u16,
|
||||
description: u16,
|
||||
shows_annotations: bool,
|
||||
shows_timeout: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||
enum Stage {
|
||||
Reached,
|
||||
Current,
|
||||
Upcoming,
|
||||
Inside,
|
||||
}
|
||||
|
||||
fn opens_a_stage(row: &TreeRow) -> bool {
|
||||
row.depth == 0 && row.kind == UnitKind::Target
|
||||
}
|
||||
|
||||
fn spinner_at(now: Duration) -> char {
|
||||
let steps = now.as_millis() / SPINNER_STEP.as_millis();
|
||||
SPINNER[usize::try_from(steps % 4).unwrap_or_default()]
|
||||
}
|
||||
|
||||
fn solved_columns(width: u16, shows_annotations: bool, shows_timeout: bool) -> Columns {
|
||||
let leading = if shows_annotations {
|
||||
vec![
|
||||
Fill(LABEL_SHARE),
|
||||
Length(ANNOTATION_COLUMN_WIDTH),
|
||||
Fill(DESCRIPTION_SHARE),
|
||||
]
|
||||
} else {
|
||||
vec![Fill(1)]
|
||||
};
|
||||
let constraints: Vec<Constraint> = leading
|
||||
.into_iter()
|
||||
.chain(once(Length(ANNOTATION_COLUMN_WIDTH)))
|
||||
.chain(shows_timeout.then_some(Length(ANNOTATION_COLUMN_WIDTH)))
|
||||
.collect();
|
||||
let solved = Layout::horizontal(constraints.clone())
|
||||
.spacing(COLUMN_GAP_WIDTH)
|
||||
.split(Rect::new(0, 0, width, TEXT_ROW_HEIGHT));
|
||||
Columns {
|
||||
label: solved[0].width,
|
||||
description: if shows_annotations {
|
||||
solved[2].width
|
||||
} else {
|
||||
0
|
||||
},
|
||||
constraints,
|
||||
shows_annotations,
|
||||
shows_timeout,
|
||||
}
|
||||
}
|
||||
|
||||
impl UnitTree<'_> {
|
||||
pub fn height_of(rows: usize, hidden: usize) -> u16 {
|
||||
u16::try_from(rows + usize::from(hidden > 0))
|
||||
.unwrap_or(u16::MAX)
|
||||
.saturating_add(TEXT_ROW_HEIGHT)
|
||||
}
|
||||
|
||||
pub fn height(&self) -> u16 {
|
||||
Self::height_of(self.rows.len(), self.hidden)
|
||||
}
|
||||
|
||||
fn phase_fits_its_column(&self, columns: &Columns) -> bool {
|
||||
self.phase.width() <= usize::from(columns.label)
|
||||
}
|
||||
|
||||
fn header(&self, columns: &Columns) -> Row<'static> {
|
||||
if !self.phase_fits_its_column(columns) {
|
||||
return Row::default().height(TEXT_ROW_HEIGHT);
|
||||
}
|
||||
let name = |text: &'static str| Line::from(text).fg(self.colors.columns);
|
||||
Row::new(columns.shown([
|
||||
self.phase.clone(),
|
||||
name("Kind"),
|
||||
name("Description"),
|
||||
name("Running").right_aligned(),
|
||||
name(TIMEOUT_HEADER).right_aligned(),
|
||||
]))
|
||||
}
|
||||
|
||||
fn run_timeout(&self, row: &TreeRow) -> Option<RunTimeout> {
|
||||
let RowStatus::Running {
|
||||
since,
|
||||
deadline: Some(deadline),
|
||||
..
|
||||
} = row.status
|
||||
else {
|
||||
return None;
|
||||
};
|
||||
let elapsed = self.now.saturating_sub(since);
|
||||
let limit = deadline.saturating_sub(since);
|
||||
(elapsed >= SHOW_TIMEOUT_AFTER).then_some(RunTimeout {
|
||||
limit,
|
||||
exceeded: elapsed >= limit,
|
||||
})
|
||||
}
|
||||
|
||||
fn timeout_cell(&self, row: &TreeRow) -> Line<'static> {
|
||||
self.run_timeout(row)
|
||||
.map_or_else(Line::default, |timeout| {
|
||||
let color = if timeout.exceeded {
|
||||
self.colors.failed_unit
|
||||
} else {
|
||||
self.colors.columns
|
||||
};
|
||||
Line::from(WHOLE_UNITS.unsigned_duration_to_string(&timeout.limit)).fg(color)
|
||||
})
|
||||
.right_aligned()
|
||||
}
|
||||
|
||||
fn stages(&self) -> impl Iterator<Item = Stage> + '_ {
|
||||
let current = self
|
||||
.rows
|
||||
.iter()
|
||||
.position(|row| opens_a_stage(row) && row.status != RowStatus::Done);
|
||||
self.rows.iter().enumerate().map(move |(index, row)| {
|
||||
if Some(index) == current {
|
||||
Stage::Current
|
||||
} else if opens_a_stage(row) && row.status == RowStatus::Done {
|
||||
Stage::Reached
|
||||
} else if opens_a_stage(row) {
|
||||
Stage::Upcoming
|
||||
} else {
|
||||
Stage::Inside
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn label_style(&self, row: &TreeRow, stage: Stage) -> Style {
|
||||
match stage {
|
||||
Stage::Current => Style::from(self.colors.current_stage).bold(),
|
||||
Stage::Reached => self.colors.reached_stage.into(),
|
||||
Stage::Upcoming | Stage::Inside => self.unit_label_style(row),
|
||||
}
|
||||
}
|
||||
|
||||
fn unit_label_style(&self, row: &TreeRow) -> Style {
|
||||
match row.status {
|
||||
RowStatus::Failed(kind) if kind.has_own_cause() => {
|
||||
Style::from(self.colors.failed_unit).bold()
|
||||
}
|
||||
RowStatus::Failed(_) => Style::from(self.colors.failed_unit).dim(),
|
||||
_ if row.kind == UnitKind::Target => self.colors.target.into(),
|
||||
RowStatus::Running { .. } => self.colors.running_unit.into(),
|
||||
RowStatus::Waiting => self.colors.waiting_unit.into(),
|
||||
RowStatus::Done => self.colors.finished_unit.into(),
|
||||
}
|
||||
}
|
||||
|
||||
fn status_marker(&self, row: &TreeRow, stage: Stage) -> Span<'static> {
|
||||
match stage {
|
||||
Stage::Current => {
|
||||
format!("{} ", self.glyphs.stage_current).fg(self.colors.current_stage)
|
||||
}
|
||||
Stage::Upcoming => format!("{} ", self.glyphs.stage_upcoming).fg(self.colors.target),
|
||||
Stage::Reached => format!("{} ", self.glyphs.done).fg(self.colors.reached_stage),
|
||||
Stage::Inside => self.unit_marker(row),
|
||||
}
|
||||
}
|
||||
|
||||
fn unit_marker(&self, row: &TreeRow) -> Span<'static> {
|
||||
match row.status {
|
||||
RowStatus::Failed(_) => {
|
||||
format!("[{}] ", self.glyphs.failed).fg(self.colors.failed_unit)
|
||||
}
|
||||
_ if row.kind == UnitKind::Target => Span::default(),
|
||||
RowStatus::Running { .. } => {
|
||||
format!("[{}] ", spinner_at(self.now)).fg(self.colors.running_marker)
|
||||
}
|
||||
RowStatus::Waiting => "[ ] ".fg(self.colors.waiting_unit),
|
||||
RowStatus::Done => format!("[{}] ", self.glyphs.done).fg(self.colors.finished_marker),
|
||||
}
|
||||
}
|
||||
|
||||
fn chained_label(&self, row: &TreeRow, room: usize) -> String {
|
||||
let link = format!(" {} ", self.glyphs.chain_link);
|
||||
let full: String = once(row.label.as_str())
|
||||
.chain(row.chain.iter().map(String::as_str))
|
||||
.collect::<Vec<_>>()
|
||||
.join(&link);
|
||||
let label = match row.chain.as_slice() {
|
||||
[_, .., last] if full.width() > room => {
|
||||
format!("{}{link}{}{link}{last}", row.label, self.glyphs.ellipsis)
|
||||
}
|
||||
_ => full,
|
||||
};
|
||||
fit_width(&label, room, self.glyphs.ellipsis)
|
||||
}
|
||||
|
||||
fn columns(&self, width: u16) -> Columns {
|
||||
let shows_timeout = self.rows.iter().any(|row| self.run_timeout(row).is_some());
|
||||
let has_annotated_rows = self.rows.iter().any(|row| {
|
||||
row.chain.is_empty() && !(row.description.is_none() && row.kind.tag().is_none())
|
||||
});
|
||||
let annotated = solved_columns(width, true, shows_timeout);
|
||||
if has_annotated_rows && annotated.description >= ANNOTATION_COLUMN_WIDTH {
|
||||
annotated
|
||||
} else {
|
||||
solved_columns(width, false, shows_timeout)
|
||||
}
|
||||
}
|
||||
|
||||
fn row(&self, row: &TreeRow, stage: Stage, prefix: String, columns: &Columns) -> Row<'static> {
|
||||
let marker = self.status_marker(row, stage);
|
||||
let room = usize::from(columns.label).saturating_sub(prefix.width() + marker.width());
|
||||
let annotation = |text: &str, width: u16| {
|
||||
if row.chain.is_empty() {
|
||||
fit_width(text, usize::from(width), self.glyphs.ellipsis)
|
||||
} else {
|
||||
String::new()
|
||||
}
|
||||
};
|
||||
let timer = match row.status {
|
||||
RowStatus::Running { since, .. }
|
||||
if self.now.saturating_sub(since) >= self.hide_runs_shorter_than =>
|
||||
{
|
||||
RUNNING_ELAPSED.unsigned_duration_to_string(&self.now.saturating_sub(since))
|
||||
}
|
||||
_ => String::new(),
|
||||
};
|
||||
let style = self.label_style(row, stage);
|
||||
Row::new(
|
||||
columns.shown([
|
||||
Line::from(vec![
|
||||
prefix.fg(self.colors.branches),
|
||||
marker,
|
||||
Span::styled(self.chained_label(row, room), style),
|
||||
]),
|
||||
Line::from(annotation(
|
||||
row.kind.tag().unwrap_or_default(),
|
||||
ANNOTATION_COLUMN_WIDTH,
|
||||
))
|
||||
.fg(self.colors.columns),
|
||||
Line::from(annotation(
|
||||
row.description.as_deref().unwrap_or_default(),
|
||||
columns.description,
|
||||
))
|
||||
.fg(self.colors.columns),
|
||||
Line::from(timer).style(style).right_aligned(),
|
||||
self.timeout_cell(row),
|
||||
]),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl Columns {
|
||||
fn shown<T>(&self, cells: [T; 5]) -> impl Iterator<Item = T> {
|
||||
let present = [
|
||||
true,
|
||||
self.shows_annotations,
|
||||
self.shows_annotations,
|
||||
true,
|
||||
self.shows_timeout,
|
||||
];
|
||||
cells
|
||||
.into_iter()
|
||||
.zip(present)
|
||||
.filter_map(|(cell, present)| present.then_some(cell))
|
||||
}
|
||||
}
|
||||
|
||||
impl Widget for UnitTree<'_> {
|
||||
fn render(self, area: Rect, buf: &mut Buffer) {
|
||||
let capacity = usize::from(area.height.saturating_sub(TEXT_ROW_HEIGHT));
|
||||
let shown = if usize::from(self.height() - TEXT_ROW_HEIGHT) > capacity {
|
||||
capacity.saturating_sub(1).min(self.rows.len())
|
||||
} else {
|
||||
self.rows.len()
|
||||
};
|
||||
let hidden = self.rows.len() - shown + self.hidden;
|
||||
let overflow = (hidden > 0).then(|| {
|
||||
Row::new([
|
||||
format!("{ENDED_TRUNK}{} {hidden} more", self.glyphs.ellipsis)
|
||||
.fg(self.colors.overflow),
|
||||
])
|
||||
});
|
||||
let columns = self.columns(area.width);
|
||||
let table = Table::new(
|
||||
self.rows
|
||||
.iter()
|
||||
.zip(self.stages())
|
||||
.zip(tree_prefixes(self.rows))
|
||||
.take(shown)
|
||||
.map(|((row, stage), prefix)| self.row(row, stage, prefix, &columns)),
|
||||
columns.constraints.clone(),
|
||||
)
|
||||
.column_spacing(COLUMN_GAP_WIDTH)
|
||||
.header(self.header(&columns));
|
||||
match overflow {
|
||||
Some(overflow_row) => table.footer(overflow_row),
|
||||
None => table,
|
||||
}
|
||||
.render(area, buf);
|
||||
if !self.phase_fits_its_column(&columns) {
|
||||
let [phase_row, _] = area.layout(&Layout::vertical([Length(TEXT_ROW_HEIGHT), Fill(1)]));
|
||||
self.phase.render(phase_row, buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn tree_prefixes(rows: &[TreeRow]) -> Vec<String> {
|
||||
let is_last = rows
|
||||
.iter()
|
||||
.rev()
|
||||
.scan(Vec::<bool>::new(), |later_sibling, row| {
|
||||
let last = !later_sibling.get(row.depth).copied().unwrap_or(false);
|
||||
later_sibling.resize(row.depth + 1, false);
|
||||
later_sibling[row.depth] = true;
|
||||
Some(last)
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.into_iter()
|
||||
.rev();
|
||||
rows.iter()
|
||||
.zip(is_last)
|
||||
.scan(Vec::<&str>::new(), |trunks, (row, last)| {
|
||||
trunks.truncate(row.depth);
|
||||
let connector = if last { LAST_BRANCH } else { BRANCH };
|
||||
let prefix = once(ENDED_TRUNK)
|
||||
.chain(trunks.iter().copied())
|
||||
.chain(once(connector))
|
||||
.collect();
|
||||
trunks.push(if last { ENDED_TRUNK } else { PASSING_TRUNK });
|
||||
Some(prefix)
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn the_spinner_turns_once_per_step_whatever_the_frame_rate() {
|
||||
let turned: String = (0..5)
|
||||
.map(|step| spinner_at(SPINNER_STEP * step + Duration::from_millis(16)))
|
||||
.collect();
|
||||
assert_eq!(turned, "|/-\\|");
|
||||
assert_eq!(
|
||||
spinner_at(Duration::from_millis(99)),
|
||||
spinner_at(Duration::ZERO)
|
||||
);
|
||||
}
|
||||
|
||||
fn at_depth(depth: usize) -> TreeRow {
|
||||
TreeRow {
|
||||
depth,
|
||||
label: String::new(),
|
||||
description: None,
|
||||
kind: UnitKind::Service,
|
||||
status: RowStatus::Waiting,
|
||||
chain: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn prefixes_close_each_branch_at_its_last_sibling() {
|
||||
let rows: Vec<TreeRow> = [0, 0, 1, 1, 2, 0].into_iter().map(at_depth).collect();
|
||||
assert_eq!(
|
||||
tree_prefixes(&rows),
|
||||
[
|
||||
" ├─ ",
|
||||
" ├─ ",
|
||||
" │ ├─ ",
|
||||
" │ └─ ",
|
||||
" │ └─ ",
|
||||
" └─ ",
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
pub mod ask_password;
|
||||
pub mod console_palette;
|
||||
pub mod console_takeover;
|
||||
pub mod live_desk;
|
||||
pub mod passphrase_input;
|
||||
pub mod resume_console;
|
||||
pub mod stream_sources;
|
||||
pub mod watch_loop;
|
||||
pub mod watch_screen;
|
||||
@@ -1,295 +0,0 @@
|
||||
use std::{
|
||||
fs, io, iter,
|
||||
os::{
|
||||
fd::{AsRawFd, OwnedFd, RawFd},
|
||||
unix::net::UnixDatagram,
|
||||
},
|
||||
path::{Path, PathBuf},
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use crossterm::event::Event;
|
||||
use rustix::{
|
||||
fs::inotify::{self, CreateFlags, WatchFlags},
|
||||
io::read,
|
||||
process::{Pid, test_kill_process},
|
||||
};
|
||||
use zeroize::Zeroizing;
|
||||
|
||||
use crate::{
|
||||
boot_view::PasswordPrompt, console_session::passphrase_input,
|
||||
systemd_link::monotonic_clock::monotonic_now,
|
||||
};
|
||||
|
||||
const REQUESTS: &str = "/run/systemd/ask-password";
|
||||
const REQUEST_PREFIX: &str = "ask.";
|
||||
const ASK_SECTION: &str = "[Ask]";
|
||||
const INOTIFY_BUFFER: usize = 4096;
|
||||
|
||||
pub struct RequestWatch {
|
||||
inotify: OwnedFd,
|
||||
}
|
||||
|
||||
impl RequestWatch {
|
||||
#[must_use]
|
||||
pub fn open() -> Option<Self> {
|
||||
fs::create_dir_all(REQUESTS).ok()?;
|
||||
let inotify = inotify::init(CreateFlags::CLOEXEC | CreateFlags::NONBLOCK).ok()?;
|
||||
inotify::add_watch(
|
||||
&inotify,
|
||||
REQUESTS,
|
||||
WatchFlags::CLOSE_WRITE
|
||||
| WatchFlags::MOVED_TO
|
||||
| WatchFlags::MOVED_FROM
|
||||
| WatchFlags::DELETE
|
||||
| WatchFlags::ONLYDIR,
|
||||
)
|
||||
.ok()?;
|
||||
Some(Self { inotify })
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn changed(&self) -> bool {
|
||||
let mut events = [0_u8; INOTIFY_BUFFER];
|
||||
iter::from_fn(|| {
|
||||
read(&self.inotify, &mut events)
|
||||
.ok()
|
||||
.filter(|read| *read > 0)
|
||||
})
|
||||
.count()
|
||||
> 0
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRawFd for RequestWatch {
|
||||
fn as_raw_fd(&self) -> RawFd {
|
||||
self.inotify.as_raw_fd()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct PasswordRequest {
|
||||
pub file: PathBuf,
|
||||
pub message: String,
|
||||
socket: PathBuf,
|
||||
echo: bool,
|
||||
silent: bool,
|
||||
not_after: Option<Duration>,
|
||||
asker: Option<Pid>,
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn requested() -> bool {
|
||||
!request_files().is_empty()
|
||||
}
|
||||
|
||||
fn request_files() -> Vec<PathBuf> {
|
||||
let mut files: Vec<PathBuf> = fs::read_dir(REQUESTS)
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.flatten()
|
||||
.filter(|entry| {
|
||||
entry
|
||||
.file_name()
|
||||
.to_string_lossy()
|
||||
.starts_with(REQUEST_PREFIX)
|
||||
})
|
||||
.map(|entry| entry.path())
|
||||
.collect();
|
||||
files.sort();
|
||||
files
|
||||
}
|
||||
|
||||
impl PasswordRequest {
|
||||
fn read(file: &Path) -> Option<Self> {
|
||||
Self::parse(file, &fs::read_to_string(file).ok()?)
|
||||
}
|
||||
|
||||
fn parse(file: &Path, text: &str) -> Option<Self> {
|
||||
let fields: Vec<(&str, &str)> = text
|
||||
.lines()
|
||||
.map(str::trim)
|
||||
.skip_while(|line| *line != ASK_SECTION)
|
||||
.skip(1)
|
||||
.take_while(|line| !line.starts_with('['))
|
||||
.filter_map(|line| line.split_once('='))
|
||||
.collect();
|
||||
let field = |key: &str| {
|
||||
fields
|
||||
.iter()
|
||||
.find(|(name, _)| *name == key)
|
||||
.map(|(_, value)| *value)
|
||||
};
|
||||
let flag = |key: &str| field(key).is_some_and(is_true);
|
||||
Some(Self {
|
||||
file: file.to_owned(),
|
||||
message: field("Message").unwrap_or_default().to_owned(),
|
||||
socket: PathBuf::from(field("Socket")?),
|
||||
echo: flag("Echo"),
|
||||
silent: flag("Silent"),
|
||||
not_after: field("NotAfter")
|
||||
.and_then(|value| value.parse().ok())
|
||||
.filter(|micros| *micros > 0)
|
||||
.map(Duration::from_micros),
|
||||
asker: field("PID")
|
||||
.and_then(|value| value.parse().ok())
|
||||
.and_then(Pid::from_raw),
|
||||
})
|
||||
}
|
||||
|
||||
fn is_awaited(&self) -> bool {
|
||||
self.not_after
|
||||
.is_none_or(|deadline| monotonic_now() <= deadline)
|
||||
&& self
|
||||
.asker
|
||||
.is_none_or(|asker| test_kill_process(asker).is_ok())
|
||||
}
|
||||
|
||||
fn answer(&self, password: &str) -> io::Result<()> {
|
||||
let mut packet = Zeroizing::new(Vec::with_capacity(password.len() + 1));
|
||||
packet.push(b'+');
|
||||
packet.extend_from_slice(password.as_bytes());
|
||||
UnixDatagram::unbound()?.send_to(&packet, &self.socket)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn is_true(value: &str) -> bool {
|
||||
matches!(
|
||||
value.to_ascii_lowercase().as_str(),
|
||||
"1" | "yes" | "y" | "true" | "t" | "on"
|
||||
)
|
||||
}
|
||||
|
||||
pub struct PasswordEntry {
|
||||
request: PasswordRequest,
|
||||
typed: Zeroizing<String>,
|
||||
sent: bool,
|
||||
}
|
||||
|
||||
impl PasswordEntry {
|
||||
pub fn follow(current: Option<Self>, requests_changed: bool) -> Option<Self> {
|
||||
match current {
|
||||
Some(entry) if entry.is_live(requests_changed) => return Some(entry),
|
||||
None if !requests_changed => return None,
|
||||
_ => {}
|
||||
}
|
||||
let entry = request_files()
|
||||
.iter()
|
||||
.filter_map(|file| PasswordRequest::read(file))
|
||||
.find_map(Self::open)?;
|
||||
eprintln!(
|
||||
"bootvine: asking for a password: {}",
|
||||
entry.request.file.display()
|
||||
);
|
||||
Some(entry)
|
||||
}
|
||||
|
||||
fn open(request: PasswordRequest) -> Option<Self> {
|
||||
if !request.is_awaited() {
|
||||
return None;
|
||||
}
|
||||
Some(Self {
|
||||
request,
|
||||
typed: passphrase_input::empty(),
|
||||
sent: false,
|
||||
})
|
||||
}
|
||||
|
||||
fn is_live(&self, requests_changed: bool) -> bool {
|
||||
self.request.is_awaited() && (!requests_changed || self.request.file.exists())
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn prompt(&self) -> PasswordPrompt<'_> {
|
||||
let input = if self.request.silent {
|
||||
String::new()
|
||||
} else if self.request.echo {
|
||||
self.typed.to_string()
|
||||
} else {
|
||||
passphrase_input::masked(&self.typed)
|
||||
};
|
||||
PasswordPrompt {
|
||||
message: &self.request.message,
|
||||
hint: None,
|
||||
input,
|
||||
sent: self.sent,
|
||||
rejected: false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn type_key(&mut self, event: &Event) -> io::Result<()> {
|
||||
if self.sent {
|
||||
return Ok(());
|
||||
}
|
||||
let Some(submitted) = passphrase_input::type_key(&mut self.typed, event) else {
|
||||
return Ok(());
|
||||
};
|
||||
self.request.answer(&submitted)?;
|
||||
self.sent = true;
|
||||
eprintln!("bootvine: answered a password prompt");
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crossterm::event::{KeyCode, KeyEvent};
|
||||
|
||||
use super::*;
|
||||
|
||||
const CRYPTSETUP_ASK: &str = concat!(
|
||||
"[Ask]\n",
|
||||
"PID=1\n",
|
||||
"Socket=/run/systemd/ask-password/sck.1\n",
|
||||
"AcceptCached=1\n",
|
||||
"Echo=0\n",
|
||||
"NotAfter=0\n",
|
||||
"Message=Please enter passphrase for disk secret:\n",
|
||||
"Icon=drive-harddisk\n",
|
||||
"Id=cryptsetup:/dev/vdb\n",
|
||||
);
|
||||
|
||||
#[test]
|
||||
fn reads_what_cryptsetup_asks() {
|
||||
let request = PasswordRequest::parse(Path::new("ask.x"), CRYPTSETUP_ASK).expect("parsed");
|
||||
assert_eq!(
|
||||
request,
|
||||
PasswordRequest {
|
||||
file: PathBuf::from("ask.x"),
|
||||
message: "Please enter passphrase for disk secret:".to_owned(),
|
||||
socket: PathBuf::from("/run/systemd/ask-password/sck.1"),
|
||||
echo: false,
|
||||
silent: false,
|
||||
not_after: None,
|
||||
asker: Pid::from_raw(1),
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ignores_requests_without_a_socket() {
|
||||
assert_eq!(
|
||||
PasswordRequest::parse(Path::new("ask.x"), "[Ask]\nMessage=hi\n"),
|
||||
None
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hides_what_is_typed() {
|
||||
let mut entry = PasswordEntry {
|
||||
request: PasswordRequest::parse(Path::new("ask.x"), CRYPTSETUP_ASK).expect("parsed"),
|
||||
typed: passphrase_input::empty(),
|
||||
sent: false,
|
||||
};
|
||||
"secret".chars().for_each(|character| {
|
||||
entry
|
||||
.type_key(&Event::Key(KeyEvent::from(KeyCode::Char(character))))
|
||||
.expect("typed");
|
||||
});
|
||||
entry
|
||||
.type_key(&Event::Key(KeyEvent::from(KeyCode::Backspace)))
|
||||
.expect("erased");
|
||||
assert_eq!(entry.prompt().input, "*****");
|
||||
}
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
use ratatui::{
|
||||
buffer::Buffer,
|
||||
style::{Color, Modifier},
|
||||
};
|
||||
|
||||
use crate::screen_settings::font_glyphs::Glyphs;
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
pub enum ConsolePalette {
|
||||
#[default]
|
||||
Terminal,
|
||||
SixteenColorVt,
|
||||
EightColorVt,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
pub struct ConsoleLook {
|
||||
pub glyphs: Glyphs,
|
||||
pub palette: ConsolePalette,
|
||||
}
|
||||
|
||||
impl ConsolePalette {
|
||||
pub fn fit_frame(self, frame: &mut Buffer) {
|
||||
if self == Self::Terminal {
|
||||
return;
|
||||
}
|
||||
frame.content.iter_mut().for_each(|cell| {
|
||||
cell.modifier.remove(Modifier::BOLD);
|
||||
if self == Self::EightColorVt {
|
||||
cell.fg = without_brightness(cell.fg);
|
||||
cell.bg = without_brightness(cell.bg);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
fn without_brightness(color: Color) -> Color {
|
||||
match color {
|
||||
Color::DarkGray | Color::White => Color::Gray,
|
||||
Color::LightRed => Color::Red,
|
||||
Color::LightGreen => Color::Green,
|
||||
Color::LightYellow => Color::Yellow,
|
||||
Color::LightBlue => Color::Blue,
|
||||
Color::LightMagenta => Color::Magenta,
|
||||
Color::LightCyan => Color::Cyan,
|
||||
Color::Indexed(bright @ 8..=15) => Color::Indexed(bright - 8),
|
||||
other => other,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use ratatui::{layout::Rect, style::Style};
|
||||
|
||||
use super::*;
|
||||
|
||||
fn frame_painted(style: Style) -> Buffer {
|
||||
let mut frame = Buffer::empty(Rect::new(0, 0, 1, 1));
|
||||
frame.set_style(frame.area, style);
|
||||
frame
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn eight_color_consoles_keep_dark_gray_visible() {
|
||||
let mut frame = frame_painted(Style::new().fg(Color::DarkGray).bold());
|
||||
ConsolePalette::EightColorVt.fit_frame(&mut frame);
|
||||
assert_eq!(frame.content[0].fg, Color::Gray);
|
||||
assert!(!frame.content[0].modifier.contains(Modifier::BOLD));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn eight_color_consoles_fold_bright_colors_onto_normal_ones() {
|
||||
let mut frame = frame_painted(Style::new().fg(Color::LightYellow).bg(Color::Indexed(12)));
|
||||
ConsolePalette::EightColorVt.fit_frame(&mut frame);
|
||||
assert_eq!(frame.content[0].fg, Color::Yellow);
|
||||
assert_eq!(frame.content[0].bg, Color::Indexed(4));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sixteen_color_consoles_only_lose_bold() {
|
||||
let mut frame = frame_painted(Style::new().fg(Color::DarkGray).bold());
|
||||
ConsolePalette::SixteenColorVt.fit_frame(&mut frame);
|
||||
assert_eq!(frame.content[0].fg, Color::DarkGray);
|
||||
assert!(!frame.content[0].modifier.contains(Modifier::BOLD));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn terminals_keep_the_frame_as_drawn() {
|
||||
let mut frame = frame_painted(Style::new().fg(Color::DarkGray).bold());
|
||||
ConsolePalette::Terminal.fit_frame(&mut frame);
|
||||
assert_eq!(frame.content[0].fg, Color::DarkGray);
|
||||
assert!(frame.content[0].modifier.contains(Modifier::BOLD));
|
||||
}
|
||||
}
|
||||
@@ -1,186 +0,0 @@
|
||||
use std::{collections::HashSet, fs, mem, ptr};
|
||||
|
||||
use rustix::{
|
||||
io::Errno,
|
||||
ioctl::{Getter, IntegerSetter, Opcode, Updater, ioctl},
|
||||
stdio::stdin,
|
||||
termios::ttyname,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
console_session::{
|
||||
ask_password,
|
||||
console_palette::{ConsoleLook, ConsolePalette},
|
||||
},
|
||||
screen_settings::font_glyphs::Glyphs,
|
||||
};
|
||||
|
||||
const GIO_UNIMAP: Opcode = 0x4B66;
|
||||
const VT_GETSTATE: Opcode = 0x5603;
|
||||
const VT_ACTIVATE: Opcode = 0x5606;
|
||||
const VIRTUAL_TERMINAL_PREFIX: &str = "/dev/tty";
|
||||
const KERNEL_PRINTK: &str = "/proc/sys/kernel/printk";
|
||||
const ALERTS_ONLY: &str = "1";
|
||||
const HIGHEST_LOW_GLYPH: u16 = 255;
|
||||
|
||||
pub(super) struct QuietKernelConsole {
|
||||
previous_level: String,
|
||||
}
|
||||
|
||||
fn console_level() -> Option<String> {
|
||||
let levels = fs::read_to_string(KERNEL_PRINTK).ok()?;
|
||||
levels.split_whitespace().next().map(ToOwned::to_owned)
|
||||
}
|
||||
|
||||
impl QuietKernelConsole {
|
||||
pub(super) fn take() -> Option<Self> {
|
||||
let previous_level = console_level()?;
|
||||
fs::write(KERNEL_PRINTK, ALERTS_ONLY).ok()?;
|
||||
Some(Self { previous_level })
|
||||
}
|
||||
|
||||
pub(super) fn keep_quiet(&mut self) -> bool {
|
||||
let Some(level) = console_level() else {
|
||||
return false;
|
||||
};
|
||||
if level == ALERTS_ONLY || fs::write(KERNEL_PRINTK, ALERTS_ONLY).is_err() {
|
||||
return false;
|
||||
}
|
||||
self.previous_level = level;
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
struct LoadedFont {
|
||||
characters: HashSet<char>,
|
||||
uses_high_glyphs: bool,
|
||||
}
|
||||
|
||||
pub(super) fn console_look(own_vt: Option<u16>) -> ConsoleLook {
|
||||
let font = loaded_font();
|
||||
let glyphs = font.as_ref().map_or_else(Glyphs::default, |font| {
|
||||
Glyphs::fitting(|symbol| symbol.is_ascii() || font.characters.contains(&symbol))
|
||||
});
|
||||
let palette = match own_vt {
|
||||
None => ConsolePalette::Terminal,
|
||||
Some(_) if font.as_ref().is_some_and(|font| font.uses_high_glyphs) => {
|
||||
ConsolePalette::EightColorVt
|
||||
}
|
||||
Some(_) => ConsolePalette::SixteenColorVt,
|
||||
};
|
||||
ConsoleLook { glyphs, palette }
|
||||
}
|
||||
|
||||
impl Drop for QuietKernelConsole {
|
||||
fn drop(&mut self) {
|
||||
let _ = fs::write(KERNEL_PRINTK, &self.previous_level);
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Default)]
|
||||
struct UnicodePair {
|
||||
unicode: u16,
|
||||
font_position: u16,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
struct UnicodeMap {
|
||||
count: u16,
|
||||
pairs: *mut UnicodePair,
|
||||
}
|
||||
|
||||
fn read_unicode_map(map: &mut UnicodeMap) -> Result<(), Errno> {
|
||||
unsafe { ioctl(stdin(), Updater::<GIO_UNIMAP, UnicodeMap>::new(map)) }
|
||||
}
|
||||
|
||||
fn loaded_font() -> Option<LoadedFont> {
|
||||
let mut probe = UnicodeMap {
|
||||
count: 0,
|
||||
pairs: ptr::null_mut(),
|
||||
};
|
||||
let _ = read_unicode_map(&mut probe);
|
||||
if probe.count == 0 {
|
||||
return None;
|
||||
}
|
||||
let mut pairs = vec![UnicodePair::default(); usize::from(probe.count)];
|
||||
let mut map = UnicodeMap {
|
||||
count: probe.count,
|
||||
pairs: pairs.as_mut_ptr(),
|
||||
};
|
||||
read_unicode_map(&mut map).ok()?;
|
||||
let mapped = &pairs[..usize::from(map.count).min(pairs.len())];
|
||||
Some(LoadedFont {
|
||||
characters: mapped
|
||||
.iter()
|
||||
.filter_map(|pair| char::from_u32(u32::from(pair.unicode)))
|
||||
.collect(),
|
||||
uses_high_glyphs: mapped
|
||||
.iter()
|
||||
.any(|pair| pair.font_position > HIGHEST_LOW_GLYPH),
|
||||
})
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
struct VtState {
|
||||
active: u16,
|
||||
_signal: u16,
|
||||
_state: u16,
|
||||
}
|
||||
|
||||
pub(super) struct ForegroundVt {
|
||||
own: u16,
|
||||
previous: u16,
|
||||
}
|
||||
|
||||
fn active_vt() -> Option<u16> {
|
||||
let state: VtState = unsafe { ioctl(stdin(), Getter::<VT_GETSTATE, VtState>::new()) }.ok()?;
|
||||
Some(state.active)
|
||||
}
|
||||
|
||||
pub(super) fn vt_of_stdin() -> Option<u16> {
|
||||
let name = ttyname(stdin(), Vec::new()).ok()?;
|
||||
name.to_str()
|
||||
.ok()?
|
||||
.strip_prefix(VIRTUAL_TERMINAL_PREFIX)?
|
||||
.parse()
|
||||
.ok()
|
||||
.filter(|number| *number > 0)
|
||||
}
|
||||
|
||||
impl ForegroundVt {
|
||||
pub(super) fn take(own: u16) -> Option<Self> {
|
||||
let previous = active_vt()?;
|
||||
if previous != own {
|
||||
activate(own).ok()?;
|
||||
}
|
||||
Some(Self { own, previous })
|
||||
}
|
||||
|
||||
pub(super) fn insist(&self) -> bool {
|
||||
self.taken_away() && activate(self.own).is_ok()
|
||||
}
|
||||
|
||||
pub(super) fn taken_away(&self) -> bool {
|
||||
active_vt().is_some_and(|active| active != self.own)
|
||||
}
|
||||
|
||||
pub(super) fn stay_switched(self) {
|
||||
mem::forget(self);
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for ForegroundVt {
|
||||
fn drop(&mut self) {
|
||||
if ask_password::requested() {
|
||||
eprintln!("bootvine: leaving a password prompt to the console agent on this terminal");
|
||||
return;
|
||||
}
|
||||
let _ = activate(self.previous);
|
||||
}
|
||||
}
|
||||
|
||||
fn activate(number: u16) -> Result<(), Errno> {
|
||||
let number = usize::from(number);
|
||||
unsafe { ioctl(stdin(), IntegerSetter::<VT_ACTIVATE>::new_usize(number)) }
|
||||
}
|
||||
@@ -1,211 +0,0 @@
|
||||
use std::{future::ready, io, mem, ops::ControlFlow, path::PathBuf, time::Duration};
|
||||
|
||||
use crossterm::event::Event;
|
||||
use futures::{Stream, StreamExt};
|
||||
|
||||
use crate::{
|
||||
boot_model::BootChange,
|
||||
boot_view::PasswordPrompt,
|
||||
console_session::{
|
||||
ask_password::{self, PasswordEntry, RequestWatch},
|
||||
console_palette::ConsoleLook,
|
||||
console_takeover::{ForegroundVt, QuietKernelConsole, console_look, vt_of_stdin},
|
||||
passphrase_input::asks_to_quit,
|
||||
resume_console::{RESUME_CONSOLE_MARKER, resume_console_is_open},
|
||||
stream_sources::items_when_readable,
|
||||
watch_screen::{ConsoleDesk, Refresh, ScreenInput, WatchEnding},
|
||||
},
|
||||
};
|
||||
|
||||
pub struct LiveDesk {
|
||||
quiet_kernel: Option<QuietKernelConsole>,
|
||||
foreground: Option<ForegroundVt>,
|
||||
for_system: bool,
|
||||
own_vt: Option<u16>,
|
||||
look: ConsoleLook,
|
||||
entry: Option<PasswordEntry>,
|
||||
handover_deadline: Option<Duration>,
|
||||
resume_marker: PathBuf,
|
||||
console_was_lent: bool,
|
||||
}
|
||||
|
||||
impl LiveDesk {
|
||||
#[must_use]
|
||||
pub fn take_console(for_system: bool) -> Self {
|
||||
let prompt_elsewhere = for_system && ask_password::requested();
|
||||
if prompt_elsewhere {
|
||||
eprintln!("bootvine: a password prompt is already showing, staying behind it");
|
||||
}
|
||||
let own_vt = vt_of_stdin();
|
||||
Self {
|
||||
quiet_kernel: for_system.then(QuietKernelConsole::take).flatten(),
|
||||
foreground: own_vt
|
||||
.filter(|_| !prompt_elsewhere)
|
||||
.and_then(ForegroundVt::take),
|
||||
for_system,
|
||||
own_vt,
|
||||
look: console_look(own_vt),
|
||||
entry: None,
|
||||
handover_deadline: None,
|
||||
resume_marker: PathBuf::from(RESUME_CONSOLE_MARKER),
|
||||
console_was_lent: false,
|
||||
}
|
||||
}
|
||||
|
||||
fn come_forward_once_prompts_are_gone(&mut self) -> bool {
|
||||
if !self.for_system || self.foreground.is_some() || ask_password::requested() {
|
||||
return false;
|
||||
}
|
||||
self.foreground = self.own_vt.and_then(ForegroundVt::take);
|
||||
if self.foreground.is_some() {
|
||||
eprintln!("bootvine: password prompt answered, taking the console back");
|
||||
}
|
||||
self.foreground.is_some()
|
||||
}
|
||||
|
||||
fn follow_requests(&mut self, requests_changed: bool) -> Refresh {
|
||||
let came_forward = requests_changed && self.come_forward_once_prompts_are_gone();
|
||||
self.entry = if self.for_system && self.foreground.is_some() {
|
||||
PasswordEntry::follow(self.entry.take(), requests_changed)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
if came_forward {
|
||||
Refresh::Clear
|
||||
} else {
|
||||
Refresh::Steady
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ConsoleDesk for LiveDesk {
|
||||
fn look(&self) -> ConsoleLook {
|
||||
self.look
|
||||
}
|
||||
|
||||
fn prompt(&self, _now: Duration) -> Option<PasswordPrompt<'_>> {
|
||||
self.entry.as_ref().map(PasswordEntry::prompt)
|
||||
}
|
||||
|
||||
fn press_key(&mut self, event: &Event, _now: Duration) -> ControlFlow<WatchEnding> {
|
||||
let Some(entry) = &mut self.entry else {
|
||||
return if asks_to_quit(event, false) {
|
||||
ControlFlow::Break(WatchEnding::ViewerLeft)
|
||||
} else {
|
||||
ControlFlow::Continue(())
|
||||
};
|
||||
};
|
||||
if let Err(error) = entry.type_key(event) {
|
||||
eprintln!("bootvine: cannot answer the password prompt: {error}");
|
||||
}
|
||||
ControlFlow::Continue(())
|
||||
}
|
||||
|
||||
fn begin_handover(&mut self, reached: &str, deadline: Duration) {
|
||||
if self.handover_deadline.is_some() {
|
||||
return;
|
||||
}
|
||||
eprintln!("bootvine: {reached} reached, handing the console over");
|
||||
self.handover_deadline = Some(deadline);
|
||||
}
|
||||
|
||||
fn frame_passed(&mut self, now: Duration) -> ControlFlow<WatchEnding, Vec<BootChange>> {
|
||||
let Some(deadline) = self.handover_deadline else {
|
||||
return ControlFlow::Continue(Vec::new());
|
||||
};
|
||||
if self
|
||||
.foreground
|
||||
.as_ref()
|
||||
.is_some_and(ForegroundVt::taken_away)
|
||||
{
|
||||
eprintln!("bootvine: another program took the console, leaving it there");
|
||||
if let Some(foreground) = self.foreground.take() {
|
||||
foreground.stay_switched();
|
||||
}
|
||||
ControlFlow::Break(WatchEnding::BootCompleted)
|
||||
} else if now >= deadline {
|
||||
eprintln!("bootvine: nothing took the console, switching back");
|
||||
ControlFlow::Break(WatchEnding::BootCompleted)
|
||||
} else {
|
||||
ControlFlow::Continue(Vec::new())
|
||||
}
|
||||
}
|
||||
|
||||
fn password_requests_changed(&mut self) -> Refresh {
|
||||
self.follow_requests(true)
|
||||
}
|
||||
|
||||
fn check_prompts(&mut self) {
|
||||
self.follow_requests(false);
|
||||
}
|
||||
|
||||
fn lends_console(&mut self) -> bool {
|
||||
let lent = resume_console_is_open(&self.resume_marker);
|
||||
self.console_was_lent |= lent;
|
||||
lent
|
||||
}
|
||||
|
||||
fn keep_console_up(&mut self) -> Refresh {
|
||||
if self.lends_console() {
|
||||
return Refresh::Steady;
|
||||
}
|
||||
let console_returned = mem::take(&mut self.console_was_lent);
|
||||
let kernel_got_loud = self
|
||||
.quiet_kernel
|
||||
.as_mut()
|
||||
.is_some_and(QuietKernelConsole::keep_quiet);
|
||||
let terminal_was_taken = self.handover_deadline.is_none()
|
||||
&& self.foreground.as_ref().is_some_and(ForegroundVt::insist);
|
||||
let look = console_look(self.own_vt);
|
||||
let restyled = look != self.look;
|
||||
self.look = look;
|
||||
if console_returned || kernel_got_loud || terminal_was_taken || restyled {
|
||||
Refresh::Repaint
|
||||
} else {
|
||||
Refresh::Steady
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn password_request_inputs(watch: RequestWatch) -> io::Result<impl Stream<Item = ScreenInput>> {
|
||||
Ok(items_when_readable(watch, RequestWatch::changed)?
|
||||
.filter(|changed| ready(*changed))
|
||||
.map(|_| ScreenInput::PasswordRequests))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::{env, fs, process};
|
||||
|
||||
use super::*;
|
||||
|
||||
fn desk_watching(resume_marker: PathBuf) -> LiveDesk {
|
||||
LiveDesk {
|
||||
quiet_kernel: None,
|
||||
foreground: None,
|
||||
for_system: true,
|
||||
own_vt: None,
|
||||
look: console_look(None),
|
||||
entry: None,
|
||||
handover_deadline: None,
|
||||
resume_marker,
|
||||
console_was_lent: false,
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_console_is_repainted_only_after_it_was_lent_for_resume() {
|
||||
let marker = env::temp_dir().join(format!("bootvine-resume-marker-{}", process::id()));
|
||||
let mut desk = desk_watching(marker.clone());
|
||||
assert!(!desk.lends_console());
|
||||
|
||||
fs::write(&marker, "1").expect("create the marker");
|
||||
assert!(desk.lends_console());
|
||||
assert_eq!(desk.keep_console_up(), Refresh::Steady);
|
||||
|
||||
fs::remove_file(&marker).expect("remove the marker");
|
||||
assert!(!desk.lends_console());
|
||||
assert_eq!(desk.keep_console_up(), Refresh::Repaint);
|
||||
assert_eq!(desk.keep_console_up(), Refresh::Steady);
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
use std::mem::take;
|
||||
|
||||
use ratatui::crossterm::event::{Event, KeyCode, KeyEvent, KeyEventKind, KeyModifiers};
|
||||
use zeroize::Zeroizing;
|
||||
|
||||
const ROOM_FOR_TYPING: usize = 512;
|
||||
|
||||
#[must_use]
|
||||
pub fn empty() -> Zeroizing<String> {
|
||||
Zeroizing::new(String::with_capacity(ROOM_FOR_TYPING))
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn masked(typed: &str) -> String {
|
||||
"*".repeat(typed.chars().count())
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn asks_to_quit(event: &Event, typing: bool) -> bool {
|
||||
let Event::Key(KeyEvent {
|
||||
code, modifiers, ..
|
||||
}) = event
|
||||
else {
|
||||
return false;
|
||||
};
|
||||
let control_c = *code == KeyCode::Char('c') && modifiers.contains(KeyModifiers::CONTROL);
|
||||
*code == KeyCode::Esc || (!typing && (*code == KeyCode::Char('q') || control_c))
|
||||
}
|
||||
|
||||
pub fn type_key(typed: &mut Zeroizing<String>, event: &Event) -> Option<Zeroizing<String>> {
|
||||
let Event::Key(KeyEvent {
|
||||
code,
|
||||
modifiers,
|
||||
kind: KeyEventKind::Press,
|
||||
..
|
||||
}) = event
|
||||
else {
|
||||
return None;
|
||||
};
|
||||
match code {
|
||||
KeyCode::Enter => return Some(Zeroizing::new(take(&mut **typed))),
|
||||
KeyCode::Backspace => {
|
||||
typed.pop();
|
||||
}
|
||||
KeyCode::Char('u') if modifiers.contains(KeyModifiers::CONTROL) => typed.clear(),
|
||||
KeyCode::Char(_) if modifiers.contains(KeyModifiers::CONTROL) => {}
|
||||
KeyCode::Char(character) if typed.len() + character.len_utf8() <= ROOM_FOR_TYPING => {
|
||||
typed.push(*character);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn press(code: KeyCode) -> Event {
|
||||
Event::Key(KeyEvent::from(code))
|
||||
}
|
||||
|
||||
fn typed(text: &str) -> Zeroizing<String> {
|
||||
let mut typed = empty();
|
||||
text.chars()
|
||||
.map(KeyCode::Char)
|
||||
.for_each(|code| assert_eq!(type_key(&mut typed, &press(code)), None));
|
||||
typed
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hides_what_is_typed() {
|
||||
let mut typed = typed("secret");
|
||||
type_key(&mut typed, &press(KeyCode::Backspace));
|
||||
assert_eq!(masked(&typed), "*****");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn control_u_clears() {
|
||||
let mut typed = typed("secret");
|
||||
let control_u = Event::Key(KeyEvent::new(KeyCode::Char('u'), KeyModifiers::CONTROL));
|
||||
type_key(&mut typed, &control_u);
|
||||
assert_eq!(typed.as_str(), "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn enter_hands_over_what_was_typed() {
|
||||
let mut typed = typed("secret");
|
||||
let submitted = type_key(&mut typed, &press(KeyCode::Enter));
|
||||
assert_eq!(submitted.as_deref().map(String::as_str), Some("secret"));
|
||||
assert_eq!(typed.as_str(), "");
|
||||
}
|
||||
}
|
||||
@@ -1,162 +0,0 @@
|
||||
use std::{
|
||||
fmt,
|
||||
fs::{self, File, OpenOptions},
|
||||
io::{self, Write},
|
||||
path::Path,
|
||||
thread,
|
||||
};
|
||||
|
||||
use crossterm::{
|
||||
Command,
|
||||
cursor::MoveTo,
|
||||
queue,
|
||||
style::{Attribute, Color as ConsoleColor, SetAttribute, SetForegroundColor},
|
||||
};
|
||||
use ratatui::{
|
||||
backend::CrosstermBackend,
|
||||
buffer::Buffer,
|
||||
layout::{Constraint, Rect},
|
||||
style::{Color, Style},
|
||||
widgets::{Block, Borders, Widget},
|
||||
};
|
||||
use rustix::termios::tcgetwinsize;
|
||||
|
||||
use crate::console_session::{stream_sources::FRAME_INTERVAL, watch_screen::overwrite_every_cell};
|
||||
|
||||
pub const RESUME_CONSOLE_MARKER: &str = "/run/bootvine/resume-console-open";
|
||||
const BOOTVINE_TERMINAL: &str = "/dev/tty12";
|
||||
const KERNEL_PRINTK: &str = "/proc/sys/kernel/printk";
|
||||
const KERNEL_TIMESTAMPS: &str = "/sys/module/printk/parameters/time";
|
||||
const KERNEL_INFO_VISIBLE: &str = "7";
|
||||
const TIMESTAMPS_HIDDEN: &str = "N";
|
||||
const FRAMES_TO_SETTLE: u32 = 2;
|
||||
const BAND_HEIGHT: u16 = 4;
|
||||
const BAND_TITLE: &str = " Looking for a hibernated session ";
|
||||
|
||||
struct ConfineScrolling(Rect);
|
||||
|
||||
impl Command for ConfineScrolling {
|
||||
fn write_ansi(&self, sequence: &mut impl fmt::Write) -> fmt::Result {
|
||||
write!(sequence, "\x1b[{};{}r", self.0.top() + 1, self.0.bottom())
|
||||
}
|
||||
}
|
||||
|
||||
struct ReleaseScrolling;
|
||||
|
||||
impl Command for ReleaseScrolling {
|
||||
fn write_ansi(&self, sequence: &mut impl fmt::Write) -> fmt::Result {
|
||||
sequence.write_str("\x1b[r")
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn resume_console_is_open(marker: &Path) -> bool {
|
||||
marker.exists()
|
||||
}
|
||||
|
||||
fn band_area(screen: Rect) -> Rect {
|
||||
screen.centered_vertically(Constraint::Length(BAND_HEIGHT))
|
||||
}
|
||||
|
||||
fn band_frame() -> Block<'static> {
|
||||
Block::new()
|
||||
.borders(Borders::TOP | Borders::BOTTOM)
|
||||
.border_style(Style::new().fg(Color::Yellow))
|
||||
.title(BAND_TITLE)
|
||||
}
|
||||
|
||||
fn open_bootvine_terminal() -> io::Result<File> {
|
||||
OpenOptions::new().write(true).open(BOOTVINE_TERMINAL)
|
||||
}
|
||||
|
||||
fn draw_progress_band() -> io::Result<()> {
|
||||
let terminal = open_bootvine_terminal()?;
|
||||
let window = tcgetwinsize(&terminal)?;
|
||||
let band = band_area(Rect::new(0, 0, window.ws_col, window.ws_row));
|
||||
let progress_rows = band_frame().inner(band);
|
||||
if progress_rows.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
let mut painted = Buffer::empty(band);
|
||||
band_frame().render(band, &mut painted);
|
||||
let mut backend = CrosstermBackend::new(terminal);
|
||||
overwrite_every_cell(&mut backend, &painted)?;
|
||||
queue!(
|
||||
backend,
|
||||
SetAttribute(Attribute::Bold),
|
||||
SetForegroundColor(ConsoleColor::DarkYellow),
|
||||
ConfineScrolling(progress_rows),
|
||||
MoveTo(progress_rows.x, progress_rows.y),
|
||||
)?;
|
||||
Write::flush(&mut backend)
|
||||
}
|
||||
|
||||
fn restore_bootvine_terminal() -> io::Result<()> {
|
||||
let mut terminal = open_bootvine_terminal()?;
|
||||
queue!(terminal, SetAttribute(Attribute::Reset), ReleaseScrolling)?;
|
||||
terminal.flush()
|
||||
}
|
||||
|
||||
pub fn open_resume_console() -> io::Result<()> {
|
||||
let printk_levels = fs::read_to_string(KERNEL_PRINTK)?;
|
||||
let previous_level = printk_levels.split_whitespace().next().unwrap_or_default();
|
||||
let previous_timestamps = fs::read_to_string(KERNEL_TIMESTAMPS).unwrap_or_default();
|
||||
let marker = Path::new(RESUME_CONSOLE_MARKER);
|
||||
if let Some(directory) = marker.parent() {
|
||||
fs::create_dir_all(directory)?;
|
||||
}
|
||||
fs::write(
|
||||
marker,
|
||||
format!("{previous_level}\n{}\n", previous_timestamps.trim()),
|
||||
)?;
|
||||
thread::sleep(FRAME_INTERVAL * FRAMES_TO_SETTLE);
|
||||
let _ = fs::write(KERNEL_TIMESTAMPS, TIMESTAMPS_HIDDEN);
|
||||
fs::write(KERNEL_PRINTK, KERNEL_INFO_VISIBLE)?;
|
||||
draw_progress_band()
|
||||
}
|
||||
|
||||
pub fn close_resume_console() -> io::Result<()> {
|
||||
let marker = Path::new(RESUME_CONSOLE_MARKER);
|
||||
let recorded = fs::read_to_string(marker)?;
|
||||
let mut recorded_lines = recorded.lines();
|
||||
let previous_level = recorded_lines.next().unwrap_or_default();
|
||||
let previous_timestamps = recorded_lines.next().unwrap_or_default();
|
||||
let terminal_restored = restore_bootvine_terminal();
|
||||
if !previous_timestamps.is_empty() {
|
||||
let _ = fs::write(KERNEL_TIMESTAMPS, previous_timestamps);
|
||||
}
|
||||
let level_restored = fs::write(KERNEL_PRINTK, previous_level);
|
||||
fs::remove_file(marker)?;
|
||||
terminal_restored.and(level_restored)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn screen_with_rows(rows: u16) -> Rect {
|
||||
Rect::new(0, 0, 80, rows)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_band_sits_in_the_middle_with_two_rows_for_the_kernel() {
|
||||
let band = band_area(screen_with_rows(50));
|
||||
assert_eq!(band, Rect::new(0, 23, 80, BAND_HEIGHT));
|
||||
assert_eq!(band_frame().inner(band), Rect::new(0, 24, 80, 2));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_scroll_region_counts_rows_from_one() {
|
||||
let mut sequence = String::new();
|
||||
ConfineScrolling(Rect::new(0, 24, 80, 2))
|
||||
.write_ansi(&mut sequence)
|
||||
.expect("writing to a string");
|
||||
assert_eq!(sequence, "\x1b[25;26r");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_screen_without_room_for_the_band_leaves_the_kernel_no_rows() {
|
||||
let band = band_area(screen_with_rows(2));
|
||||
assert!(band_frame().inner(band).is_empty());
|
||||
}
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
use std::{future::Future, io, iter, os::fd::AsRawFd, time::Duration};
|
||||
|
||||
use crossterm::event::{self, Event};
|
||||
use futures::{FutureExt, Stream, StreamExt, stream};
|
||||
use tokio::{
|
||||
io::{Interest, unix::AsyncFd},
|
||||
signal::unix::{SignalKind, signal},
|
||||
time::{Interval, MissedTickBehavior, interval, timeout},
|
||||
};
|
||||
|
||||
use crate::console_session::watch_screen::ScreenInput;
|
||||
|
||||
pub const FRAME_INTERVAL: Duration = Duration::from_millis(16);
|
||||
pub const BACKGROUND_CHECK_INTERVAL: Duration = Duration::from_millis(100);
|
||||
|
||||
pub struct CarriedItem<Item, State> {
|
||||
pub item: Item,
|
||||
pub state: State,
|
||||
}
|
||||
|
||||
pub fn unfold_carrying<State, Item, Next, Pending>(
|
||||
initial: State,
|
||||
mut next: Next,
|
||||
) -> impl Stream<Item = Item>
|
||||
where
|
||||
Next: FnMut(State) -> Pending,
|
||||
Pending: Future<Output = Option<CarriedItem<Item, State>>>,
|
||||
{
|
||||
stream::unfold(initial, move |state| {
|
||||
next(state).map(|carried| carried.map(|carried| (carried.item, carried.state)))
|
||||
})
|
||||
}
|
||||
|
||||
pub fn readable_source<Source: AsRawFd>(source: Source) -> io::Result<AsyncFd<Source>> {
|
||||
Ok(unsafe { AsyncFd::register_with_interest(source, Interest::READABLE) }?)
|
||||
}
|
||||
|
||||
pub fn items_when_readable<Source: AsRawFd, Item>(
|
||||
source: Source,
|
||||
read: impl Fn(&Source) -> Item,
|
||||
) -> io::Result<impl Stream<Item = Item>> {
|
||||
let readiness = readable_source(source)?;
|
||||
Ok(stream::poll_fn(move |context| {
|
||||
readiness.poll_read_ready(context).map(|ready| {
|
||||
ready.ok().map(|mut guard| {
|
||||
guard.clear_ready();
|
||||
read(readiness.get_ref())
|
||||
})
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
pub async fn readable_or_timeout<Source: AsRawFd>(readiness: &AsyncFd<Source>, patience: Duration) {
|
||||
if let Ok(Ok(mut guard)) = timeout(patience, readiness.readable()).await {
|
||||
guard.clear_ready();
|
||||
}
|
||||
}
|
||||
|
||||
fn steady_interval(period: Duration) -> Interval {
|
||||
let mut ticks = interval(period);
|
||||
ticks.set_missed_tick_behavior(MissedTickBehavior::Delay);
|
||||
ticks
|
||||
}
|
||||
|
||||
pub fn periodic_inputs(
|
||||
period: Duration,
|
||||
input: fn() -> ScreenInput,
|
||||
) -> impl Stream<Item = ScreenInput> {
|
||||
let mut ticks = steady_interval(period);
|
||||
stream::poll_fn(move |context| ticks.poll_tick(context).map(|_| Some(input())))
|
||||
}
|
||||
|
||||
pub fn frame_inputs() -> impl Stream<Item = ScreenInput> {
|
||||
periodic_inputs(FRAME_INTERVAL, || ScreenInput::Frame)
|
||||
}
|
||||
|
||||
fn drain_terminal_events() -> io::Result<Vec<Event>> {
|
||||
iter::from_fn(|| match event::poll(Duration::ZERO) {
|
||||
Ok(true) => Some(event::read()),
|
||||
Ok(false) => None,
|
||||
Err(error) => Some(Err(error)),
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn terminal_inputs(drained: io::Result<Vec<Event>>) -> Vec<ScreenInput> {
|
||||
match drained {
|
||||
Ok(events) => events.into_iter().map(ScreenInput::Key).collect(),
|
||||
Err(error) => vec![ScreenInput::Failed(error.into())],
|
||||
}
|
||||
}
|
||||
|
||||
pub fn key_inputs() -> io::Result<impl Stream<Item = ScreenInput>> {
|
||||
Ok(
|
||||
items_when_readable(io::stdin(), |_| drain_terminal_events())?
|
||||
.map(terminal_inputs)
|
||||
.flat_map(stream::iter),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn termination_inputs() -> io::Result<impl Stream<Item = ScreenInput>> {
|
||||
let mut terminate = signal(SignalKind::terminate())?;
|
||||
Ok(stream::once(async move {
|
||||
terminate.recv().await;
|
||||
ScreenInput::Terminate
|
||||
}))
|
||||
}
|
||||
@@ -1,122 +0,0 @@
|
||||
use std::{path::Path, time::Duration};
|
||||
|
||||
use futures::{StreamExt, stream};
|
||||
use tokio::runtime::Builder;
|
||||
|
||||
use crate::{
|
||||
boot_model::{BootState, Phase, boot_origin::BootOrigin},
|
||||
console_session::{
|
||||
ask_password::RequestWatch,
|
||||
live_desk::{LiveDesk, password_request_inputs},
|
||||
stream_sources::{
|
||||
BACKGROUND_CHECK_INTERVAL, frame_inputs, key_inputs, periodic_inputs,
|
||||
termination_inputs,
|
||||
},
|
||||
watch_screen::{ScreenInput, WatchEnding, WatchScreen, watch_until_ending},
|
||||
},
|
||||
screen_settings::{color_scheme::Colors, config_file::Timing},
|
||||
systemd_link::{
|
||||
boot_feed::{RootRequest, bus_inputs},
|
||||
link_error::Error,
|
||||
switch_root::INITRD_RELEASE,
|
||||
systemd_bus::{Scope, Session, StatusOutput},
|
||||
},
|
||||
};
|
||||
|
||||
pub struct Settings {
|
||||
pub scope: Scope,
|
||||
pub shutdown: bool,
|
||||
pub target: RootRequest,
|
||||
pub timing: Timing,
|
||||
pub colors: Colors,
|
||||
}
|
||||
|
||||
const FULL_REPAINT_INTERVAL: Duration = Duration::from_secs(5);
|
||||
|
||||
struct ConfiguredStatusOnExit;
|
||||
|
||||
impl Drop for ConfiguredStatusOnExit {
|
||||
fn drop(&mut self) {
|
||||
if let Ok(session) = Session::open(Scope::System) {
|
||||
session.set_show_status(StatusOutput::Configured).ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn boot_already_finished(settings: &Settings) -> bool {
|
||||
settings.scope == Scope::System
|
||||
&& !settings.shutdown
|
||||
&& Session::open(Scope::System)
|
||||
.and_then(|session| session.boot_in_progress())
|
||||
.is_ok_and(|booting| !booting)
|
||||
}
|
||||
|
||||
fn starting_phase(settings: &Settings) -> Phase {
|
||||
match settings.scope {
|
||||
_ if settings.shutdown => Phase::Shutdown,
|
||||
Scope::User => Phase::User,
|
||||
Scope::System if Path::new(INITRD_RELEASE).exists() => Phase::Initrd,
|
||||
Scope::System => Phase::Host,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn run(settings: &Settings) -> Result<(), Error> {
|
||||
if boot_already_finished(settings) {
|
||||
eprintln!("bootvine: boot already finished, leaving the console alone");
|
||||
return Ok(());
|
||||
}
|
||||
Builder::new_current_thread()
|
||||
.enable_io()
|
||||
.enable_time()
|
||||
.build()?
|
||||
.block_on(watch_live_boot(settings, starting_phase(settings)))
|
||||
}
|
||||
|
||||
async fn watch_live_boot(settings: &Settings, phase: Phase) -> Result<(), Error> {
|
||||
let for_system = settings.scope == Scope::System;
|
||||
let _restores_status = for_system.then_some(ConfiguredStatusOnExit);
|
||||
let requests = RequestWatch::open();
|
||||
let prompt_check: fn() -> ScreenInput = if requests.is_some() {
|
||||
|| ScreenInput::PromptCheck
|
||||
} else {
|
||||
|| ScreenInput::PasswordRequests
|
||||
};
|
||||
let desk = LiveDesk::take_console(for_system);
|
||||
let password_inputs = requests.map(password_request_inputs).transpose()?;
|
||||
let event_inputs = stream::select(
|
||||
stream::select(
|
||||
bus_inputs(phase, settings.scope, settings.target.clone()),
|
||||
key_inputs()?,
|
||||
),
|
||||
stream::select(
|
||||
termination_inputs()?,
|
||||
stream::iter(password_inputs).flatten(),
|
||||
),
|
||||
);
|
||||
let timer_inputs = stream::select(
|
||||
stream::select(
|
||||
frame_inputs(),
|
||||
periodic_inputs(BACKGROUND_CHECK_INTERVAL, prompt_check),
|
||||
),
|
||||
stream::select(
|
||||
periodic_inputs(BACKGROUND_CHECK_INTERVAL, || ScreenInput::ConsoleUpkeep),
|
||||
periodic_inputs(FULL_REPAINT_INTERVAL, || ScreenInput::FullRepaint),
|
||||
),
|
||||
);
|
||||
let inputs = stream::select(event_inputs, timer_inputs);
|
||||
let mut screen = WatchScreen::new(
|
||||
BootState::new(phase),
|
||||
desk,
|
||||
BootOrigin::read,
|
||||
settings.colors,
|
||||
settings.timing,
|
||||
Duration::ZERO,
|
||||
);
|
||||
let mut terminal = ratatui::try_init()?;
|
||||
let ending = watch_until_ending(&mut screen, &mut terminal, inputs).await;
|
||||
ratatui::restore();
|
||||
match ending {
|
||||
WatchEnding::Failed(error) => Err(error),
|
||||
WatchEnding::BootCompleted | WatchEnding::ViewerLeft => Ok(()),
|
||||
}
|
||||
}
|
||||
@@ -1,350 +0,0 @@
|
||||
use std::{future::ready, ops::ControlFlow, time::Duration};
|
||||
|
||||
use crossterm::event::Event;
|
||||
use futures::{Stream, StreamExt};
|
||||
use ratatui::{
|
||||
Terminal,
|
||||
backend::Backend,
|
||||
buffer::{Buffer, CellDiffOption},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
boot_model::{BootChange, BootState, boot_origin::BootOrigin},
|
||||
boot_view::{BootProjection, BootView, PasswordPrompt, project_boot},
|
||||
console_session::console_palette::ConsoleLook,
|
||||
screen_settings::{color_scheme::Colors, config_file::Timing},
|
||||
systemd_link::{link_error::Error, monotonic_clock::monotonic_now},
|
||||
};
|
||||
|
||||
const INPUT_BATCH: usize = 64;
|
||||
const PROJECTION_REFRESH: Duration = Duration::from_millis(100);
|
||||
|
||||
pub enum ScreenInput {
|
||||
Boot(Vec<BootChange>),
|
||||
Key(Event),
|
||||
Frame,
|
||||
PromptCheck,
|
||||
ConsoleUpkeep,
|
||||
FullRepaint,
|
||||
PasswordRequests,
|
||||
Terminate,
|
||||
Failed(Error),
|
||||
}
|
||||
|
||||
pub enum WatchEnding {
|
||||
BootCompleted,
|
||||
ViewerLeft,
|
||||
Failed(Error),
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub enum Refresh {
|
||||
Steady,
|
||||
Repaint,
|
||||
Clear,
|
||||
}
|
||||
|
||||
pub trait ConsoleDesk {
|
||||
fn prompt(&self, now: Duration) -> Option<PasswordPrompt<'_>>;
|
||||
fn press_key(&mut self, event: &Event, now: Duration) -> ControlFlow<WatchEnding>;
|
||||
fn frame_passed(&mut self, now: Duration) -> ControlFlow<WatchEnding, Vec<BootChange>>;
|
||||
|
||||
fn look(&self) -> ConsoleLook {
|
||||
ConsoleLook::default()
|
||||
}
|
||||
|
||||
fn password_requests_changed(&mut self) -> Refresh {
|
||||
Refresh::Steady
|
||||
}
|
||||
|
||||
fn check_prompts(&mut self) {}
|
||||
|
||||
fn keep_console_up(&mut self) -> Refresh {
|
||||
Refresh::Steady
|
||||
}
|
||||
|
||||
fn begin_handover(&mut self, _reached: &str, _deadline: Duration) {}
|
||||
|
||||
fn lends_console(&mut self) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
struct CachedProjection {
|
||||
projection: BootProjection,
|
||||
built_at: Duration,
|
||||
}
|
||||
|
||||
pub struct WatchScreen<Desk> {
|
||||
pub state: BootState,
|
||||
pub desk: Desk,
|
||||
read_origin: fn() -> BootOrigin,
|
||||
origin: BootOrigin,
|
||||
refresh_due: Refresh,
|
||||
colors: Colors,
|
||||
timing: Timing,
|
||||
epoch: Duration,
|
||||
projection: Option<CachedProjection>,
|
||||
}
|
||||
|
||||
impl<Desk: ConsoleDesk> WatchScreen<Desk> {
|
||||
pub fn new(
|
||||
state: BootState,
|
||||
desk: Desk,
|
||||
read_origin: fn() -> BootOrigin,
|
||||
colors: Colors,
|
||||
timing: Timing,
|
||||
epoch: Duration,
|
||||
) -> Self {
|
||||
Self {
|
||||
state,
|
||||
desk,
|
||||
read_origin,
|
||||
origin: read_origin(),
|
||||
refresh_due: Refresh::Steady,
|
||||
colors,
|
||||
timing,
|
||||
epoch,
|
||||
projection: None,
|
||||
}
|
||||
}
|
||||
|
||||
fn request_refresh(&mut self, refresh: Refresh) {
|
||||
self.refresh_due = self.refresh_due.max(refresh);
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn now(&self) -> Duration {
|
||||
monotonic_now().saturating_sub(self.epoch)
|
||||
}
|
||||
|
||||
fn absorb(&mut self, input: ScreenInput) -> ControlFlow<WatchEnding> {
|
||||
let now = self.now();
|
||||
match input {
|
||||
ScreenInput::Boot(changes) => self.apply_boot_changes(changes, now),
|
||||
ScreenInput::Key(event) => self.desk.press_key(&event, now),
|
||||
ScreenInput::Frame => {
|
||||
let changes = self.desk.frame_passed(now)?;
|
||||
if changes.is_empty() {
|
||||
return ControlFlow::Continue(());
|
||||
}
|
||||
self.apply_boot_changes(changes, now)
|
||||
}
|
||||
ScreenInput::PromptCheck => {
|
||||
self.desk.check_prompts();
|
||||
ControlFlow::Continue(())
|
||||
}
|
||||
ScreenInput::ConsoleUpkeep => {
|
||||
let refresh = self.desk.keep_console_up();
|
||||
self.request_refresh(refresh);
|
||||
ControlFlow::Continue(())
|
||||
}
|
||||
ScreenInput::FullRepaint => {
|
||||
self.request_refresh(Refresh::Repaint);
|
||||
ControlFlow::Continue(())
|
||||
}
|
||||
ScreenInput::PasswordRequests => {
|
||||
let refresh = self.desk.password_requests_changed();
|
||||
self.request_refresh(refresh);
|
||||
ControlFlow::Continue(())
|
||||
}
|
||||
ScreenInput::Terminate => ControlFlow::Break(WatchEnding::ViewerLeft),
|
||||
ScreenInput::Failed(error) => ControlFlow::Break(WatchEnding::Failed(error)),
|
||||
}
|
||||
}
|
||||
|
||||
fn apply_boot_changes(
|
||||
&mut self,
|
||||
changes: Vec<BootChange>,
|
||||
now: Duration,
|
||||
) -> ControlFlow<WatchEnding> {
|
||||
let phase_before = self.state.phase;
|
||||
changes
|
||||
.into_iter()
|
||||
.for_each(|change| self.state.apply(change));
|
||||
self.projection = None;
|
||||
if self.state.phase != phase_before {
|
||||
self.origin = (self.read_origin)();
|
||||
}
|
||||
if let Some(display_manager) = self.state.started_display_manager() {
|
||||
self.desk
|
||||
.begin_handover(display_manager, now + self.timing.wait_for_display_manager);
|
||||
} else if self.state.is_complete() {
|
||||
self.desk.begin_handover(
|
||||
self.state.root.unit().unwrap_or("boot"),
|
||||
now + self.timing.keep_final_frame_for,
|
||||
);
|
||||
}
|
||||
ControlFlow::Continue(())
|
||||
}
|
||||
|
||||
fn absorb_batch<B: Backend>(
|
||||
&mut self,
|
||||
batch: Vec<ScreenInput>,
|
||||
terminal: &mut Terminal<B>,
|
||||
) -> ControlFlow<WatchEnding>
|
||||
where
|
||||
Error: From<B::Error>,
|
||||
{
|
||||
batch.into_iter().try_for_each(|input| self.absorb(input))?;
|
||||
if self.desk.lends_console() {
|
||||
return ControlFlow::Continue(());
|
||||
}
|
||||
match self.draw(terminal) {
|
||||
Ok(()) => ControlFlow::Continue(()),
|
||||
Err(error) => ControlFlow::Break(WatchEnding::Failed(error)),
|
||||
}
|
||||
}
|
||||
|
||||
fn draw<B: Backend>(&mut self, terminal: &mut Terminal<B>) -> Result<(), Error>
|
||||
where
|
||||
Error: From<B::Error>,
|
||||
{
|
||||
if self.refresh_due == Refresh::Clear {
|
||||
terminal.clear()?;
|
||||
}
|
||||
let now = self.now();
|
||||
let look = self.desk.look();
|
||||
if self
|
||||
.projection
|
||||
.as_ref()
|
||||
.is_some_and(|cached| now.saturating_sub(cached.built_at) >= PROJECTION_REFRESH)
|
||||
{
|
||||
self.projection = None;
|
||||
}
|
||||
let projection = &self
|
||||
.projection
|
||||
.get_or_insert_with(|| CachedProjection {
|
||||
projection: project_boot(&self.state, &self.timing, now),
|
||||
built_at: now,
|
||||
})
|
||||
.projection;
|
||||
let completed = terminal.draw(|canvas| {
|
||||
canvas.render_widget(
|
||||
BootView {
|
||||
state: &self.state,
|
||||
projection,
|
||||
colors: &self.colors,
|
||||
timing: &self.timing,
|
||||
glyphs: &look.glyphs,
|
||||
now,
|
||||
origin: &self.origin,
|
||||
password_prompt: self.desk.prompt(now),
|
||||
},
|
||||
canvas.area(),
|
||||
);
|
||||
look.palette.fit_frame(canvas.buffer_mut());
|
||||
})?;
|
||||
if self.refresh_due == Refresh::Repaint {
|
||||
let painted = completed.buffer.clone();
|
||||
overwrite_every_cell(terminal.backend_mut(), &painted)?;
|
||||
}
|
||||
self.refresh_due = Refresh::Steady;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn watch_until_ending<Desk: ConsoleDesk, B: Backend>(
|
||||
screen: &mut WatchScreen<Desk>,
|
||||
terminal: &mut Terminal<B>,
|
||||
inputs: impl Stream<Item = ScreenInput>,
|
||||
) -> WatchEnding
|
||||
where
|
||||
Error: From<B::Error>,
|
||||
{
|
||||
inputs
|
||||
.ready_chunks(INPUT_BATCH)
|
||||
.filter_map(|batch| ready(screen.absorb_batch(batch, terminal).break_value()))
|
||||
.take(1)
|
||||
.fold(WatchEnding::ViewerLeft, |_, ending| ready(ending))
|
||||
.await
|
||||
}
|
||||
|
||||
pub(super) fn overwrite_every_cell<B: Backend>(
|
||||
backend: &mut B,
|
||||
frame: &Buffer,
|
||||
) -> Result<(), B::Error> {
|
||||
backend.draw(
|
||||
frame
|
||||
.content
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|(_, cell)| cell.diff_option != CellDiffOption::Skip)
|
||||
.map(|(index, cell)| {
|
||||
let (x, y) = frame.pos_of(index);
|
||||
(x, y, cell)
|
||||
}),
|
||||
)?;
|
||||
backend.flush()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{
|
||||
boot_model::{ActiveState, Activity, HANDOFF_UNIT},
|
||||
boot_test_fixtures::{MS, nested_boot_sample, queue_unit, waiting},
|
||||
};
|
||||
|
||||
#[derive(Default)]
|
||||
struct HandoverRecorder {
|
||||
handovers: Vec<String>,
|
||||
}
|
||||
|
||||
impl ConsoleDesk for HandoverRecorder {
|
||||
fn prompt(&self, _now: Duration) -> Option<PasswordPrompt<'_>> {
|
||||
None
|
||||
}
|
||||
|
||||
fn press_key(&mut self, _event: &Event, _now: Duration) -> ControlFlow<WatchEnding> {
|
||||
ControlFlow::Continue(())
|
||||
}
|
||||
|
||||
fn frame_passed(&mut self, _now: Duration) -> ControlFlow<WatchEnding, Vec<BootChange>> {
|
||||
ControlFlow::Continue(Vec::new())
|
||||
}
|
||||
|
||||
fn begin_handover(&mut self, reached: &str, _deadline: Duration) {
|
||||
self.handovers.push(reached.to_owned());
|
||||
}
|
||||
}
|
||||
|
||||
fn test_origin() -> BootOrigin {
|
||||
BootOrigin {
|
||||
host: "test".to_owned(),
|
||||
system: None,
|
||||
generation: None,
|
||||
kernel: "Linux".to_owned(),
|
||||
}
|
||||
}
|
||||
|
||||
fn screen_watching(state: BootState) -> WatchScreen<HandoverRecorder> {
|
||||
WatchScreen::new(
|
||||
state,
|
||||
HandoverRecorder::default(),
|
||||
test_origin,
|
||||
Colors::default(),
|
||||
Timing::default(),
|
||||
Duration::ZERO,
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn display_manager_start_hands_over_before_the_boot_completes() {
|
||||
let mut state = nested_boot_sample();
|
||||
queue_unit(&mut state, 20, waiting(HANDOFF_UNIT, &[]), 500 * MS);
|
||||
let mut screen = screen_watching(state);
|
||||
let _ = screen.apply_boot_changes(Vec::new(), 1000 * MS);
|
||||
assert!(screen.desk.handovers.is_empty());
|
||||
let started = BootChange::UpdateActivity {
|
||||
unit: HANDOFF_UNIT.to_owned(),
|
||||
activity: Activity {
|
||||
state: Some(ActiveState::Active),
|
||||
..Activity::default()
|
||||
},
|
||||
};
|
||||
let _ = screen.apply_boot_changes(vec![started], 6000 * MS);
|
||||
assert!(!screen.state.is_complete());
|
||||
assert_eq!(screen.desk.handovers, [HANDOFF_UNIT]);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
pub mod boot_model;
|
||||
#[cfg(test)]
|
||||
mod boot_test_fixtures;
|
||||
pub mod boot_view;
|
||||
pub mod console_session;
|
||||
pub mod screen_settings;
|
||||
pub mod system_install;
|
||||
pub mod systemd_link;
|
||||
@@ -1,167 +0,0 @@
|
||||
use std::{
|
||||
error::Error, fmt::Display, io::ErrorKind, path::PathBuf, process::ExitCode, time::Duration,
|
||||
};
|
||||
|
||||
use bootvine::{
|
||||
console_session::{
|
||||
resume_console::{close_resume_console, open_resume_console},
|
||||
watch_loop::{Settings, run},
|
||||
},
|
||||
screen_settings::config_file::{
|
||||
Config, ConfigError, Timing, default_config_table, read_config_file,
|
||||
},
|
||||
system_install::install_files::{
|
||||
InstallOptions, UninstallOptions, install_files, uninstall_files,
|
||||
},
|
||||
systemd_link::{boot_feed::RootRequest, systemd_bus::Scope},
|
||||
};
|
||||
use clap::{Args, Parser, Subcommand, ValueEnum};
|
||||
use jiff::fmt::friendly::SpanParser;
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(
|
||||
version,
|
||||
about = "Live dependency tree of systemd jobs while the system boots",
|
||||
args_conflicts_with_subcommands = true
|
||||
)]
|
||||
struct Cli {
|
||||
#[command(subcommand)]
|
||||
command: Option<Command>,
|
||||
#[command(flatten)]
|
||||
watch: WatchOptions,
|
||||
}
|
||||
|
||||
#[derive(Args)]
|
||||
struct WatchOptions {
|
||||
#[arg(long, help = "Watch the user service manager instead of PID 1")]
|
||||
user: bool,
|
||||
#[arg(
|
||||
long,
|
||||
help = "Follow a shutdown instead of a boot; started by bootvine-shutdown.service"
|
||||
)]
|
||||
shutdown: bool,
|
||||
#[arg(
|
||||
long,
|
||||
help = "Root unit of the tree; defaults to the manager's default target"
|
||||
)]
|
||||
target: Option<String>,
|
||||
#[arg(
|
||||
long,
|
||||
value_parser = |raw: &str| SpanParser::new().parse_unsigned_duration(raw),
|
||||
help = "How long the final frame stays on screen, e.g. 1s or 500ms; overrides \
|
||||
timing.keep-final-frame-for"
|
||||
)]
|
||||
hold: Option<Duration>,
|
||||
#[arg(
|
||||
long,
|
||||
default_value = "/etc/bootvine.toml",
|
||||
help = "TOML file with [colors] and [timing] tables; see `bootvine defaults`"
|
||||
)]
|
||||
config: PathBuf,
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
enum Command {
|
||||
#[command(about = "Print every setting with its default value")]
|
||||
Defaults(DefaultsOptions),
|
||||
#[command(about = "Exit with an error if a config file is unreadable or invalid")]
|
||||
Check(CheckOptions),
|
||||
#[command(
|
||||
about = "Install this binary and the systemd units, and enable them; asks sudo when needed"
|
||||
)]
|
||||
Install(InstallOptions),
|
||||
#[command(about = "Disable and remove what install put in place")]
|
||||
Uninstall(UninstallOptions),
|
||||
#[command(
|
||||
about = "Let the kernel's image loading progress reach the console; started before \
|
||||
systemd-hibernate-resume.service"
|
||||
)]
|
||||
OpenResumeConsole,
|
||||
#[command(about = "Undo open-resume-console when no hibernated image was restored")]
|
||||
CloseResumeConsole,
|
||||
}
|
||||
|
||||
#[derive(Args)]
|
||||
struct DefaultsOptions {
|
||||
#[arg(long, value_enum, default_value_t = DefaultsFormat::Toml)]
|
||||
format: DefaultsFormat,
|
||||
}
|
||||
|
||||
#[derive(Args)]
|
||||
struct CheckOptions {
|
||||
#[arg(help = "Config file to check, such as /etc/bootvine.toml")]
|
||||
path: PathBuf,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, ValueEnum)]
|
||||
enum DefaultsFormat {
|
||||
Toml,
|
||||
Nix,
|
||||
}
|
||||
|
||||
fn main() -> ExitCode {
|
||||
let cli = Cli::parse();
|
||||
match cli.command {
|
||||
Some(Command::Defaults(options)) => report_outcome(
|
||||
render_defaults(options.format).map(|text| println!("{}", text.trim_end())),
|
||||
),
|
||||
Some(Command::Check(options)) => report_outcome(
|
||||
read_config_file(&options.path)
|
||||
.map(|_| ())
|
||||
.map_err(|error| format!("{}: {error}", options.path.display())),
|
||||
),
|
||||
Some(Command::Install(options)) => report_outcome(install_files(&options)),
|
||||
Some(Command::Uninstall(options)) => report_outcome(uninstall_files(&options)),
|
||||
Some(Command::OpenResumeConsole) => report_outcome(open_resume_console()),
|
||||
Some(Command::CloseResumeConsole) => report_outcome(close_resume_console()),
|
||||
None => watch_boot(cli.watch),
|
||||
}
|
||||
}
|
||||
|
||||
fn report_outcome(outcome: Result<(), impl Display>) -> ExitCode {
|
||||
match outcome {
|
||||
Ok(()) => ExitCode::SUCCESS,
|
||||
Err(error) => {
|
||||
eprintln!("bootvine: {error}");
|
||||
ExitCode::FAILURE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn render_defaults(format: DefaultsFormat) -> Result<String, Box<dyn Error>> {
|
||||
let defaults = default_config_table()?;
|
||||
Ok(match format {
|
||||
DefaultsFormat::Toml => toml::to_string_pretty(&defaults)?,
|
||||
DefaultsFormat::Nix => ser_nix::to_string(&defaults)?,
|
||||
})
|
||||
}
|
||||
|
||||
fn watch_boot(options: WatchOptions) -> ExitCode {
|
||||
let config = match read_config_file(&options.config) {
|
||||
Ok(config) => config,
|
||||
Err(ConfigError::Unreadable(error)) if error.kind() == ErrorKind::NotFound => {
|
||||
Config::default()
|
||||
}
|
||||
Err(error) => {
|
||||
eprintln!("bootvine: ignoring {}: {error}", options.config.display());
|
||||
Config::default()
|
||||
}
|
||||
};
|
||||
let settings = Settings {
|
||||
scope: if options.user {
|
||||
Scope::User
|
||||
} else {
|
||||
Scope::System
|
||||
},
|
||||
shutdown: options.shutdown,
|
||||
target: options
|
||||
.target
|
||||
.map_or(RootRequest::ManagerDefault, RootRequest::Named),
|
||||
timing: Timing {
|
||||
keep_final_frame_for: options.hold.unwrap_or(config.timing.keep_final_frame_for),
|
||||
..config.timing
|
||||
},
|
||||
colors: config.colors,
|
||||
};
|
||||
report_outcome(run(&settings))
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
pub mod color_scheme;
|
||||
pub mod config_file;
|
||||
pub mod font_glyphs;
|
||||
@@ -1,196 +0,0 @@
|
||||
use ratatui::style::Color;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, Deserialize, Serialize, PartialEq, Eq)]
|
||||
#[serde(default, deny_unknown_fields, rename_all = "kebab-case")]
|
||||
pub struct Colors {
|
||||
pub header: HeaderColors,
|
||||
pub stages: StageColors,
|
||||
pub tree: TreeColors,
|
||||
pub timeline: TimelineColors,
|
||||
pub failures: FailureColors,
|
||||
pub footer: FooterColors,
|
||||
pub password: PasswordColors,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, Eq)]
|
||||
#[serde(default, deny_unknown_fields, rename_all = "kebab-case")]
|
||||
pub struct HeaderColors {
|
||||
pub origin: Color,
|
||||
pub separators: Color,
|
||||
pub total_time: Color,
|
||||
}
|
||||
|
||||
impl Default for HeaderColors {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
origin: Color::White,
|
||||
separators: Color::DarkGray,
|
||||
total_time: Color::White,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, Eq)]
|
||||
#[serde(default, deny_unknown_fields, rename_all = "kebab-case")]
|
||||
pub struct StageColors {
|
||||
pub branches: Color,
|
||||
pub finished_label: Color,
|
||||
pub finished_time: Color,
|
||||
pub unit_count: Color,
|
||||
pub failed_count: Color,
|
||||
pub current: Color,
|
||||
}
|
||||
|
||||
impl Default for StageColors {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
branches: Color::DarkGray,
|
||||
finished_label: Color::Gray,
|
||||
finished_time: Color::Green,
|
||||
unit_count: Color::Gray,
|
||||
failed_count: Color::LightRed,
|
||||
current: Color::White,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, Eq)]
|
||||
#[serde(default, deny_unknown_fields, rename_all = "kebab-case")]
|
||||
pub struct TreeColors {
|
||||
pub branches: Color,
|
||||
pub columns: Color,
|
||||
pub target: Color,
|
||||
pub current_stage: Color,
|
||||
pub reached_stage: Color,
|
||||
pub running_unit: Color,
|
||||
pub running_marker: Color,
|
||||
pub waiting_unit: Color,
|
||||
pub finished_unit: Color,
|
||||
pub finished_marker: Color,
|
||||
pub failed_unit: Color,
|
||||
pub overflow: Color,
|
||||
}
|
||||
|
||||
impl Default for TreeColors {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
branches: Color::DarkGray,
|
||||
columns: Color::DarkGray,
|
||||
target: Color::Cyan,
|
||||
current_stage: Color::Yellow,
|
||||
reached_stage: Color::Green,
|
||||
running_unit: Color::White,
|
||||
running_marker: Color::Yellow,
|
||||
waiting_unit: Color::Gray,
|
||||
finished_unit: Color::DarkGray,
|
||||
finished_marker: Color::Green,
|
||||
failed_unit: Color::LightRed,
|
||||
overflow: Color::Gray,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, Eq)]
|
||||
#[serde(default, deny_unknown_fields, rename_all = "kebab-case")]
|
||||
pub struct TimelineColors {
|
||||
pub rule: Color,
|
||||
pub title: Color,
|
||||
pub axis: Color,
|
||||
pub milestone: Color,
|
||||
pub finished: Color,
|
||||
pub finished_label: Color,
|
||||
pub failed: Color,
|
||||
pub queued_bar: Color,
|
||||
pub running: Color,
|
||||
pub running_label: Color,
|
||||
}
|
||||
|
||||
impl Default for TimelineColors {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
rule: Color::DarkGray,
|
||||
title: Color::Gray,
|
||||
axis: Color::DarkGray,
|
||||
milestone: Color::Green,
|
||||
finished: Color::Green,
|
||||
finished_label: Color::Gray,
|
||||
failed: Color::LightRed,
|
||||
queued_bar: Color::Gray,
|
||||
running: Color::Yellow,
|
||||
running_label: Color::White,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, Eq)]
|
||||
#[serde(default, deny_unknown_fields, rename_all = "kebab-case")]
|
||||
pub struct FailureColors {
|
||||
pub rule: Color,
|
||||
pub title: Color,
|
||||
pub unit: Color,
|
||||
pub reason: Color,
|
||||
pub log: Color,
|
||||
pub overflow: Color,
|
||||
}
|
||||
|
||||
impl Default for FailureColors {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
rule: Color::DarkGray,
|
||||
title: Color::LightRed,
|
||||
unit: Color::LightRed,
|
||||
reason: Color::White,
|
||||
log: Color::Gray,
|
||||
overflow: Color::DarkGray,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, Eq)]
|
||||
#[serde(default, deny_unknown_fields, rename_all = "kebab-case")]
|
||||
pub struct FooterColors {
|
||||
pub rule: Color,
|
||||
pub done: Color,
|
||||
pub running: Color,
|
||||
pub waiting: Color,
|
||||
pub failed: Color,
|
||||
pub no_failures: Color,
|
||||
}
|
||||
|
||||
impl Default for FooterColors {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
rule: Color::DarkGray,
|
||||
done: Color::Green,
|
||||
running: Color::Yellow,
|
||||
waiting: Color::Gray,
|
||||
failed: Color::LightRed,
|
||||
no_failures: Color::Gray,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, Eq)]
|
||||
#[serde(default, deny_unknown_fields, rename_all = "kebab-case")]
|
||||
pub struct PasswordColors {
|
||||
pub frame: Color,
|
||||
pub message: Color,
|
||||
pub hint: Color,
|
||||
pub checking: Color,
|
||||
pub rejected: Color,
|
||||
pub backdrop: Color,
|
||||
}
|
||||
|
||||
impl Default for PasswordColors {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
frame: Color::Yellow,
|
||||
message: Color::White,
|
||||
hint: Color::DarkGray,
|
||||
checking: Color::Gray,
|
||||
rejected: Color::LightRed,
|
||||
backdrop: Color::DarkGray,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
use std::{fs, io, path::Path, time::Duration};
|
||||
|
||||
use heck::ToKebabCase;
|
||||
use jiff::fmt::serde::unsigned_duration::friendly::compact::required as friendly_duration;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use toml::{Table, Value, de::Error as ParseError, ser::Error as SerializeError};
|
||||
|
||||
use crate::screen_settings::color_scheme::Colors;
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, Deserialize, Serialize, PartialEq, Eq)]
|
||||
#[serde(default, deny_unknown_fields, rename_all = "kebab-case")]
|
||||
pub struct Config {
|
||||
pub colors: Colors,
|
||||
pub timing: Timing,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, Eq)]
|
||||
#[serde(default, deny_unknown_fields, rename_all = "kebab-case")]
|
||||
pub struct Timing {
|
||||
#[serde(with = "friendly_duration")]
|
||||
pub keep_finished_units_for: Duration,
|
||||
#[serde(with = "friendly_duration")]
|
||||
pub hide_runs_shorter_than: Duration,
|
||||
#[serde(with = "friendly_duration")]
|
||||
pub keep_final_frame_for: Duration,
|
||||
#[serde(with = "friendly_duration")]
|
||||
pub wait_for_display_manager: Duration,
|
||||
}
|
||||
|
||||
impl Default for Timing {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
keep_finished_units_for: Duration::from_secs(2),
|
||||
hide_runs_shorter_than: Duration::from_secs(1),
|
||||
keep_final_frame_for: Duration::from_secs(1),
|
||||
wait_for_display_manager: Duration::from_secs(10),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum ConfigError {
|
||||
#[error("cannot read: {0}")]
|
||||
Unreadable(#[from] io::Error),
|
||||
#[error("invalid: {0}")]
|
||||
Invalid(#[from] ParseError),
|
||||
}
|
||||
|
||||
pub fn read_config_file(path: &Path) -> Result<Config, ConfigError> {
|
||||
Ok(toml::from_str(&fs::read_to_string(path)?)?)
|
||||
}
|
||||
|
||||
pub fn default_config_table() -> Result<Table, SerializeError> {
|
||||
Table::try_from(Config::default()).map(kebab_color_names)
|
||||
}
|
||||
|
||||
fn kebab_color_names(table: Table) -> Table {
|
||||
table
|
||||
.into_iter()
|
||||
.map(|(key, value)| {
|
||||
let value = match value {
|
||||
Value::Table(nested) => Value::Table(kebab_color_names(nested)),
|
||||
Value::String(name) if name.starts_with(char::is_alphabetic) => {
|
||||
Value::String(name.to_kebab_case())
|
||||
}
|
||||
other => other,
|
||||
};
|
||||
(key, value)
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn printed_defaults() -> String {
|
||||
toml::to_string_pretty(&default_config_table().expect("serializable defaults"))
|
||||
.expect("printable defaults")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn timing_reads_friendly_durations_and_keeps_unset_defaults() {
|
||||
let config: Config = toml::from_str("[timing]\nkeep-finished-units-for = \"500ms\"\n")
|
||||
.expect("valid config");
|
||||
assert_eq!(
|
||||
config.timing.keep_finished_units_for,
|
||||
Duration::from_millis(500)
|
||||
);
|
||||
assert_eq!(
|
||||
config.timing.keep_final_frame_for,
|
||||
Timing::default().keep_final_frame_for
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nonsense_durations_are_rejected() {
|
||||
assert!(toml::from_str::<Config>("[timing]\nkeep-final-frame-for = \"soon\"\n").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unknown_color_keys_are_rejected() {
|
||||
assert!(toml::from_str::<Config>("[colors.tree]\nbogus = \"red\"\n").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn printed_defaults_read_back_unchanged() {
|
||||
let printed = printed_defaults();
|
||||
assert!(printed.contains("failed-unit = \"light-red\""), "{printed}");
|
||||
assert_eq!(
|
||||
toml::from_str::<Config>(&printed).expect("valid defaults"),
|
||||
Config::default()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub struct Glyphs {
|
||||
pub done: char,
|
||||
pub failed: char,
|
||||
pub bead: char,
|
||||
pub waiting_bead: char,
|
||||
pub still_going: char,
|
||||
pub growing_tip: Option<[char; 8]>,
|
||||
pub running_mark: char,
|
||||
pub root_switch_mark: char,
|
||||
pub stage_current: char,
|
||||
pub stage_upcoming: char,
|
||||
pub ellipsis: &'static str,
|
||||
pub chain_link: &'static str,
|
||||
}
|
||||
|
||||
const DONE: [char; 2] = ['√', '+'];
|
||||
const FAILED: [char; 2] = ['×', 'x'];
|
||||
const BEAD: [char; 2] = ['■', '#'];
|
||||
const WAITING_BEAD: [char; 2] = ['·', '.'];
|
||||
const STILL_GOING: [char; 2] = ['▶', '>'];
|
||||
const GROWING_TIP: [char; 8] = ['▏', '▎', '▍', '▌', '▋', '▊', '▉', '█'];
|
||||
const RUNNING_MARK: [char; 3] = ['►', '▶', '>'];
|
||||
const ROOT_SWITCH_MARK: [char; 2] = ['│', '|'];
|
||||
const STAGE_MARKS: [&str; 3] = ["◆◇", "●○", "*o"];
|
||||
const ELLIPSIS: [&str; 2] = ["…", "..."];
|
||||
const CHAIN_LINK: [&str; 2] = ["─", "-"];
|
||||
|
||||
impl Default for Glyphs {
|
||||
fn default() -> Self {
|
||||
Self::fitting(|_| true)
|
||||
}
|
||||
}
|
||||
|
||||
impl Glyphs {
|
||||
pub fn fitting(covers: impl Fn(char) -> bool) -> Self {
|
||||
let symbol = |candidates: &[char]| {
|
||||
candidates
|
||||
.iter()
|
||||
.copied()
|
||||
.find(|candidate| covers(*candidate))
|
||||
.unwrap_or(candidates[candidates.len() - 1])
|
||||
};
|
||||
let text = |candidates: &[&'static str]| {
|
||||
candidates
|
||||
.iter()
|
||||
.copied()
|
||||
.find(|candidate| candidate.chars().all(&covers))
|
||||
.unwrap_or(candidates[candidates.len() - 1])
|
||||
};
|
||||
let stage_marks: Vec<char> = text(&STAGE_MARKS).chars().collect();
|
||||
Self {
|
||||
done: symbol(&DONE),
|
||||
failed: symbol(&FAILED),
|
||||
bead: symbol(&BEAD),
|
||||
waiting_bead: symbol(&WAITING_BEAD),
|
||||
still_going: symbol(&STILL_GOING),
|
||||
growing_tip: GROWING_TIP
|
||||
.iter()
|
||||
.all(|eighth| covers(*eighth))
|
||||
.then_some(GROWING_TIP),
|
||||
running_mark: symbol(&RUNNING_MARK),
|
||||
root_switch_mark: symbol(&ROOT_SWITCH_MARK),
|
||||
stage_current: stage_marks[0],
|
||||
stage_upcoming: stage_marks[1],
|
||||
ellipsis: text(&ELLIPSIS),
|
||||
chain_link: text(&CHAIN_LINK),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
const LAT2_TERMINUS16: &str = "×■●▶·•…│├└─━█▒░↑↓←→≥";
|
||||
const DEFAULT8X16: &str = "√■○►▶·•│├└─▌▐█▓▒░▀▄↑↓←→≥";
|
||||
|
||||
fn covered_by(font: &'static str) -> impl Fn(char) -> bool {
|
||||
move |symbol| symbol.is_ascii() || font.contains(symbol)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_font_without_the_square_root_and_pointer_falls_back() {
|
||||
let glyphs = Glyphs::fitting(covered_by(LAT2_TERMINUS16));
|
||||
assert_eq!(glyphs.done, '+');
|
||||
assert_eq!(glyphs.running_mark, '▶');
|
||||
assert_eq!(glyphs.failed, '×');
|
||||
assert_eq!(glyphs.ellipsis, "…");
|
||||
assert_eq!((glyphs.stage_current, glyphs.stage_upcoming), ('*', 'o'));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_built_in_kernel_font_loses_the_cross_and_ellipsis() {
|
||||
let glyphs = Glyphs::fitting(covered_by(DEFAULT8X16));
|
||||
assert_eq!(glyphs.done, '√');
|
||||
assert_eq!(glyphs.failed, 'x');
|
||||
assert_eq!(glyphs.ellipsis, "...");
|
||||
assert_eq!(glyphs.chain_link, "─");
|
||||
assert_eq!((glyphs.stage_current, glyphs.stage_upcoming), ('*', 'o'));
|
||||
assert_eq!(glyphs.growing_tip, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn full_unicode_keeps_every_preferred_glyph() {
|
||||
let glyphs = Glyphs::default();
|
||||
assert_eq!((glyphs.done, glyphs.running_mark), ('√', '►'));
|
||||
assert_eq!(glyphs.growing_tip, Some(GROWING_TIP));
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
pub mod install_error;
|
||||
pub mod install_files;
|
||||
@@ -1,11 +0,0 @@
|
||||
use std::{io, path::PathBuf, process::ExitStatus};
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum InstallError {
|
||||
#[error("{}: {source}", path.display())]
|
||||
File { path: PathBuf, source: io::Error },
|
||||
#[error("could not run {program}: {source}")]
|
||||
Spawn { program: String, source: io::Error },
|
||||
#[error("{program} failed: {status}")]
|
||||
Failed { program: String, status: ExitStatus },
|
||||
}
|
||||
@@ -1,350 +0,0 @@
|
||||
use std::{
|
||||
env,
|
||||
ffi::OsString,
|
||||
fs::{self, Permissions},
|
||||
io::ErrorKind,
|
||||
iter::once,
|
||||
os::unix::fs::PermissionsExt,
|
||||
path::{Path, PathBuf},
|
||||
process::Command,
|
||||
};
|
||||
|
||||
use clap::{Args, ValueEnum};
|
||||
use rustix::process::geteuid;
|
||||
|
||||
use crate::system_install::install_error::InstallError;
|
||||
|
||||
const DRACUT_MODULE_DIR: &str = "/usr/lib/dracut/modules.d/90bootvine";
|
||||
const DRACUT_CONF: &str = "/etc/dracut.conf.d/bootvine.conf";
|
||||
const MKINITCPIO_HOOK: &str = "/usr/lib/initcpio/install/sd-bootvine";
|
||||
const PACKAGED_BINARY_PATH: &str = "/usr/bin/bootvine";
|
||||
|
||||
struct PackagedUnit {
|
||||
name: &'static str,
|
||||
contents: &'static str,
|
||||
}
|
||||
|
||||
const PACKAGED_UNITS: [PackagedUnit; 2] = [
|
||||
PackagedUnit {
|
||||
name: "bootvine.service",
|
||||
contents: include_str!("../../system-files/systemd/bootvine.service"),
|
||||
},
|
||||
PackagedUnit {
|
||||
name: "bootvine-shutdown.service",
|
||||
contents: include_str!("../../system-files/systemd/bootvine-shutdown.service"),
|
||||
},
|
||||
];
|
||||
const RESUME_DROP_IN_DIR: &str = "systemd-hibernate-resume.service.d";
|
||||
const RESUME_DROP_IN: PackagedUnit = PackagedUnit {
|
||||
name: "systemd-hibernate-resume.service.d/bootvine.conf",
|
||||
contents: include_str!(
|
||||
"../../system-files/systemd/systemd-hibernate-resume.service.d/bootvine.conf"
|
||||
),
|
||||
};
|
||||
const DRACUT_MODULE_SETUP: &str =
|
||||
include_str!("../../system-files/dracut/90bootvine/module-setup.sh");
|
||||
const MKINITCPIO_INSTALL_HOOK: &str =
|
||||
include_str!("../../system-files/mkinitcpio/install/sd-bootvine");
|
||||
const INITRD_GENERATORS: [InitrdGenerator; 2] =
|
||||
[InitrdGenerator::Dracut, InitrdGenerator::Mkinitcpio];
|
||||
|
||||
#[derive(Args)]
|
||||
pub struct InstallTarget {
|
||||
#[arg(
|
||||
long,
|
||||
default_value = "/usr",
|
||||
help = "Prefix for bin/bootvine and lib/systemd/system"
|
||||
)]
|
||||
prefix: PathBuf,
|
||||
#[arg(
|
||||
long,
|
||||
help = "Stage the files under this directory instead of /; skips sudo and systemctl"
|
||||
)]
|
||||
destdir: Option<PathBuf>,
|
||||
}
|
||||
|
||||
#[derive(Args)]
|
||||
pub struct InstallOptions {
|
||||
#[command(flatten)]
|
||||
target: InstallTarget,
|
||||
#[arg(
|
||||
long,
|
||||
value_enum,
|
||||
default_value_t = InitrdGenerator::None,
|
||||
help = "Also install the hook that adds bootvine to this initramfs generator"
|
||||
)]
|
||||
initrd: InitrdGenerator,
|
||||
#[arg(long, help = "Leave the units disabled")]
|
||||
no_enable: bool,
|
||||
}
|
||||
|
||||
#[derive(Args)]
|
||||
pub struct UninstallOptions {
|
||||
#[command(flatten)]
|
||||
target: InstallTarget,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, ValueEnum)]
|
||||
pub enum InitrdGenerator {
|
||||
None,
|
||||
Dracut,
|
||||
Mkinitcpio,
|
||||
}
|
||||
|
||||
struct InstalledFile {
|
||||
destination: PathBuf,
|
||||
contents: Vec<u8>,
|
||||
mode: u32,
|
||||
}
|
||||
|
||||
impl InstallTarget {
|
||||
fn staged(&self, path: &Path) -> PathBuf {
|
||||
match &self.destdir {
|
||||
Some(root) => root.join(path.strip_prefix("/").unwrap_or(path)),
|
||||
None => path.to_owned(),
|
||||
}
|
||||
}
|
||||
|
||||
fn changes_live_system(&self) -> bool {
|
||||
self.destdir.is_none()
|
||||
}
|
||||
|
||||
fn needs_sudo(&self) -> bool {
|
||||
self.changes_live_system() && !geteuid().is_root()
|
||||
}
|
||||
|
||||
fn binary_path(&self) -> PathBuf {
|
||||
self.prefix.join("bin/bootvine")
|
||||
}
|
||||
|
||||
fn unit_path(&self, unit: &str) -> PathBuf {
|
||||
self.prefix.join("lib/systemd/system").join(unit)
|
||||
}
|
||||
|
||||
fn every_installed_path(&self) -> Vec<PathBuf> {
|
||||
once(self.binary_path())
|
||||
.chain(unit_files(self).map(|file| file.destination))
|
||||
.chain(
|
||||
INITRD_GENERATORS
|
||||
.into_iter()
|
||||
.flat_map(initrd_hook_files)
|
||||
.map(|file| file.destination),
|
||||
)
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
impl InitrdGenerator {
|
||||
fn install_hint(self) -> Option<&'static str> {
|
||||
match self {
|
||||
Self::None => None,
|
||||
Self::Dracut => Some("rebuild the initramfs: sudo dracut --force"),
|
||||
Self::Mkinitcpio => Some(
|
||||
"add sd-bootvine after systemd in HOOKS in /etc/mkinitcpio.conf, then run: sudo \
|
||||
mkinitcpio -P",
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
fn removal_hint(self) -> Option<&'static str> {
|
||||
match self {
|
||||
Self::None => None,
|
||||
Self::Dracut => Some("rebuild the initramfs without bootvine: sudo dracut --force"),
|
||||
Self::Mkinitcpio => Some(
|
||||
"remove sd-bootvine from HOOKS in /etc/mkinitcpio.conf, then run: sudo mkinitcpio \
|
||||
-P",
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn running_binary() -> Result<PathBuf, InstallError> {
|
||||
env::current_exe().map_err(|source| InstallError::File {
|
||||
path: PathBuf::from("/proc/self/exe"),
|
||||
source,
|
||||
})
|
||||
}
|
||||
|
||||
fn binary_file(target: &InstallTarget) -> Result<Option<InstalledFile>, InstallError> {
|
||||
let running = running_binary()?;
|
||||
let destination = target.binary_path();
|
||||
if fs::canonicalize(target.staged(&destination)).is_ok_and(|resolved| resolved == running) {
|
||||
return Ok(None);
|
||||
}
|
||||
let contents = fs::read(&running).map_err(|source| InstallError::File {
|
||||
path: running,
|
||||
source,
|
||||
})?;
|
||||
Ok(Some(InstalledFile {
|
||||
destination,
|
||||
contents,
|
||||
mode: 0o755,
|
||||
}))
|
||||
}
|
||||
|
||||
fn unit_files(target: &InstallTarget) -> impl Iterator<Item = InstalledFile> {
|
||||
let binary_path = target.binary_path();
|
||||
PACKAGED_UNITS
|
||||
.iter()
|
||||
.chain(once(&RESUME_DROP_IN))
|
||||
.map(move |unit| InstalledFile {
|
||||
destination: target.unit_path(unit.name),
|
||||
contents: unit
|
||||
.contents
|
||||
.replace(PACKAGED_BINARY_PATH, &binary_path.to_string_lossy())
|
||||
.into_bytes(),
|
||||
mode: 0o644,
|
||||
})
|
||||
}
|
||||
|
||||
fn initrd_hook_files(initrd: InitrdGenerator) -> Vec<InstalledFile> {
|
||||
match initrd {
|
||||
InitrdGenerator::None => Vec::new(),
|
||||
InitrdGenerator::Dracut => vec![
|
||||
InstalledFile {
|
||||
destination: Path::new(DRACUT_MODULE_DIR).join("module-setup.sh"),
|
||||
contents: DRACUT_MODULE_SETUP.as_bytes().to_vec(),
|
||||
mode: 0o755,
|
||||
},
|
||||
InstalledFile {
|
||||
destination: PathBuf::from(DRACUT_CONF),
|
||||
contents: b"add_dracutmodules+=\" bootvine \"\n".to_vec(),
|
||||
mode: 0o644,
|
||||
},
|
||||
],
|
||||
InitrdGenerator::Mkinitcpio => vec![InstalledFile {
|
||||
destination: PathBuf::from(MKINITCPIO_HOOK),
|
||||
contents: MKINITCPIO_INSTALL_HOOK.as_bytes().to_vec(),
|
||||
mode: 0o644,
|
||||
}],
|
||||
}
|
||||
}
|
||||
|
||||
fn sibling_for_replacement(path: &Path) -> PathBuf {
|
||||
let mut file_name = OsString::from(".");
|
||||
file_name.push(path.file_name().unwrap_or_default());
|
||||
file_name.push(".bootvine-new");
|
||||
path.with_file_name(file_name)
|
||||
}
|
||||
|
||||
fn write_installed_file(target: &InstallTarget, file: &InstalledFile) -> Result<(), InstallError> {
|
||||
let path = target.staged(&file.destination);
|
||||
let replacement = sibling_for_replacement(&path);
|
||||
path.parent()
|
||||
.map_or(Ok(()), fs::create_dir_all)
|
||||
.and_then(|()| fs::write(&replacement, &file.contents))
|
||||
.and_then(|()| fs::set_permissions(&replacement, Permissions::from_mode(file.mode)))
|
||||
.and_then(|()| fs::rename(&replacement, &path))
|
||||
.map_err(|source| InstallError::File { path, source })
|
||||
}
|
||||
|
||||
fn remove_if_present(path: PathBuf) -> Result<(), InstallError> {
|
||||
match fs::remove_file(&path) {
|
||||
Err(error) if error.kind() != ErrorKind::NotFound => Err(InstallError::File {
|
||||
path,
|
||||
source: error,
|
||||
}),
|
||||
_ => Ok(()),
|
||||
}
|
||||
}
|
||||
|
||||
fn run_command(command: &mut Command) -> Result<(), InstallError> {
|
||||
let program = command.get_program().to_string_lossy().into_owned();
|
||||
let status = command.status().map_err(|source| InstallError::Spawn {
|
||||
program: program.clone(),
|
||||
source,
|
||||
})?;
|
||||
if status.success() {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(InstallError::Failed { program, status })
|
||||
}
|
||||
}
|
||||
|
||||
fn systemctl<'a>(arguments: impl IntoIterator<Item = &'a str>) -> Result<(), InstallError> {
|
||||
run_command(Command::new("systemctl").args(arguments))
|
||||
}
|
||||
|
||||
fn unit_names() -> impl Iterator<Item = &'static str> {
|
||||
PACKAGED_UNITS.iter().map(|unit| unit.name)
|
||||
}
|
||||
|
||||
fn rerun_with_sudo() -> Result<(), InstallError> {
|
||||
run_command(
|
||||
Command::new("sudo")
|
||||
.arg(running_binary()?)
|
||||
.args(env::args_os().skip(1)),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn install_files(options: &InstallOptions) -> Result<(), InstallError> {
|
||||
let target = &options.target;
|
||||
if target.needs_sudo() {
|
||||
return rerun_with_sudo();
|
||||
}
|
||||
binary_file(target)?
|
||||
.into_iter()
|
||||
.chain(unit_files(target))
|
||||
.chain(initrd_hook_files(options.initrd))
|
||||
.try_for_each(|file| write_installed_file(target, &file))?;
|
||||
if target.changes_live_system() {
|
||||
systemctl(["daemon-reload"])?;
|
||||
if !options.no_enable {
|
||||
systemctl(once("enable").chain(unit_names()))?;
|
||||
}
|
||||
if let Some(hint) = options.initrd.install_hint() {
|
||||
println!("{hint}");
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn installed_initrd_hooks(target: &InstallTarget) -> Vec<InitrdGenerator> {
|
||||
INITRD_GENERATORS
|
||||
.into_iter()
|
||||
.filter(|generator| {
|
||||
initrd_hook_files(*generator)
|
||||
.iter()
|
||||
.any(|file| target.staged(&file.destination).exists())
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn uninstall_files(options: &UninstallOptions) -> Result<(), InstallError> {
|
||||
let target = &options.target;
|
||||
if target.needs_sudo() {
|
||||
return rerun_with_sudo();
|
||||
}
|
||||
let removed_initrd_hooks = installed_initrd_hooks(target);
|
||||
if target.changes_live_system() {
|
||||
let installed_units: Vec<&str> = unit_names()
|
||||
.filter(|unit| target.unit_path(unit).exists())
|
||||
.collect();
|
||||
if !installed_units.is_empty() {
|
||||
systemctl(once("disable").chain(installed_units))?;
|
||||
}
|
||||
}
|
||||
target
|
||||
.every_installed_path()
|
||||
.into_iter()
|
||||
.try_for_each(|path| remove_if_present(target.staged(&path)))?;
|
||||
let _ = fs::remove_dir(target.staged(&target.unit_path(RESUME_DROP_IN_DIR)));
|
||||
let dracut_module_dir = target.staged(Path::new(DRACUT_MODULE_DIR));
|
||||
match fs::remove_dir(&dracut_module_dir) {
|
||||
Err(error) if error.kind() == ErrorKind::DirectoryNotEmpty => {
|
||||
return Err(InstallError::File {
|
||||
path: dracut_module_dir,
|
||||
source: error,
|
||||
});
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
if target.changes_live_system() {
|
||||
systemctl(["daemon-reload"])?;
|
||||
removed_initrd_hooks
|
||||
.into_iter()
|
||||
.filter_map(InitrdGenerator::removal_hint)
|
||||
.for_each(|hint| println!("{hint}"));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
pub mod boot_feed;
|
||||
mod journal_tail;
|
||||
pub mod link_error;
|
||||
pub mod monotonic_clock;
|
||||
pub mod switch_root;
|
||||
pub mod systemd_bus;
|
||||
@@ -1,591 +0,0 @@
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
iter::once,
|
||||
process,
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
|
||||
use dbus::Path;
|
||||
use futures::{Stream, StreamExt, stream};
|
||||
use tokio::time::sleep;
|
||||
|
||||
use crate::{
|
||||
boot_model::{
|
||||
ActiveState, Activity, BootChange, BootState, FailureCause, HANDOFF_UNIT, JobKind,
|
||||
JobResult, Phase, UnitFacts,
|
||||
},
|
||||
console_session::{
|
||||
stream_sources::{BACKGROUND_CHECK_INTERVAL, CarriedItem, unfold_carrying},
|
||||
watch_screen::ScreenInput,
|
||||
},
|
||||
systemd_link::{
|
||||
journal_tail::recent_unit_messages,
|
||||
link_error::Error,
|
||||
monotonic_clock::monotonic_now,
|
||||
switch_root::Sysroot,
|
||||
systemd_bus::{
|
||||
BusConnection, FetchedUnit, JobListing, Scope, Session, Signal, SignalBatch,
|
||||
StatusOutput,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const RECONNECT_PATIENCE: Duration = Duration::from_secs(60);
|
||||
const JOURNAL_SETTLING_WAITS: [Duration; 3] = [
|
||||
Duration::from_millis(200),
|
||||
Duration::from_millis(300),
|
||||
Duration::from_millis(500),
|
||||
];
|
||||
const LOG_LINES_KEPT: usize = 6;
|
||||
const SWITCH_ROOT_UNIT: &str = "initrd-switch-root.service";
|
||||
const SHUTDOWN_ROOTS: [&str; 5] = [
|
||||
"poweroff.target",
|
||||
"reboot.target",
|
||||
"halt.target",
|
||||
"kexec.target",
|
||||
"soft-reboot.target",
|
||||
];
|
||||
const SHUTDOWN_FALLBACK_ROOT: &str = "shutdown.target";
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub enum RootRequest {
|
||||
Named(String),
|
||||
ManagerDefault,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||
enum ConnectAttempt {
|
||||
First,
|
||||
Again,
|
||||
}
|
||||
|
||||
enum Link {
|
||||
Connected(BusConnection),
|
||||
Connecting {
|
||||
deadline: Instant,
|
||||
attempt: ConnectAttempt,
|
||||
},
|
||||
Finished,
|
||||
}
|
||||
|
||||
impl Link {
|
||||
fn connecting(attempt: ConnectAttempt) -> Self {
|
||||
Self::Connecting {
|
||||
deadline: Instant::now() + RECONNECT_PATIENCE,
|
||||
attempt,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum RootSwitch {
|
||||
NotQueued,
|
||||
Queued(Sysroot),
|
||||
}
|
||||
|
||||
enum TrackedUnit {
|
||||
Known(String),
|
||||
New {
|
||||
facts: UnitFacts,
|
||||
activity: Activity,
|
||||
},
|
||||
}
|
||||
|
||||
impl TrackedUnit {
|
||||
fn name(&self) -> &str {
|
||||
match self {
|
||||
Self::Known(name) => name,
|
||||
Self::New { facts, .. } => &facts.name,
|
||||
}
|
||||
}
|
||||
|
||||
fn into_change(self) -> Option<BootChange> {
|
||||
match self {
|
||||
Self::Known(_) => None,
|
||||
Self::New { facts, activity } => Some(BootChange::TrackUnit { facts, activity }),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn queued_units(signals: &[Signal]) -> impl Iterator<Item = &str> {
|
||||
signals.iter().filter_map(|signal| match signal {
|
||||
Signal::JobNew { unit, .. } => Some(unit.as_str()),
|
||||
_ => None,
|
||||
})
|
||||
}
|
||||
|
||||
fn connected_inputs(changes: Vec<BootChange>, switching_root: bool) -> Vec<ScreenInput> {
|
||||
(!changes.is_empty())
|
||||
.then_some(ScreenInput::Boot(changes))
|
||||
.into_iter()
|
||||
.chain(switching_root.then_some(ScreenInput::FullRepaint))
|
||||
.collect()
|
||||
}
|
||||
|
||||
struct BootTracker {
|
||||
scope: Scope,
|
||||
target: RootRequest,
|
||||
phase: Phase,
|
||||
unit_paths: HashMap<Path<'static>, String>,
|
||||
explained_failures: HashSet<String>,
|
||||
units_in_failed_state: HashSet<String>,
|
||||
root_switch: RootSwitch,
|
||||
}
|
||||
|
||||
struct BusFeed {
|
||||
link: Link,
|
||||
tracker: BootTracker,
|
||||
}
|
||||
|
||||
struct FeedProgress<'feed> {
|
||||
tracker: &'feed mut BootTracker,
|
||||
connection: &'feed mut BusConnection,
|
||||
changes: Vec<BootChange>,
|
||||
}
|
||||
|
||||
impl BusFeed {
|
||||
fn new(phase: Phase, scope: Scope, target: RootRequest) -> Self {
|
||||
Self {
|
||||
link: Link::connecting(ConnectAttempt::First),
|
||||
tracker: BootTracker {
|
||||
scope,
|
||||
target,
|
||||
phase,
|
||||
unit_paths: HashMap::new(),
|
||||
explained_failures: HashSet::new(),
|
||||
units_in_failed_state: HashSet::new(),
|
||||
root_switch: RootSwitch::NotQueued,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
async fn next_inputs(&mut self) -> Option<Vec<ScreenInput>> {
|
||||
match &mut self.link {
|
||||
Link::Finished => None,
|
||||
Link::Connecting { deadline, attempt } => {
|
||||
let deadline = *deadline;
|
||||
let attempt = *attempt;
|
||||
Some(self.connect(deadline, attempt).await)
|
||||
}
|
||||
Link::Connected(connection) => {
|
||||
let received = self.tracker.receive(connection).await;
|
||||
let switching_root = matches!(self.tracker.root_switch, RootSwitch::Queued(_));
|
||||
Some(match received {
|
||||
Ok(changes) => connected_inputs(changes, switching_root),
|
||||
Err(_) => self.lose_connection(),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async fn open_watched(&mut self, attempt: ConnectAttempt) -> Result<Vec<BootChange>, Error> {
|
||||
let mut connection = BusConnection::register(Session::open(self.tracker.scope)?)?;
|
||||
let changes = self
|
||||
.tracker
|
||||
.start_watching(&mut connection, attempt)
|
||||
.await?;
|
||||
self.link = Link::Connected(connection);
|
||||
Ok(changes)
|
||||
}
|
||||
|
||||
async fn connect(&mut self, deadline: Instant, attempt: ConnectAttempt) -> Vec<ScreenInput> {
|
||||
match self.open_watched(attempt).await {
|
||||
Ok(changes) => vec![ScreenInput::Boot(changes), ScreenInput::FullRepaint],
|
||||
Err(_) if Instant::now() < deadline => {
|
||||
sleep(BACKGROUND_CHECK_INTERVAL).await;
|
||||
vec![ScreenInput::FullRepaint]
|
||||
}
|
||||
Err(_) => {
|
||||
self.link = Link::Finished;
|
||||
vec![ScreenInput::Failed(Error::ManagerUnreachable)]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn lose_connection(&mut self) -> Vec<ScreenInput> {
|
||||
let at = monotonic_now();
|
||||
let tracker = &mut self.tracker;
|
||||
let RootSwitch::Queued(sysroot) = &tracker.root_switch else {
|
||||
if tracker.phase == Phase::Shutdown {
|
||||
self.link = Link::Finished;
|
||||
return vec![ScreenInput::Boot(vec![BootChange::ManagerExited { at }])];
|
||||
}
|
||||
self.link = Link::connecting(ConnectAttempt::Again);
|
||||
return vec![ScreenInput::Boot(vec![BootChange::ForgetJobs])];
|
||||
};
|
||||
if let Err(error) = sysroot.enter() {
|
||||
self.link = Link::Finished;
|
||||
return vec![ScreenInput::Failed(error.into())];
|
||||
}
|
||||
tracker.root_switch = RootSwitch::NotQueued;
|
||||
tracker.unit_paths.clear();
|
||||
tracker.explained_failures.clear();
|
||||
tracker.units_in_failed_state.clear();
|
||||
tracker.phase = Phase::Host;
|
||||
self.link = Link::connecting(ConnectAttempt::Again);
|
||||
vec![ScreenInput::Boot(vec![BootChange::SwitchRoot { at }])]
|
||||
}
|
||||
}
|
||||
|
||||
impl BootTracker {
|
||||
async fn receive(&mut self, connection: &mut BusConnection) -> Result<Vec<BootChange>, Error> {
|
||||
match connection.receive_signals(BACKGROUND_CHECK_INTERVAL).await {
|
||||
SignalBatch::Open(signals) => {
|
||||
self.arm_root_switch(queued_units(&signals));
|
||||
Ok(self
|
||||
.collect_changes(connection, signals, async |tracker, connection, signal| {
|
||||
tracker.changes_for(connection, signal).await
|
||||
})
|
||||
.await)
|
||||
}
|
||||
SignalBatch::Closed(signals) => {
|
||||
self.arm_root_switch(queued_units(&signals));
|
||||
Err(Error::Disconnected)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn arm_root_switch<'unit>(&mut self, mut queued_units: impl Iterator<Item = &'unit str>) {
|
||||
if self.phase == Phase::Initrd
|
||||
&& matches!(self.root_switch, RootSwitch::NotQueued)
|
||||
&& queued_units.any(|unit| unit == SWITCH_ROOT_UNIT)
|
||||
&& let Ok(sysroot) = Sysroot::hold()
|
||||
{
|
||||
self.root_switch = RootSwitch::Queued(sysroot);
|
||||
}
|
||||
}
|
||||
|
||||
async fn collect_changes<Item>(
|
||||
&mut self,
|
||||
connection: &mut BusConnection,
|
||||
items: Vec<Item>,
|
||||
step: impl AsyncFn(&mut Self, &mut BusConnection, Item) -> Vec<BootChange>,
|
||||
) -> Vec<BootChange> {
|
||||
let step = &step;
|
||||
stream::iter(items)
|
||||
.fold(
|
||||
FeedProgress {
|
||||
tracker: self,
|
||||
connection,
|
||||
changes: Vec::new(),
|
||||
},
|
||||
|mut progress, item| async move {
|
||||
let changes = step(progress.tracker, progress.connection, item).await;
|
||||
progress.changes.extend(changes);
|
||||
progress
|
||||
},
|
||||
)
|
||||
.await
|
||||
.changes
|
||||
}
|
||||
|
||||
async fn requested_root(
|
||||
&self,
|
||||
connection: &mut BusConnection,
|
||||
jobs: &[JobListing],
|
||||
) -> Result<String, Error> {
|
||||
let RootRequest::Named(target) = &self.target else {
|
||||
if self.phase != Phase::Shutdown {
|
||||
return connection.default_target().await;
|
||||
}
|
||||
return Ok(SHUTDOWN_ROOTS
|
||||
.into_iter()
|
||||
.find(|root| {
|
||||
jobs.iter()
|
||||
.any(|job| job.unit == *root && job.kind == JobKind::BringsUp)
|
||||
})
|
||||
.unwrap_or(SHUTDOWN_FALLBACK_ROOT)
|
||||
.to_owned());
|
||||
};
|
||||
Ok(target.clone())
|
||||
}
|
||||
|
||||
async fn boot_progress_changes(
|
||||
&self,
|
||||
connection: &mut BusConnection,
|
||||
attempt: ConnectAttempt,
|
||||
) -> Result<Vec<BootChange>, Error> {
|
||||
let boot_in_progress = connection.boot_in_progress().await?;
|
||||
let origin = (attempt == ConnectAttempt::First).then(|| {
|
||||
BootChange::SetOrigin(if boot_in_progress {
|
||||
Duration::ZERO
|
||||
} else {
|
||||
monotonic_now()
|
||||
})
|
||||
});
|
||||
let finished = if boot_in_progress {
|
||||
Vec::new()
|
||||
} else {
|
||||
self.boot_finished()
|
||||
};
|
||||
Ok(origin.into_iter().chain(finished).collect())
|
||||
}
|
||||
|
||||
async fn start_watching(
|
||||
&mut self,
|
||||
connection: &mut BusConnection,
|
||||
attempt: ConnectAttempt,
|
||||
) -> Result<Vec<BootChange>, Error> {
|
||||
connection.subscribe().await?;
|
||||
if self.scope == Scope::System {
|
||||
connection.set_show_status(StatusOutput::Silent).await.ok();
|
||||
}
|
||||
let shutting_down = self.phase == Phase::Shutdown;
|
||||
let jobs: Vec<JobListing> = connection
|
||||
.list_jobs()
|
||||
.await?
|
||||
.into_iter()
|
||||
.filter(|job| shutting_down || job.kind == JobKind::BringsUp)
|
||||
.collect();
|
||||
self.arm_root_switch(jobs.iter().map(|job| job.unit.as_str()));
|
||||
let requested_root = self.requested_root(connection, &jobs).await?;
|
||||
let boot_progress = self.boot_progress_changes(connection, attempt).await?;
|
||||
let tracked_root = self.track(connection, &requested_root).await;
|
||||
let root = tracked_root
|
||||
.as_ref()
|
||||
.map_or(requested_root, |tracked| tracked.name().to_owned());
|
||||
let tracked_handoff = self.track(connection, HANDOFF_UNIT).await;
|
||||
let handoff = tracked_handoff
|
||||
.as_ref()
|
||||
.map(|tracked| BootChange::SetHandoff(tracked.name().to_owned()));
|
||||
let watched_units = jobs
|
||||
.iter()
|
||||
.map(|job| job.unit.clone())
|
||||
.chain(BootState::new(self.phase).milestone_targets)
|
||||
.collect();
|
||||
let tracked_changes = self
|
||||
.collect_changes(
|
||||
connection,
|
||||
watched_units,
|
||||
async |tracker, connection, unit| {
|
||||
tracker
|
||||
.track(connection, &unit)
|
||||
.await
|
||||
.and_then(TrackedUnit::into_change)
|
||||
.into_iter()
|
||||
.collect()
|
||||
},
|
||||
)
|
||||
.await;
|
||||
eprintln!(
|
||||
"bootvine: watching {root} in {} as pid {} over {}",
|
||||
self.phase.label(),
|
||||
process::id(),
|
||||
if connection.peer_to_peer() {
|
||||
"the private socket"
|
||||
} else {
|
||||
"the bus"
|
||||
},
|
||||
);
|
||||
let queued_at = monotonic_now();
|
||||
Ok(boot_progress
|
||||
.into_iter()
|
||||
.chain(tracked_root.and_then(TrackedUnit::into_change))
|
||||
.chain(tracked_handoff.and_then(TrackedUnit::into_change))
|
||||
.chain(handoff)
|
||||
.chain(tracked_changes)
|
||||
.chain(once(BootChange::SetRoot(root)))
|
||||
.chain(jobs.into_iter().map(|job| BootChange::QueueJob {
|
||||
id: job.id,
|
||||
unit: job.unit,
|
||||
kind: job.kind,
|
||||
at: queued_at,
|
||||
}))
|
||||
.collect())
|
||||
}
|
||||
|
||||
async fn track(&mut self, connection: &mut BusConnection, unit: &str) -> Option<TrackedUnit> {
|
||||
if self.unit_paths.values().any(|known| known == unit) {
|
||||
return Some(TrackedUnit::Known(unit.to_owned()));
|
||||
}
|
||||
let FetchedUnit {
|
||||
path,
|
||||
facts,
|
||||
activity,
|
||||
} = connection.fetch_unit(unit).await.ok()?;
|
||||
if self.unit_paths.values().any(|known| *known == facts.name) {
|
||||
return Some(TrackedUnit::Known(facts.name));
|
||||
}
|
||||
self.unit_paths.insert(path, facts.name.clone());
|
||||
Some(TrackedUnit::New { facts, activity })
|
||||
}
|
||||
|
||||
async fn changes_for(
|
||||
&mut self,
|
||||
connection: &mut BusConnection,
|
||||
signal: Signal,
|
||||
) -> Vec<BootChange> {
|
||||
let at = monotonic_now();
|
||||
match signal {
|
||||
Signal::JobNew { id, job, unit } => {
|
||||
self.queue_new_job(connection, id, &job, unit, at).await
|
||||
}
|
||||
Signal::JobRemoved { id, unit, result } => {
|
||||
let explanation = match result {
|
||||
JobResult::Failed => self.explain_failure(connection, unit, "failed").await,
|
||||
JobResult::Timeout => self.explain_failure(connection, unit, "timed out").await,
|
||||
_ => None,
|
||||
};
|
||||
once(BootChange::FinishJob { id, result, at })
|
||||
.chain(explanation)
|
||||
.collect()
|
||||
}
|
||||
Signal::UnitChanged { path, activity } => {
|
||||
let Some(unit) = self.unit_paths.get(&path).cloned() else {
|
||||
return Vec::new();
|
||||
};
|
||||
let explanation = if self.enters_failed_state(&unit, activity) {
|
||||
self.explain_failure(connection, unit.clone(), "failed")
|
||||
.await
|
||||
} else {
|
||||
None
|
||||
};
|
||||
once(BootChange::UpdateActivity { unit, activity })
|
||||
.chain(explanation)
|
||||
.collect()
|
||||
}
|
||||
Signal::BootFinished => self.boot_finished(),
|
||||
}
|
||||
}
|
||||
|
||||
fn enters_failed_state(&mut self, unit: &str, activity: Activity) -> bool {
|
||||
match activity.state {
|
||||
Some(ActiveState::Failed) => self.units_in_failed_state.insert(unit.to_owned()),
|
||||
Some(_) => {
|
||||
self.units_in_failed_state.remove(unit);
|
||||
false
|
||||
}
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
|
||||
async fn explain_failure(
|
||||
&mut self,
|
||||
connection: &mut BusConnection,
|
||||
unit: String,
|
||||
fallback_reason: &str,
|
||||
) -> Option<BootChange> {
|
||||
if !self.unit_paths.values().any(|known| *known == unit) {
|
||||
return None;
|
||||
}
|
||||
self.explained_failures.insert(unit.clone());
|
||||
let reason = connection
|
||||
.failure_reason(&unit)
|
||||
.await
|
||||
.ok()
|
||||
.flatten()
|
||||
.unwrap_or_else(|| fallback_reason.to_owned());
|
||||
let log_lines = settled_unit_messages(&unit).await;
|
||||
Some(BootChange::ExplainFailure {
|
||||
unit,
|
||||
cause: FailureCause { reason, log_lines },
|
||||
})
|
||||
}
|
||||
|
||||
fn boot_finished(&self) -> Vec<BootChange> {
|
||||
(self.phase == Phase::Host)
|
||||
.then_some(BootChange::BootFinished)
|
||||
.into_iter()
|
||||
.collect()
|
||||
}
|
||||
|
||||
async fn queue_new_job(
|
||||
&mut self,
|
||||
connection: &mut BusConnection,
|
||||
id: u32,
|
||||
job: &Path<'static>,
|
||||
unit: String,
|
||||
at: Duration,
|
||||
) -> Vec<BootChange> {
|
||||
let kind = connection.job_kind(job).await.unwrap_or(JobKind::Unknown);
|
||||
if kind == JobKind::TakesDown && self.phase != Phase::Shutdown {
|
||||
return Vec::new();
|
||||
}
|
||||
let tracked = self.track(connection, &unit).await;
|
||||
let unit = tracked
|
||||
.as_ref()
|
||||
.map_or(unit, |tracked| tracked.name().to_owned());
|
||||
tracked
|
||||
.and_then(TrackedUnit::into_change)
|
||||
.into_iter()
|
||||
.chain(once(BootChange::QueueJob { id, unit, kind, at }))
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
async fn settled_unit_messages(unit: &str) -> Vec<String> {
|
||||
for settling in JOURNAL_SETTLING_WAITS {
|
||||
sleep(settling).await;
|
||||
let log_lines = recent_unit_messages(unit.to_owned(), LOG_LINES_KEPT).await;
|
||||
if !log_lines.is_empty() {
|
||||
return log_lines;
|
||||
}
|
||||
}
|
||||
Vec::new()
|
||||
}
|
||||
|
||||
pub fn bus_inputs(
|
||||
phase: Phase,
|
||||
scope: Scope,
|
||||
target: RootRequest,
|
||||
) -> impl Stream<Item = ScreenInput> {
|
||||
unfold_carrying(BusFeed::new(phase, scope, target), |mut feed| async move {
|
||||
let inputs = feed.next_inputs().await?;
|
||||
Some(CarriedItem {
|
||||
item: inputs,
|
||||
state: feed,
|
||||
})
|
||||
})
|
||||
.flat_map(stream::iter)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn host_tracker() -> BootTracker {
|
||||
BootTracker {
|
||||
scope: Scope::System,
|
||||
target: RootRequest::ManagerDefault,
|
||||
phase: Phase::Host,
|
||||
unit_paths: HashMap::new(),
|
||||
explained_failures: HashSet::new(),
|
||||
units_in_failed_state: HashSet::new(),
|
||||
root_switch: RootSwitch::NotQueued,
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_screen_is_repainted_only_while_the_root_switches() {
|
||||
assert!(connected_inputs(Vec::new(), false).is_empty());
|
||||
assert!(matches!(
|
||||
connected_inputs(Vec::new(), true).as_slice(),
|
||||
[ScreenInput::FullRepaint]
|
||||
));
|
||||
assert!(matches!(
|
||||
connected_inputs(vec![BootChange::ForgetJobs], true).as_slice(),
|
||||
[ScreenInput::Boot(_), ScreenInput::FullRepaint]
|
||||
));
|
||||
assert!(matches!(
|
||||
connected_inputs(vec![BootChange::ForgetJobs], false).as_slice(),
|
||||
[ScreenInput::Boot(_)]
|
||||
));
|
||||
}
|
||||
|
||||
fn in_state(state: ActiveState) -> Activity {
|
||||
Activity {
|
||||
state: Some(state),
|
||||
..Activity::default()
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn only_entering_the_failed_state_asks_for_a_fresh_explanation() {
|
||||
let mut tracker = host_tracker();
|
||||
let unit = "http-listener.service";
|
||||
assert!(tracker.enters_failed_state(unit, in_state(ActiveState::Failed)));
|
||||
assert!(!tracker.enters_failed_state(unit, in_state(ActiveState::Failed)));
|
||||
assert!(!tracker.enters_failed_state(unit, Activity::default()));
|
||||
assert!(!tracker.enters_failed_state(unit, in_state(ActiveState::Activating)));
|
||||
assert!(tracker.enters_failed_state(unit, in_state(ActiveState::Failed)));
|
||||
}
|
||||
}
|
||||
@@ -1,132 +0,0 @@
|
||||
use std::{io, str::Chars};
|
||||
|
||||
use systemd::{
|
||||
id128::Id128,
|
||||
journal::{Journal, OpenOptions},
|
||||
};
|
||||
use tokio::task::spawn_blocking;
|
||||
|
||||
const UNIT_FIELDS: [&str; 4] = ["_SYSTEMD_UNIT", "UNIT", "_SYSTEMD_USER_UNIT", "USER_UNIT"];
|
||||
const MANAGER_SUMMARY_MESSAGE_IDS: [&str; 10] = [
|
||||
"7d4958e842da4a758f6c1cdc7b36dcc5",
|
||||
"39f53479d3a045ac8e11786248231fbf",
|
||||
"7ad2d189f7e94e70a38c781354912448",
|
||||
"5eb03494b6584870a536b337290809b3",
|
||||
"be02cf6855d2428ba40df7e9d022f03d",
|
||||
"de5b426a63be47a7b6ac3eaac82e2f6f",
|
||||
"9d1aaa27d60140bd96365438aad20286",
|
||||
"ae8f7b866b0347b9af31fe1c80b127c0",
|
||||
"d9b373ed55a64feb8242e02dbe79a49c",
|
||||
"98e322203f7a4ed290d09fe03c09fe15",
|
||||
];
|
||||
const ENTRIES_SCANNED: usize = 200;
|
||||
const ESCAPE: char = '\u{1b}';
|
||||
|
||||
pub async fn recent_unit_messages(unit: String, wanted: usize) -> Vec<String> {
|
||||
spawn_blocking(move || {
|
||||
read_recent_messages(&unit, wanted).unwrap_or_else(|error| {
|
||||
eprintln!("bootvine: reading the journal of {unit}: {error}");
|
||||
Vec::new()
|
||||
})
|
||||
})
|
||||
.await
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
fn read_recent_messages(unit: &str, wanted: usize) -> io::Result<Vec<String>> {
|
||||
let mut journal = OpenOptions::default().open()?;
|
||||
match_unit_in_this_boot(&mut journal, unit)?;
|
||||
journal.seek_tail()?;
|
||||
let mut newest_first = Vec::new();
|
||||
let mut scanned = 0;
|
||||
while newest_first.len() < wanted
|
||||
&& scanned < ENTRIES_SCANNED
|
||||
&& journal.previous().is_ok_and(|moved| moved > 0)
|
||||
{
|
||||
scanned += 1;
|
||||
if is_manager_summary(&mut journal).unwrap_or(true) {
|
||||
continue;
|
||||
}
|
||||
if let Ok(Some(message)) = entry_message(&mut journal) {
|
||||
newest_first.push(message);
|
||||
}
|
||||
}
|
||||
newest_first.reverse();
|
||||
Ok(newest_first)
|
||||
}
|
||||
|
||||
fn match_unit_in_this_boot(journal: &mut Journal, unit: &str) -> io::Result<()> {
|
||||
UNIT_FIELDS.iter().try_for_each(|field| {
|
||||
journal.match_add(field, unit)?.match_or()?;
|
||||
Ok::<_, io::Error>(())
|
||||
})?;
|
||||
journal
|
||||
.match_and()?
|
||||
.match_add("_BOOT_ID", Id128::from_boot()?.to_string())?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn field_text(journal: &mut Journal, field: &str) -> io::Result<Option<String>> {
|
||||
Ok(journal.get_data(field)?.and_then(|entry_field| {
|
||||
entry_field
|
||||
.value()
|
||||
.map(|value| String::from_utf8_lossy(value).into_owned())
|
||||
}))
|
||||
}
|
||||
|
||||
fn is_manager_summary(journal: &mut Journal) -> io::Result<bool> {
|
||||
Ok(field_text(journal, "MESSAGE_ID")?
|
||||
.is_some_and(|message_id| MANAGER_SUMMARY_MESSAGE_IDS.contains(&message_id.as_str())))
|
||||
}
|
||||
|
||||
fn entry_message(journal: &mut Journal) -> io::Result<Option<String>> {
|
||||
Ok(field_text(journal, "MESSAGE")?
|
||||
.map(|message| printable_line(&message))
|
||||
.filter(|line| !line.is_empty()))
|
||||
}
|
||||
|
||||
fn printable_line(message: &str) -> String {
|
||||
let mut characters = message.lines().next().unwrap_or_default().chars();
|
||||
let mut printable = String::new();
|
||||
while let Some(character) = characters.next() {
|
||||
if character == ESCAPE {
|
||||
skip_escape_sequence(&mut characters);
|
||||
} else if !character.is_control() {
|
||||
printable.push(character);
|
||||
}
|
||||
}
|
||||
printable.trim_end().to_owned()
|
||||
}
|
||||
|
||||
fn skip_escape_sequence(characters: &mut Chars<'_>) {
|
||||
if characters.clone().next() == Some('[') {
|
||||
characters.next();
|
||||
characters.find(|character| ('@'..='~').contains(character));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::env;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
#[ignore = "reads this machine's journal: cargo test journal_of_this_boot -- --ignored \
|
||||
--nocapture"]
|
||||
fn journal_of_this_boot_has_lines_for_journald() {
|
||||
let unit = env::var("BOOTVINE_JOURNAL_UNIT")
|
||||
.unwrap_or_else(|_| "systemd-journald.service".to_owned());
|
||||
let lines = read_recent_messages(&unit, 6).expect("readable journal");
|
||||
lines.iter().for_each(|line| println!("{line}"));
|
||||
assert!(!lines.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn printable_line_keeps_the_first_line_without_colours() {
|
||||
assert_eq!(
|
||||
printable_line("\u{1b}[31mno such file\u{1b}[0m\nsecond line"),
|
||||
"no such file"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
use std::{convert::Infallible, io};
|
||||
|
||||
use dbus::{Error as BusError, arg::TypeMismatchError};
|
||||
use rustix::io::Errno;
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum Error {
|
||||
#[error("systemd bus: {0}")]
|
||||
Bus(#[from] BusError),
|
||||
#[error("unexpected reply from systemd: {0}")]
|
||||
Reply(#[from] TypeMismatchError),
|
||||
#[error("could not build a method call")]
|
||||
MalformedCall,
|
||||
#[error("the service manager closed the connection")]
|
||||
Disconnected,
|
||||
#[error("the service manager did not answer in time")]
|
||||
CallTimedOut,
|
||||
#[error("console: {0}")]
|
||||
Console(#[from] io::Error),
|
||||
#[error("entering the new root: {0}")]
|
||||
RootSwitch(#[from] Errno),
|
||||
#[error("the service manager did not come back")]
|
||||
ManagerUnreachable,
|
||||
}
|
||||
|
||||
impl From<Infallible> for Error {
|
||||
fn from(never: Infallible) -> Self {
|
||||
match never {}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use rustix::time::{ClockId, clock_gettime};
|
||||
|
||||
#[must_use]
|
||||
pub fn monotonic_now() -> Duration {
|
||||
let now = clock_gettime(ClockId::Monotonic);
|
||||
Duration::new(
|
||||
now.tv_sec.cast_unsigned(),
|
||||
u32::try_from(now.tv_nsec).unwrap_or_default(),
|
||||
)
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
use std::os::fd::OwnedFd;
|
||||
|
||||
use rustix::{
|
||||
fs::{Mode, OFlags, open},
|
||||
io::Errno,
|
||||
process::{chdir, chroot, fchdir},
|
||||
};
|
||||
|
||||
const SYSROOT: &str = "/sysroot";
|
||||
pub const INITRD_RELEASE: &str = "/etc/initrd-release";
|
||||
|
||||
pub struct Sysroot {
|
||||
directory: OwnedFd,
|
||||
}
|
||||
|
||||
impl Sysroot {
|
||||
pub fn hold() -> Result<Self, Errno> {
|
||||
let directory = open(
|
||||
SYSROOT,
|
||||
OFlags::DIRECTORY | OFlags::RDONLY | OFlags::CLOEXEC,
|
||||
Mode::empty(),
|
||||
)?;
|
||||
Ok(Self { directory })
|
||||
}
|
||||
|
||||
pub fn enter(&self) -> Result<(), Errno> {
|
||||
fchdir(&self.directory)?;
|
||||
chroot(".")?;
|
||||
chdir("/")
|
||||
}
|
||||
}
|
||||
@@ -1,677 +0,0 @@
|
||||
use std::{
|
||||
future::ready,
|
||||
io, iter, mem,
|
||||
os::fd::{AsFd, AsRawFd, BorrowedFd, RawFd},
|
||||
pin::pin,
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use dbus::{
|
||||
Message, MessageType, Path,
|
||||
arg::{AppendAll, PropMap, RefArg, Variant},
|
||||
channel::{BusType, Channel},
|
||||
};
|
||||
use futures::{TryStreamExt, stream};
|
||||
use rustix::event::{PollFd, PollFlags, Timespec, poll};
|
||||
use tokio::{io::unix::AsyncFd, time::timeout};
|
||||
|
||||
use crate::{
|
||||
boot_model::{Activity, JobKind, JobResult, UnitFacts, UnitKind, UnitTimeouts},
|
||||
console_session::stream_sources::{
|
||||
CarriedItem, readable_or_timeout, readable_source, unfold_carrying,
|
||||
},
|
||||
systemd_link::link_error::Error,
|
||||
};
|
||||
|
||||
const DESTINATION: &str = "org.freedesktop.systemd1";
|
||||
const MANAGER_PATH: &str = "/org/freedesktop/systemd1";
|
||||
const MANAGER_INTERFACE: &str = "org.freedesktop.systemd1.Manager";
|
||||
const UNIT_INTERFACE: &str = "org.freedesktop.systemd1.Unit";
|
||||
const SERVICE_INTERFACE: &str = "org.freedesktop.systemd1.Service";
|
||||
const MOUNT_INTERFACE: &str = "org.freedesktop.systemd1.Mount";
|
||||
const SWAP_INTERFACE: &str = "org.freedesktop.systemd1.Swap";
|
||||
const SOCKET_INTERFACE: &str = "org.freedesktop.systemd1.Socket";
|
||||
const JOB_INTERFACE: &str = "org.freedesktop.systemd1.Job";
|
||||
const PROPERTIES_INTERFACE: &str = "org.freedesktop.DBus.Properties";
|
||||
const PEER_INTERFACE: &str = "org.freedesktop.DBus.Peer";
|
||||
const BUS_DESTINATION: &str = "org.freedesktop.DBus";
|
||||
const BUS_PATH: &str = "/org/freedesktop/DBus";
|
||||
const PRIVATE_SOCKET: &str = "unix:path=/run/systemd/private";
|
||||
const SIGNAL_RULE: &str = "type='signal',path_namespace='/org/freedesktop/systemd1'";
|
||||
const CALL_TIMEOUT: Duration = Duration::from_secs(1);
|
||||
const UNLIMITED: Duration = Duration::from_micros(u64::MAX);
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum Scope {
|
||||
System,
|
||||
User,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum StatusOutput {
|
||||
Silent,
|
||||
Configured,
|
||||
}
|
||||
|
||||
impl StatusOutput {
|
||||
fn bus_mode(self) -> &'static str {
|
||||
match self {
|
||||
Self::Silent => "no",
|
||||
Self::Configured => "",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub enum SignalBatch {
|
||||
Open(Vec<Signal>),
|
||||
Closed(Vec<Signal>),
|
||||
}
|
||||
|
||||
pub enum Signal {
|
||||
JobNew {
|
||||
id: u32,
|
||||
job: Path<'static>,
|
||||
unit: String,
|
||||
},
|
||||
JobRemoved {
|
||||
id: u32,
|
||||
unit: String,
|
||||
result: JobResult,
|
||||
},
|
||||
UnitChanged {
|
||||
path: Path<'static>,
|
||||
activity: Activity,
|
||||
},
|
||||
BootFinished,
|
||||
}
|
||||
|
||||
pub struct FetchedUnit {
|
||||
pub path: Path<'static>,
|
||||
pub facts: UnitFacts,
|
||||
pub activity: Activity,
|
||||
}
|
||||
|
||||
pub struct JobListing {
|
||||
pub id: u32,
|
||||
pub unit: String,
|
||||
pub kind: JobKind,
|
||||
}
|
||||
|
||||
type ListedJob = (u32, String, String, String, Path<'static>, Path<'static>);
|
||||
|
||||
impl From<ListedJob> for JobListing {
|
||||
fn from((id, unit, kind, ..): ListedJob) -> Self {
|
||||
Self {
|
||||
id,
|
||||
unit,
|
||||
kind: serde_plain::from_str(&kind).unwrap_or(JobKind::Unknown),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Session {
|
||||
channel: Channel,
|
||||
peer_to_peer: bool,
|
||||
}
|
||||
|
||||
fn method_call(
|
||||
destination: &str,
|
||||
path: &str,
|
||||
interface: &str,
|
||||
member: &str,
|
||||
arguments: impl AppendAll,
|
||||
) -> Result<Message, Error> {
|
||||
let Ok(mut call) = Message::new_method_call(destination, path, interface, member) else {
|
||||
return Err(Error::MalformedCall);
|
||||
};
|
||||
call.append_all(arguments);
|
||||
Ok(call)
|
||||
}
|
||||
|
||||
fn manager_call(member: &str, arguments: impl AppendAll) -> Result<Message, Error> {
|
||||
method_call(
|
||||
DESTINATION,
|
||||
MANAGER_PATH,
|
||||
MANAGER_INTERFACE,
|
||||
member,
|
||||
arguments,
|
||||
)
|
||||
}
|
||||
|
||||
fn property_call(path: &str, interface: &str, property: &str) -> Result<Message, Error> {
|
||||
method_call(
|
||||
DESTINATION,
|
||||
path,
|
||||
PROPERTIES_INTERFACE,
|
||||
"Get",
|
||||
(interface, property),
|
||||
)
|
||||
}
|
||||
|
||||
fn boot_in_progress_call() -> Result<Message, Error> {
|
||||
property_call(MANAGER_PATH, MANAGER_INTERFACE, "FinishTimestampMonotonic")
|
||||
}
|
||||
|
||||
fn read_boot_in_progress(reply: &Message) -> Result<bool, Error> {
|
||||
let finished: Variant<u64> = reply.read1()?;
|
||||
Ok(finished.0 == 0)
|
||||
}
|
||||
|
||||
impl Session {
|
||||
pub fn open(scope: Scope) -> Result<Self, Error> {
|
||||
if scope == Scope::System
|
||||
&& let Ok(channel) = Channel::open_private(PRIVATE_SOCKET)
|
||||
{
|
||||
let session = Self::watching(channel, true);
|
||||
session.send(authentication_carrier()?)?;
|
||||
return Ok(session);
|
||||
}
|
||||
let bus = match scope {
|
||||
Scope::System => BusType::System,
|
||||
Scope::User => BusType::Session,
|
||||
};
|
||||
let session = Self::watching(Channel::get_private(bus)?, false);
|
||||
session.blocking_call(method_call(
|
||||
BUS_DESTINATION,
|
||||
BUS_PATH,
|
||||
BUS_DESTINATION,
|
||||
"AddMatch",
|
||||
(SIGNAL_RULE,),
|
||||
)?)?;
|
||||
Ok(session)
|
||||
}
|
||||
|
||||
fn watching(mut channel: Channel, peer_to_peer: bool) -> Self {
|
||||
channel.set_watch_enabled(true);
|
||||
Self {
|
||||
channel,
|
||||
peer_to_peer,
|
||||
}
|
||||
}
|
||||
|
||||
fn blocking_call(&self, call: Message) -> Result<Message, Error> {
|
||||
Ok(self.channel.send_with_reply_and_block(call, CALL_TIMEOUT)?)
|
||||
}
|
||||
|
||||
pub fn set_show_status(&self, output: StatusOutput) -> Result<(), Error> {
|
||||
self.blocking_call(manager_call("SetShowStatus", (output.bus_mode(),))?)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn boot_in_progress(&self) -> Result<bool, Error> {
|
||||
read_boot_in_progress(&self.blocking_call(boot_in_progress_call()?)?)
|
||||
}
|
||||
|
||||
fn send(&self, call: Message) -> Result<u32, Error> {
|
||||
let serial = self.channel.send(call).map_err(|()| Error::Disconnected)?;
|
||||
self.channel.flush();
|
||||
Ok(serial)
|
||||
}
|
||||
|
||||
fn socket_has_unread_bytes(&self) -> bool {
|
||||
let mut watched = [PollFd::new(self, PollFlags::IN)];
|
||||
poll(&mut watched, Some(&Timespec::default())).is_ok_and(|ready| ready > 0)
|
||||
}
|
||||
|
||||
fn read_one_chunk(&self) -> bool {
|
||||
self.channel.read_write(Some(Duration::ZERO)).is_ok() && self.channel.is_connected()
|
||||
}
|
||||
|
||||
fn arrived_messages(&self) -> Vec<Message> {
|
||||
iter::repeat_with(|| self.read_one_chunk())
|
||||
.find(|still_connected| !still_connected || !self.socket_has_unread_bytes());
|
||||
iter::from_fn(|| self.channel.pop_message()).collect()
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BusConnection {
|
||||
session: AsyncFd<Session>,
|
||||
early_signals: Vec<Signal>,
|
||||
}
|
||||
|
||||
impl BusConnection {
|
||||
pub fn register(session: Session) -> io::Result<Self> {
|
||||
Ok(Self {
|
||||
session: readable_source(session)?,
|
||||
early_signals: Vec::new(),
|
||||
})
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn peer_to_peer(&self) -> bool {
|
||||
self.session.get_ref().peer_to_peer
|
||||
}
|
||||
|
||||
fn drain_replies(&mut self) -> Result<Vec<Message>, Error> {
|
||||
let session = self.session.get_ref();
|
||||
let (signals, replies): (Vec<Message>, Vec<Message>) = session
|
||||
.arrived_messages()
|
||||
.into_iter()
|
||||
.partition(|message| message.msg_type() == MessageType::Signal);
|
||||
self.early_signals
|
||||
.extend(signals.iter().filter_map(parse_signal));
|
||||
if session.channel.is_connected() {
|
||||
Ok(replies)
|
||||
} else {
|
||||
Err(Error::Disconnected)
|
||||
}
|
||||
}
|
||||
|
||||
async fn next_replies(&mut self) -> Result<Vec<Message>, Error> {
|
||||
let drained = self.drain_replies()?;
|
||||
if !drained.is_empty() {
|
||||
return Ok(drained);
|
||||
}
|
||||
self.session.readable().await?.clear_ready();
|
||||
self.drain_replies()
|
||||
}
|
||||
|
||||
async fn reply_to(&mut self, serial: u32) -> Result<Message, Error> {
|
||||
let mut replies = pin!(
|
||||
unfold_carrying(self, |connection| async move {
|
||||
let replies = connection.next_replies().await;
|
||||
Some(CarriedItem {
|
||||
item: replies,
|
||||
state: connection,
|
||||
})
|
||||
})
|
||||
.map_ok(|replies| stream::iter(replies.into_iter().map(Ok::<_, Error>)))
|
||||
.try_flatten()
|
||||
.try_filter(|reply| ready(reply.get_reply_serial() == Some(serial)))
|
||||
);
|
||||
replies.try_next().await?.ok_or(Error::Disconnected)
|
||||
}
|
||||
|
||||
async fn call(&mut self, call: Message) -> Result<Message, Error> {
|
||||
let serial = self.session.get_ref().send(call)?;
|
||||
let Ok(reply) = timeout(CALL_TIMEOUT, self.reply_to(serial)).await else {
|
||||
return Err(Error::CallTimedOut);
|
||||
};
|
||||
let mut reply = reply?;
|
||||
reply.as_result()?;
|
||||
Ok(reply)
|
||||
}
|
||||
|
||||
pub async fn subscribe(&mut self) -> Result<(), Error> {
|
||||
self.call(manager_call("Subscribe", ())?).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn set_show_status(&mut self, output: StatusOutput) -> Result<(), Error> {
|
||||
self.call(manager_call("SetShowStatus", (output.bus_mode(),))?)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn default_target(&mut self) -> Result<String, Error> {
|
||||
let reply = self.call(manager_call("GetDefaultTarget", ())?).await?;
|
||||
Ok(reply.read1()?)
|
||||
}
|
||||
|
||||
pub async fn boot_in_progress(&mut self) -> Result<bool, Error> {
|
||||
read_boot_in_progress(&self.call(boot_in_progress_call()?).await?)
|
||||
}
|
||||
|
||||
pub async fn list_jobs(&mut self) -> Result<Vec<JobListing>, Error> {
|
||||
let reply = self.call(manager_call("ListJobs", ())?).await?;
|
||||
let listed: Vec<ListedJob> = reply.read1()?;
|
||||
Ok(listed.into_iter().map(JobListing::from).collect())
|
||||
}
|
||||
|
||||
pub async fn job_kind(&mut self, job: &Path<'_>) -> Result<JobKind, Error> {
|
||||
let reply = self
|
||||
.call(property_call(job, JOB_INTERFACE, "JobType")?)
|
||||
.await?;
|
||||
let kind: Variant<String> = reply.read1()?;
|
||||
Ok(serde_plain::from_str(&kind.0).unwrap_or(JobKind::Unknown))
|
||||
}
|
||||
|
||||
pub async fn fetch_unit(&mut self, name: &str) -> Result<FetchedUnit, Error> {
|
||||
let path: Path<'static> = self
|
||||
.call(manager_call("GetUnit", (name,))?)
|
||||
.await?
|
||||
.read1()?;
|
||||
let properties = self.all_properties(&path, UNIT_INTERFACE).await?;
|
||||
let kind_properties = match kind_interface(UnitKind::of(&unit_id(name, &properties))) {
|
||||
Some(interface) => self.all_properties(&path, interface).await?,
|
||||
None => PropMap::new(),
|
||||
};
|
||||
Ok(FetchedUnit {
|
||||
facts: unit_facts_from(name, &properties, &kind_properties),
|
||||
activity: activity_from(&properties),
|
||||
path,
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn failure_reason(&mut self, name: &str) -> Result<Option<String>, Error> {
|
||||
let Some(interface) = kind_interface(UnitKind::of(name)) else {
|
||||
return Ok(None);
|
||||
};
|
||||
let path: Path<'static> = self
|
||||
.call(manager_call("GetUnit", (name,))?)
|
||||
.await?
|
||||
.read1()?;
|
||||
let properties = self.all_properties(&path, interface).await?;
|
||||
Ok(failure_reason_from(&properties))
|
||||
}
|
||||
|
||||
async fn all_properties(&mut self, path: &Path<'_>, interface: &str) -> Result<PropMap, Error> {
|
||||
Ok(self
|
||||
.call(method_call(
|
||||
DESTINATION,
|
||||
path,
|
||||
PROPERTIES_INTERFACE,
|
||||
"GetAll",
|
||||
(interface,),
|
||||
)?)
|
||||
.await?
|
||||
.read1()?)
|
||||
}
|
||||
|
||||
pub async fn receive_signals(&mut self, patience: Duration) -> SignalBatch {
|
||||
if self.early_signals.is_empty() {
|
||||
readable_or_timeout(&self.session, patience).await;
|
||||
}
|
||||
let still_connected = self.drain_replies().is_ok();
|
||||
let signals = mem::take(&mut self.early_signals);
|
||||
if still_connected {
|
||||
SignalBatch::Open(signals)
|
||||
} else {
|
||||
SignalBatch::Closed(signals)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn text_property(properties: &PropMap, property: &str) -> Option<String> {
|
||||
properties
|
||||
.get(property)
|
||||
.and_then(|value| value.0.as_str())
|
||||
.map(ToOwned::to_owned)
|
||||
}
|
||||
|
||||
fn signal_name(number: i64) -> String {
|
||||
let name = match number {
|
||||
1 => "SIGHUP",
|
||||
2 => "SIGINT",
|
||||
3 => "SIGQUIT",
|
||||
4 => "SIGILL",
|
||||
5 => "SIGTRAP",
|
||||
6 => "SIGABRT",
|
||||
7 => "SIGBUS",
|
||||
8 => "SIGFPE",
|
||||
9 => "SIGKILL",
|
||||
11 => "SIGSEGV",
|
||||
13 => "SIGPIPE",
|
||||
14 => "SIGALRM",
|
||||
15 => "SIGTERM",
|
||||
other => return format!("signal {other}"),
|
||||
};
|
||||
name.to_owned()
|
||||
}
|
||||
|
||||
fn failure_reason_from(properties: &PropMap) -> Option<String> {
|
||||
let result = text_property(properties, "Result").filter(|result| result != "success")?;
|
||||
let status = properties
|
||||
.get("ExecMainStatus")
|
||||
.and_then(|value| value.0.as_i64());
|
||||
let reason = match (result.as_str(), status) {
|
||||
("exit-code", Some(status)) if status != 0 => format!("exited with status {status}"),
|
||||
("exit-code", _) => "exited with an error".to_owned(),
|
||||
("signal", Some(signal)) => format!("killed by {}", signal_name(signal)),
|
||||
("core-dump", Some(signal)) => format!("dumped core on {}", signal_name(signal)),
|
||||
("timeout", _) => "timed out".to_owned(),
|
||||
("watchdog", _) => "stopped answering the watchdog".to_owned(),
|
||||
("start-limit-hit", _) => "restarted too often".to_owned(),
|
||||
("oom-kill", _) => "killed for running out of memory".to_owned(),
|
||||
("resources", _) => "could not set up its resources".to_owned(),
|
||||
("protocol", _) => "broke the start-up protocol".to_owned(),
|
||||
(other, _) => other.to_owned(),
|
||||
};
|
||||
Some(
|
||||
match text_property(properties, "StatusText").filter(|text| !text.is_empty()) {
|
||||
Some(status_text) => format!("{reason}: {status_text}"),
|
||||
None => reason,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
fn unit_id(name: &str, properties: &PropMap) -> String {
|
||||
text_property(properties, "Id").unwrap_or_else(|| name.to_owned())
|
||||
}
|
||||
|
||||
fn kind_interface(kind: UnitKind) -> Option<&'static str> {
|
||||
match kind {
|
||||
UnitKind::Service => Some(SERVICE_INTERFACE),
|
||||
UnitKind::Mount => Some(MOUNT_INTERFACE),
|
||||
UnitKind::Swap => Some(SWAP_INTERFACE),
|
||||
UnitKind::Socket => Some(SOCKET_INTERFACE),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn time_limit(properties: &PropMap, property: &str) -> Option<Duration> {
|
||||
properties
|
||||
.get(property)
|
||||
.and_then(|value| value.0.as_u64())
|
||||
.map(Duration::from_micros)
|
||||
.filter(|limit| !limit.is_zero() && *limit != UNLIMITED)
|
||||
}
|
||||
|
||||
fn timeouts_from(kind: UnitKind, unit: &PropMap, kind_specific: &PropMap) -> UnitTimeouts {
|
||||
let (start, stop) = if kind == UnitKind::Service {
|
||||
("TimeoutStartUSec", "TimeoutStopUSec")
|
||||
} else {
|
||||
("TimeoutUSec", "TimeoutUSec")
|
||||
};
|
||||
UnitTimeouts {
|
||||
start: time_limit(kind_specific, start),
|
||||
stop: time_limit(kind_specific, stop),
|
||||
job: time_limit(unit, "JobTimeoutUSec"),
|
||||
job_running: time_limit(unit, "JobRunningTimeoutUSec"),
|
||||
}
|
||||
}
|
||||
|
||||
fn unit_facts_from(name: &str, properties: &PropMap, kind_properties: &PropMap) -> UnitFacts {
|
||||
let text = |property: &str| text_property(properties, property);
|
||||
let names = |property: &str| {
|
||||
properties
|
||||
.get(property)
|
||||
.and_then(|value| value.0.as_iter())
|
||||
.map(|items| {
|
||||
items
|
||||
.filter_map(|item| item.as_str().map(ToOwned::to_owned))
|
||||
.collect()
|
||||
})
|
||||
.unwrap_or_default()
|
||||
};
|
||||
let id = unit_id(name, properties);
|
||||
UnitFacts {
|
||||
timeouts: timeouts_from(UnitKind::of(&id), properties, kind_properties),
|
||||
name: id,
|
||||
description: text("Description").filter(|description| !description.is_empty()),
|
||||
after: names("After"),
|
||||
before: names("Before"),
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRawFd for Session {
|
||||
fn as_raw_fd(&self) -> RawFd {
|
||||
self.channel.watch().fd
|
||||
}
|
||||
}
|
||||
|
||||
impl AsFd for Session {
|
||||
fn as_fd(&self) -> BorrowedFd<'_> {
|
||||
unsafe { BorrowedFd::borrow_raw(self.as_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
fn authentication_carrier() -> Result<Message, Error> {
|
||||
let mut ping = method_call(DESTINATION, MANAGER_PATH, PEER_INTERFACE, "Ping", ())?;
|
||||
ping.set_no_reply(true);
|
||||
Ok(ping)
|
||||
}
|
||||
|
||||
fn parse_signal(message: &Message) -> Option<Signal> {
|
||||
if message.msg_type() != MessageType::Signal {
|
||||
return None;
|
||||
}
|
||||
let interface = message.interface()?;
|
||||
let member = message.member()?;
|
||||
match (&*interface, &*member) {
|
||||
(MANAGER_INTERFACE, "JobNew" | "JobRemoved") => parse_job_signal(message, &member),
|
||||
(MANAGER_INTERFACE, "StartupFinished") => Some(Signal::BootFinished),
|
||||
(PROPERTIES_INTERFACE, "PropertiesChanged") => parse_unit_change(message),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_job_signal(message: &Message, member: &str) -> Option<Signal> {
|
||||
match member {
|
||||
"JobNew" => {
|
||||
let (id, job, unit): (u32, Path<'static>, String) = message.read3().ok()?;
|
||||
Some(Signal::JobNew { id, job, unit })
|
||||
}
|
||||
"JobRemoved" => {
|
||||
let (id, _job, unit, result): (u32, Path<'static>, String, String) =
|
||||
message.read4().ok()?;
|
||||
Some(Signal::JobRemoved {
|
||||
id,
|
||||
unit,
|
||||
result: serde_plain::from_str(&result).unwrap_or(JobResult::Failed),
|
||||
})
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_unit_change(message: &Message) -> Option<Signal> {
|
||||
let (changed_interface, changed, _invalidated): (String, PropMap, Vec<String>) =
|
||||
message.read3().ok()?;
|
||||
if changed_interface != UNIT_INTERFACE {
|
||||
return None;
|
||||
}
|
||||
Some(Signal::UnitChanged {
|
||||
path: message.path()?.into_static(),
|
||||
activity: activity_from(&changed),
|
||||
})
|
||||
}
|
||||
|
||||
fn activity_from(properties: &PropMap) -> Activity {
|
||||
let monotonic = |property: &str| {
|
||||
properties
|
||||
.get(property)
|
||||
.and_then(|value| value.0.as_u64())
|
||||
.filter(|micros| *micros != 0)
|
||||
.map(Duration::from_micros)
|
||||
};
|
||||
Activity {
|
||||
state: properties
|
||||
.get("ActiveState")
|
||||
.and_then(|value| value.0.as_str())
|
||||
.and_then(|raw| serde_plain::from_str(raw).ok()),
|
||||
inactive_exit: monotonic("InactiveExitTimestampMonotonic"),
|
||||
active_enter: monotonic("ActiveEnterTimestampMonotonic"),
|
||||
active_exit: monotonic("ActiveExitTimestampMonotonic"),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn startup_finished_signal_marks_the_boot_finished() {
|
||||
let startup_finished = Message::signal(
|
||||
&Path::from(MANAGER_PATH),
|
||||
&MANAGER_INTERFACE.into(),
|
||||
&"StartupFinished".into(),
|
||||
)
|
||||
.append3(0_u64, 0_u64, 0_u64)
|
||||
.append3(0_u64, 0_u64, 0_u64);
|
||||
assert!(matches!(
|
||||
parse_signal(&startup_finished),
|
||||
Some(Signal::BootFinished)
|
||||
));
|
||||
}
|
||||
|
||||
fn limit_properties(entries: &[(&str, Duration)]) -> PropMap {
|
||||
entries
|
||||
.iter()
|
||||
.map(|(name, limit)| {
|
||||
let micros = u64::try_from(limit.as_micros()).unwrap_or(u64::MAX);
|
||||
(
|
||||
(*name).to_owned(),
|
||||
Variant(Box::new(micros) as Box<dyn RefArg>),
|
||||
)
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unlimited_timeouts_are_absent() {
|
||||
let unit = limit_properties(&[
|
||||
("JobTimeoutUSec", UNLIMITED),
|
||||
("JobRunningTimeoutUSec", Duration::ZERO),
|
||||
]);
|
||||
let service = limit_properties(&[
|
||||
("TimeoutStartUSec", UNLIMITED),
|
||||
("TimeoutStopUSec", Duration::from_secs(90)),
|
||||
]);
|
||||
assert_eq!(
|
||||
timeouts_from(UnitKind::Service, &unit, &service),
|
||||
UnitTimeouts {
|
||||
stop: Some(Duration::from_secs(90)),
|
||||
..UnitTimeouts::default()
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
fn reason_properties(result: &str, status: i32, status_text: &str) -> PropMap {
|
||||
[
|
||||
("Result", Box::new(result.to_owned()) as Box<dyn RefArg>),
|
||||
("ExecMainStatus", Box::new(status)),
|
||||
("StatusText", Box::new(status_text.to_owned())),
|
||||
]
|
||||
.into_iter()
|
||||
.map(|(name, value)| (name.to_owned(), Variant(value)))
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn exit_codes_and_signals_become_a_reason() {
|
||||
assert_eq!(
|
||||
failure_reason_from(&reason_properties("exit-code", 1, "")).as_deref(),
|
||||
Some("exited with status 1")
|
||||
);
|
||||
assert_eq!(
|
||||
failure_reason_from(&reason_properties("signal", 11, "")).as_deref(),
|
||||
Some("killed by SIGSEGV")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn status_text_follows_the_reason() {
|
||||
assert_eq!(
|
||||
failure_reason_from(&reason_properties("timeout", 0, "waiting for the disk"))
|
||||
.as_deref(),
|
||||
Some("timed out: waiting for the disk")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn success_has_no_reason() {
|
||||
assert_eq!(
|
||||
failure_reason_from(&reason_properties("success", 0, "")),
|
||||
None
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mounts_use_one_timeout_for_both_directions() {
|
||||
let mount = limit_properties(&[("TimeoutUSec", Duration::from_secs(20))]);
|
||||
let timeouts = timeouts_from(UnitKind::Mount, &PropMap::new(), &mount);
|
||||
assert_eq!(timeouts.start, Some(Duration::from_secs(20)));
|
||||
assert_eq!(timeouts.stop, Some(Duration::from_secs(20)));
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
disable=SC2154
|
||||
@@ -1,20 +0,0 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
check() {
|
||||
require_binaries bootvine || return 1
|
||||
return 255
|
||||
}
|
||||
|
||||
depends() {
|
||||
echo systemd
|
||||
}
|
||||
|
||||
install() {
|
||||
inst_binary bootvine
|
||||
inst_simple "$systemdsystemunitdir/bootvine.service"
|
||||
inst_simple "$systemdsystemunitdir/systemd-hibernate-resume.service.d/bootvine.conf"
|
||||
if [[ -f /etc/bootvine.toml ]]; then
|
||||
inst_simple /etc/bootvine.toml
|
||||
fi
|
||||
$SYSTEMCTL -q --root "$initdir" enable bootvine.service
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
build() {
|
||||
add_binary bootvine
|
||||
add_systemd_unit bootvine.service
|
||||
add_file /usr/lib/systemd/system/systemd-hibernate-resume.service.d/bootvine.conf
|
||||
if [[ -f /etc/bootvine.toml ]]; then
|
||||
add_file /etc/bootvine.toml
|
||||
fi
|
||||
add_symlink /usr/lib/systemd/system/sysinit.target.wants/bootvine.service \
|
||||
/usr/lib/systemd/system/bootvine.service
|
||||
}
|
||||
|
||||
help() {
|
||||
cat <<HELP
|
||||
Shows a live dependency tree of systemd jobs while the initramfs boots.
|
||||
Requires the systemd hook; add sd-bootvine after it in HOOKS.
|
||||
HELP
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
[Unit]
|
||||
Description=Live dependency tree of shutdown jobs
|
||||
DefaultDependencies=no
|
||||
After=bootvine.service display-manager.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/bin/bootvine --shutdown
|
||||
StandardInput=tty
|
||||
StandardOutput=tty
|
||||
StandardError=journal
|
||||
TTYPath=/dev/tty12
|
||||
TTYReset=yes
|
||||
TTYVTDisallocate=no
|
||||
|
||||
[Install]
|
||||
WantedBy=shutdown.target
|
||||
@@ -1,19 +0,0 @@
|
||||
[Unit]
|
||||
Description=Live dependency tree of boot jobs
|
||||
DefaultDependencies=no
|
||||
IgnoreOnIsolate=yes
|
||||
Before=display-manager.service shutdown.target
|
||||
Conflicts=shutdown.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=@/usr/bin/bootvine @bootvine
|
||||
StandardInput=tty
|
||||
StandardOutput=tty
|
||||
StandardError=journal
|
||||
TTYPath=/dev/tty12
|
||||
TTYReset=yes
|
||||
TTYVTDisallocate=no
|
||||
|
||||
[Install]
|
||||
WantedBy=sysinit.target
|
||||
@@ -1,6 +0,0 @@
|
||||
[Unit]
|
||||
After=systemd-vconsole-setup.service
|
||||
|
||||
[Service]
|
||||
ExecStartPre=-/usr/bin/bootvine open-resume-console
|
||||
ExecStopPost=-/usr/bin/bootvine close-resume-console
|
||||
@@ -1,335 +0,0 @@
|
||||
# Architecture
|
||||
|
||||
How bootvine follows a boot and a shutdown, and what it changes on the console
|
||||
while it does. None of this is needed to install or configure it.
|
||||
|
||||
## Requirements
|
||||
|
||||
- **systemd ≥ 246 as PID 1.** bootvine reads the jobs and units from the
|
||||
service manager over D-Bus.
|
||||
- **[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).
|
||||
- **libsystemd.** It reads the last journal lines of a failed unit; see
|
||||
[failures](#failures).
|
||||
- **A virtual terminal.** It draws on `tty12` and switches the console to it.
|
||||
|
||||
## Overview
|
||||
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
participant Kernel
|
||||
participant PID1 as systemd (PID 1)
|
||||
participant Bootvine as bootvine
|
||||
participant Console as tty12
|
||||
|
||||
Kernel->>PID1: unpack the initramfs, run /init
|
||||
PID1->>Bootvine: start bootvine.service (wanted by sysinit.target)
|
||||
Bootvine->>PID1: connect to /run/systemd/private, Subscribe
|
||||
Bootvine->>Console: take the console
|
||||
loop initrd
|
||||
PID1-->>Bootvine: JobNew, JobRemoved, PropertiesChanged
|
||||
Bootvine->>Console: redraw the tree
|
||||
end
|
||||
PID1->>PID1: switch-root to /sysroot, re-execute
|
||||
Note over Bootvine: spared, chroots into the new root
|
||||
Bootvine->>PID1: reconnect, Subscribe
|
||||
loop stage 2
|
||||
PID1-->>Bootvine: JobNew, JobRemoved, PropertiesChanged
|
||||
Bootvine->>Console: redraw the tree
|
||||
end
|
||||
PID1-->>Bootvine: StartupFinished
|
||||
Bootvine->>Console: hand the console back
|
||||
```
|
||||
|
||||
## Starting in the initrd
|
||||
|
||||
The initrd is a small root file system that the kernel unpacks into memory and
|
||||
runs before the real root is mounted. When it runs systemd, its `/init` is
|
||||
systemd as PID 1, with the same units, targets and D-Bus API as on the real
|
||||
root. bootvine hooks into that systemd rather than into the kernel.
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
subgraph Build["When the initramfs is built"]
|
||||
Generator["NixOS, dracut module<br>or mkinitcpio hook"]
|
||||
end
|
||||
subgraph Initramfs
|
||||
Binary["/usr/bin/bootvine"]
|
||||
Unit["bootvine.service"]
|
||||
Link["sysinit.target.wants/<br>bootvine.service"]
|
||||
end
|
||||
Generator --> Binary
|
||||
Generator --> Unit
|
||||
Generator --> Link
|
||||
Link -- "pulls in at the first<br>transaction" --> Unit
|
||||
```
|
||||
|
||||
1. **The image.** The initramfs generator copies the binary,
|
||||
`bootvine.service` and `/etc/bootvine.toml` into the image and enables the
|
||||
unit there, which links it into `sysinit.target.wants`.
|
||||
2. **The first transaction.** systemd in the initrd starts `initrd.target`,
|
||||
which pulls in `sysinit.target` and with it `bootvine.service`.
|
||||
3. **No waiting.** `DefaultDependencies=no` drops the implicit
|
||||
`After=sysinit.target basic.target`, so bootvine is not ordered after
|
||||
anything and starts in parallel with udev and the first mounts, about a
|
||||
second after the kernel.
|
||||
4. **Knowing where it is.** `/etc/initrd-release` exists only in an initrd, so
|
||||
its presence tells bootvine it is in the initrd stage.
|
||||
|
||||
Without a systemd initrd, the same unit is enabled in the real root and starts
|
||||
in stage 2 instead.
|
||||
|
||||
## What systemd exposes
|
||||
|
||||
PID 1 publishes its state on D-Bus under `org.freedesktop.systemd1`. In the
|
||||
initrd there is no D-Bus daemon yet, so bootvine connects straight to PID 1 on
|
||||
the private socket `/run/systemd/private`, which systemd listens on from the
|
||||
moment it starts. Where that socket is not available, it falls back to the
|
||||
system bus.
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
Bootvine["bootvine"]
|
||||
subgraph PID1["systemd (PID 1)"]
|
||||
Manager["Manager<br>/org/freedesktop/systemd1"]
|
||||
Units["Unit objects"]
|
||||
Jobs["Job objects"]
|
||||
end
|
||||
Bootvine -- "Subscribe, ListJobs,<br>GetDefaultTarget, GetUnit,<br>SetShowStatus" --> Manager
|
||||
Bootvine -- "Properties.GetAll" --> Units
|
||||
Bootvine -- "Properties.Get JobType" --> Jobs
|
||||
Manager -. "JobNew, JobRemoved,<br>StartupFinished" .-> Bootvine
|
||||
Units -. "PropertiesChanged" .-> Bootvine
|
||||
```
|
||||
|
||||
On connecting, bootvine:
|
||||
|
||||
1. calls `Subscribe`, without which PID 1 sends no signals;
|
||||
2. calls `ListJobs` for the jobs already queued, since some were queued before
|
||||
it started;
|
||||
3. calls `GetDefaultTarget` for the root of the tree, such as
|
||||
`initrd.target` in the initrd and `graphical.target` in stage 2;
|
||||
4. reads `FinishTimestampMonotonic`, which stays 0 until the boot is finished.
|
||||
|
||||
From then on it follows the signals:
|
||||
|
||||
| Signal | Carries | Used for |
|
||||
| --- | --- | --- |
|
||||
| `JobNew` | job id, job path, unit name | a row in the tree |
|
||||
| `JobRemoved` | job id, unit name, result | the row finishes as done, failed or skipped |
|
||||
| `PropertiesChanged` on a unit | `ActiveState` and its timestamps | running since, and the timeline |
|
||||
| `StartupFinished` | | the boot reached its default target |
|
||||
|
||||
For each unit it meets, `GetUnit` and `Properties.GetAll` give its
|
||||
`Description`, its `After=` and `Before=` orderings and its timeouts.
|
||||
|
||||
### From orderings to a tree
|
||||
|
||||
A unit waits on the units in its `After=` that still have a pending job; when
|
||||
stopping, on the units in its `Before=`. bootvine nests each unit under the one
|
||||
waiting on it, starting from the default target.
|
||||
|
||||
```mermaid
|
||||
flowchart TB
|
||||
Graphical["graphical.target"] --> DisplayManager["display-manager.service"]
|
||||
Graphical --> MultiUser["multi-user.target"]
|
||||
MultiUser --> RemoteFs["remote-fs.target"]
|
||||
RemoteFs --> NetworkMount["mnt-data.mount"]
|
||||
NetworkMount --> Network["network-online.target"]
|
||||
Network --> NetworkManager["NetworkManager-wait-online.service"]
|
||||
```
|
||||
|
||||
Here `graphical.target` is `After=multi-user.target`, `remote-fs.target` is
|
||||
`After=` the network mount, the mount is `After=network-online.target`, and so
|
||||
on down to the unit that is actually running. A target is ordered after the
|
||||
units it wants, so targets fill the upper levels.
|
||||
|
||||
### Timestamps
|
||||
|
||||
systemd's `…TimestampMonotonic` properties count microseconds of
|
||||
`CLOCK_MONOTONIC`, which starts with the kernel. bootvine reads the same
|
||||
clock, so the times it shows are measured from the kernel start, even for
|
||||
units that ran before bootvine did.
|
||||
|
||||
### Failures
|
||||
|
||||
`JobRemoved` says how a job ended: `failed`, `timeout` or `dependency`. Like
|
||||
systemd's own `[FAILED]`, `[ TIME ]` and `[DEPEND]`, bootvine tells them
|
||||
apart: a unit that failed only because a dependency did is shown dimmed in the
|
||||
tree and left out of the failure panel, so the panel points at the unit that
|
||||
actually broke. A unit whose `ActiveState` turns `failed` without a failed job,
|
||||
such as a service crashing after it started, counts as failed too.
|
||||
|
||||
For a unit that broke or timed out, bootvine collects the cause once:
|
||||
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
participant PID1 as systemd (PID 1)
|
||||
participant Bootvine as bootvine
|
||||
participant Journal as journal files
|
||||
|
||||
PID1-->>Bootvine: ActiveState=failed, or JobRemoved failed/timeout
|
||||
Bootvine->>PID1: GetUnit, Properties.GetAll on the unit type
|
||||
PID1->>Bootvine: Result, ExecMainCode, ExecMainStatus, StatusText
|
||||
Note over Bootvine: wait 200 ms for journald, longer while nothing is there yet
|
||||
Bootvine->>Journal: sd_journal, matching the unit in this boot
|
||||
Journal->>Bootvine: last messages, newest last
|
||||
Note over Bootvine: reason and lines in the failure panel
|
||||
```
|
||||
|
||||
- **The reason** comes from the unit type's `Result` (`exit-code`, `signal`,
|
||||
`timeout`, `start-limit-hit`, `oom-kill`, …), with the exit status or signal
|
||||
of the main process, and the service's `StatusText` when it set one. These
|
||||
are read when the unit fails, since they change at that moment.
|
||||
- **The journal lines** match the unit the same way `journalctl -u` does
|
||||
(`_SYSTEMD_UNIT=` or `UNIT=`, in the current boot), without PID 1's own
|
||||
"Starting…", "Failed with result…" and "Failed to start…" lines, which the
|
||||
reason already covers. In the initrd they come from `/run/log/journal`. The
|
||||
journal is opened without `SD_JOURNAL_LOCAL_ONLY`: libsystemd caches the
|
||||
initrd's machine ID, which would hide the real root's files after the
|
||||
switch, and the boot ID match already keeps other machines out.
|
||||
- **libsystemd** is linked rather than calling `journalctl`, since dracut,
|
||||
mkinitcpio and the NixOS initrd builder copy the libraries a binary links
|
||||
into the initramfs along with it, while `journalctl` may not be there.
|
||||
|
||||
## Surviving the switch to the real root
|
||||
|
||||
At the end of the initrd, systemd mounts the real root at `/sysroot`, isolates
|
||||
`initrd-switch-root.target` and runs `initrd-switch-root.service`, which makes
|
||||
PID 1 kill the remaining processes, move `/sysroot` to `/` and re-execute
|
||||
itself from the real root.
|
||||
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
participant PID1 as systemd (PID 1)
|
||||
participant Bootvine as bootvine
|
||||
|
||||
PID1-->>Bootvine: JobNew initrd-switch-root.service
|
||||
Bootvine->>Bootvine: open a directory fd to /sysroot
|
||||
PID1->>PID1: isolate initrd-switch-root.target
|
||||
Note over Bootvine: kept, IgnoreOnIsolate=yes
|
||||
PID1->>PID1: kill remaining processes
|
||||
Note over Bootvine: spared, argv[0] is @bootvine
|
||||
PID1->>PID1: move /sysroot to /, re-execute
|
||||
PID1--xBootvine: private socket closes
|
||||
Bootvine->>Bootvine: fchdir to the fd, chroot(".")
|
||||
Bootvine->>PID1: reconnect to /run/systemd/private
|
||||
Note over Bootvine: stage 2, root is the default target
|
||||
```
|
||||
|
||||
Three things keep bootvine alive across it:
|
||||
|
||||
- **A process name starting with `@`.** `ExecStart=@/usr/bin/bootvine
|
||||
@bootvine` sets `argv[0]` to `@bootvine`, and switch-root spares processes
|
||||
whose name starts with `@`.
|
||||
- **`IgnoreOnIsolate=yes`**, so isolating `initrd-switch-root.target` does
|
||||
not stop the unit.
|
||||
- **A file descriptor to the new root.** After the switch, `/sysroot` no
|
||||
longer exists and bootvine's own root is still the old initramfs. A
|
||||
directory opened as soon as the switch-root job is queued lets it `chroot`
|
||||
into the real root, where `/run/systemd/private` is the re-executed PID 1.
|
||||
|
||||
When the connection drops, bootvine moves the initrd into the finished stages
|
||||
and reconnects for up to a minute.
|
||||
|
||||
## Lifecycle
|
||||
|
||||
### Boot
|
||||
|
||||
1. **Start**, in the initrd or in stage 2; see
|
||||
[starting in the initrd](#starting-in-the-initrd).
|
||||
2. **Switch to the real root**; see
|
||||
[surviving the switch](#surviving-the-switch-to-the-real-root).
|
||||
3. **Stage 2.** The tree shows the jobs still pending under the default
|
||||
target.
|
||||
4. **Handover.** bootvine hands the console back once the default target is
|
||||
reached and the final frame has stayed for `keep-final-frame-for`. When a
|
||||
display manager is starting, it waits instead for the display manager to
|
||||
switch to its own terminal, up to `wait-for-display-manager`.
|
||||
|
||||
If it starts after the boot has already finished, it exits without touching
|
||||
the console.
|
||||
|
||||
### Shutdown
|
||||
|
||||
`shutdown.target` conflicts with `bootvine.service` and wants
|
||||
`bootvine-shutdown.service`, which runs `bootvine --shutdown`. Its root is the
|
||||
target being brought up, such as `poweroff.target` or `reboot.target`. It
|
||||
shows the units being stopped, nested under the units that have to stop first,
|
||||
until PID 1 hands over to `systemd-shutdown` and the connection closes.
|
||||
|
||||
## The console
|
||||
|
||||
While it runs, bootvine:
|
||||
|
||||
- **brings `tty12` to the foreground**, and takes it back if something else
|
||||
switches away during the boot;
|
||||
- **quiets the kernel console** by setting the console log level in
|
||||
`/proc/sys/kernel/printk` to 1, so only emergency messages reach the
|
||||
screen, and sets it again if something raises it;
|
||||
- **silences systemd's status output** with the manager's `SetShowStatus`
|
||||
call;
|
||||
- **repaints every cell every 100 ms during a root switch**, because PID 1
|
||||
writes to the console and resets it while it re-executes, and drawing only
|
||||
the cells that changed would leave that on screen.
|
||||
|
||||
It restores the log level and the status output when it hands the console
|
||||
back. Kernel messages from before it starts are already on screen; see
|
||||
[early kernel messages](configuration.md#early-kernel-messages).
|
||||
|
||||
### Resuming from hibernation
|
||||
|
||||
The kernel freezes all processes before it loads a hibernated image, so
|
||||
bootvine cannot draw during the load. A drop-in on
|
||||
`systemd-hibernate-resume.service` runs `bootvine open-resume-console` first,
|
||||
which:
|
||||
|
||||
- creates `/run/bootvine/resume-console-open`, so the running bootvine stops
|
||||
drawing, stops resetting the log level and stops taking `tty12` back;
|
||||
- raises the console log level to 7, so the kernel's `pr_info` progress lines
|
||||
reach the screen, and hides their timestamps;
|
||||
- draws a band across the middle of `tty12`, limits scrolling to the two rows
|
||||
inside it, and sets the colour and cursor there. The kernel console writes at
|
||||
the cursor in the terminal's current colour, always from column 0, so it
|
||||
stays inside the band without knowing about it.
|
||||
|
||||
If an image is restored, none of this needs undoing: the boot kernel's memory
|
||||
is replaced, and the restored system keeps its own log level and terminals. If
|
||||
not, `bootvine close-resume-console` runs as `ExecStopPost`, restoring what
|
||||
the marker recorded, the colour and the scrolling, and bootvine repaints.
|
||||
|
||||
### Passphrase prompts
|
||||
|
||||
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.
|
||||
|
||||
## The units
|
||||
|
||||
| Unit | Wanted by | Notable settings |
|
||||
| --- | --- | --- |
|
||||
| `bootvine.service` | `sysinit.target` | `DefaultDependencies=no`, `IgnoreOnIsolate=yes`, `Before=display-manager.service`, process name `@bootvine` |
|
||||
| `bootvine-shutdown.service` | `shutdown.target` | `After=bootvine.service display-manager.service` |
|
||||
|
||||
Both draw on `/dev/tty12` with `TTYReset=yes` and log to the journal.
|
||||
|
||||
## One event loop
|
||||
|
||||
Everything runs on one thread. The service manager, the keyboard, the frame
|
||||
timer, password prompts and termination each produce a stream of inputs; the
|
||||
streams are merged, applied in batches to a single screen state, and the screen
|
||||
is drawn once per batch. The live boot and the scripted demos share this loop
|
||||
and differ only in where their inputs come from.
|
||||
|
||||
## systemd's private socket
|
||||
|
||||
- zbus rejects it, because PID 1 sends under its well-known name rather than a
|
||||
unique one. libdbus works.
|
||||
- libdbus sends its authentication handshake together with the first message,
|
||||
which systemd leaves unread, so a no-reply ping goes out right after
|
||||
connecting.
|
||||
@@ -1,166 +0,0 @@
|
||||
# Configuration
|
||||
|
||||
Every setting has a default, so bootvine needs no configuration. To change
|
||||
some, write only those keys:
|
||||
|
||||
- **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.
|
||||
|
||||
```nix
|
||||
services.bootvine.settings = {
|
||||
colors.tree.running-marker = "light-yellow";
|
||||
timing.keep-final-frame-for = "500ms";
|
||||
};
|
||||
```
|
||||
|
||||
- **On other distributions**, in `/etc/bootvine.toml`:
|
||||
|
||||
```toml
|
||||
[colors.tree]
|
||||
running-marker = "light-yellow"
|
||||
|
||||
[timing]
|
||||
keep-final-frame-for = "500ms"
|
||||
```
|
||||
|
||||
Then check the file and, if bootvine runs in your initrd, rebuild the
|
||||
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
|
||||
sudo dracut --force # or: sudo mkinitcpio -P
|
||||
```
|
||||
|
||||
At boot, bootvine ignores an invalid file and uses the defaults.
|
||||
|
||||
## Defaults
|
||||
|
||||
`bootvine defaults` prints every key with its default as TOML, and
|
||||
`bootvine defaults --format nix` prints the same as a Nix attribute set to
|
||||
paste into `services.bootvine.settings`:
|
||||
|
||||
```toml
|
||||
[colors.header]
|
||||
origin = "white"
|
||||
separators = "dark-gray"
|
||||
total-time = "white"
|
||||
|
||||
[colors.stages]
|
||||
branches = "dark-gray"
|
||||
finished-label = "gray"
|
||||
finished-time = "green"
|
||||
unit-count = "gray"
|
||||
failed-count = "light-red"
|
||||
current = "white"
|
||||
|
||||
[colors.tree]
|
||||
branches = "dark-gray"
|
||||
columns = "dark-gray"
|
||||
target = "cyan"
|
||||
current-stage = "yellow"
|
||||
reached-stage = "green"
|
||||
running-unit = "white"
|
||||
running-marker = "yellow"
|
||||
waiting-unit = "gray"
|
||||
finished-unit = "dark-gray"
|
||||
finished-marker = "green"
|
||||
failed-unit = "light-red"
|
||||
overflow = "gray"
|
||||
|
||||
[colors.timeline]
|
||||
rule = "dark-gray"
|
||||
title = "gray"
|
||||
axis = "dark-gray"
|
||||
milestone = "green"
|
||||
finished = "green"
|
||||
finished-label = "gray"
|
||||
failed = "light-red"
|
||||
queued-bar = "gray"
|
||||
running = "yellow"
|
||||
running-label = "white"
|
||||
|
||||
[colors.failures]
|
||||
rule = "dark-gray"
|
||||
title = "light-red"
|
||||
unit = "light-red"
|
||||
reason = "white"
|
||||
log = "gray"
|
||||
overflow = "dark-gray"
|
||||
|
||||
[colors.footer]
|
||||
rule = "dark-gray"
|
||||
done = "green"
|
||||
running = "yellow"
|
||||
waiting = "gray"
|
||||
failed = "light-red"
|
||||
no-failures = "gray"
|
||||
|
||||
[colors.password]
|
||||
frame = "yellow"
|
||||
message = "white"
|
||||
hint = "dark-gray"
|
||||
checking = "gray"
|
||||
rejected = "light-red"
|
||||
backdrop = "dark-gray"
|
||||
|
||||
[timing]
|
||||
keep-finished-units-for = "2s"
|
||||
hide-runs-shorter-than = "1s"
|
||||
keep-final-frame-for = "1s"
|
||||
wait-for-display-manager = "10s"
|
||||
```
|
||||
|
||||
## Colours
|
||||
|
||||
Each `[colors.*]` table covers one part of the screen:
|
||||
|
||||
| Table | Part |
|
||||
| --- | --- |
|
||||
| `header` | the top line with the origin and total time |
|
||||
| `stages` | the finished stages, such as the initrd |
|
||||
| `tree` | the unit tree |
|
||||
| `timeline` | the timeline of the slowest units |
|
||||
| `failures` | the failed units with their reason and last journal lines |
|
||||
| `footer` | the tallies of done, running, waiting and failed units |
|
||||
| `password` | the passphrase popup |
|
||||
|
||||
Values are the 16 console colour names, such as `yellow`, `light-yellow`,
|
||||
`gray` and `dark-gray`. To change how those 16 colours look, set the console
|
||||
palette instead: `console.colors` on NixOS, or the `vt.default_red`,
|
||||
`vt.default_grn` and `vt.default_blu` kernel parameters elsewhere.
|
||||
|
||||
## Timing
|
||||
|
||||
| Key | Meaning |
|
||||
| --- | --- |
|
||||
| `keep-finished-units-for` | How long a finished unit stays in the tree, faded, before it leaves. |
|
||||
| `hide-runs-shorter-than` | Runs shorter than this get no timer and no timeline bar. |
|
||||
| `keep-final-frame-for` | How long the last frame stays before the console is handed back. |
|
||||
| `wait-for-display-manager` | When a display manager is starting, how long to wait for it to switch to its own terminal instead, so the console's status lines never show in between. |
|
||||
|
||||
## Early kernel messages
|
||||
|
||||
bootvine silences the kernel console while it runs, but kernel messages from
|
||||
before it starts still reach the screen. To keep those to errors, boot with the
|
||||
`quiet` kernel parameter, or on NixOS set:
|
||||
|
||||
```nix
|
||||
boot.consoleLogLevel = 3;
|
||||
```
|
||||
|
||||
## Running it by hand
|
||||
|
||||
The units run bootvine with its defaults. Run by hand, it takes these options:
|
||||
|
||||
| Option | Meaning |
|
||||
| --- | --- |
|
||||
| `--config <path>` | Read the settings from another file than `/etc/bootvine.toml`. |
|
||||
| `--hold <duration>` | Override `timing.keep-final-frame-for`, e.g. `3s`. |
|
||||
| `--target <unit>` | Root the tree at this unit instead of the default target. |
|
||||
| `--user` | Watch your user service manager instead of PID 1. |
|
||||
| `--shutdown` | Follow a shutdown instead of a boot. |
|
||||
|
||||
[Development](development.md#testing) shows how to watch your user manager
|
||||
start a set of sample units this way.
|
||||
@@ -1,126 +0,0 @@
|
||||
# Development
|
||||
|
||||
## Layout
|
||||
|
||||
| Folder | Holds |
|
||||
| --- | --- |
|
||||
| `bootvine/` | the published crate: the library, the `bootvine` binary and the unit and initrd files it installs |
|
||||
| `scripted-demos/` | the scripted boot, shutdown and passphrase demos, and the VHS tapes that record them |
|
||||
| `xtask/` | repository tasks run with `cargo xtask` |
|
||||
| `vm-tests/` | the sample NixOS machines, one folder each with its VM check |
|
||||
| `nix/` | the crane builds and the NixOS module |
|
||||
| `recordings/` | ignored output of `record-screencasts`: the scripted demo GIFs and the sample machine WebP recordings, published on the `recordings` branch for the README and the [guide](guide.md) |
|
||||
|
||||
`cargo build` and `cargo test` act on every crate. `cargo run` needs the binary:
|
||||
`--bin bootvine`, `--bin scripted-boot` and so on.
|
||||
|
||||
## Setup
|
||||
|
||||
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
|
||||
|
||||
```sh
|
||||
cargo clippy --workspace --all-targets
|
||||
cargo fmt --all
|
||||
```
|
||||
|
||||
Clippy runs with the pedantic lints and forbids absolute paths; formatting
|
||||
needs the nightly toolchain the dev shell provides.
|
||||
|
||||
Commit messages follow [Conventional Commits](https://www.conventionalcommits.org).
|
||||
jj does not run git hooks, so check the commits you are about to push with:
|
||||
|
||||
```sh
|
||||
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` ([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'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](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.
|
||||
|
||||
## Releases
|
||||
|
||||
`.woodpecker/release-pr-and-publish.yaml` runs
|
||||
[release-plz](https://release-plz.dev) after the checks pass on `main`. It
|
||||
keeps a pull request labelled `release` open on Codeberg that bumps the version
|
||||
in `Cargo.toml` and adds the new commits to `CHANGELOG.md`. Only `feat`, `fix`
|
||||
and `perf` commits open one; a `!` or a `BREAKING CHANGE` footer bumps the
|
||||
minor version while bootvine is below 1.0. Merging that pull request publishes
|
||||
the crate to crates.io, tags the merge `v<version>` and creates a Codeberg
|
||||
release with the changelog. Settings are in `release-plz.toml`.
|
||||
|
||||
The pipeline needs two Woodpecker secrets: `codeberg_token`, a Codeberg access
|
||||
token with repository write access, and `cargo_registry_token`, a crates.io
|
||||
token that may publish new crates and updates. Preview the next release
|
||||
locally from the dev shell with `release-plz update`.
|
||||
|
||||
## Testing
|
||||
|
||||
| What | Command |
|
||||
| --- | --- |
|
||||
| Model and render tests | `cargo test --workspace` |
|
||||
| Scripted demos | `cargo run --bin scripted-boot` (also `scripted-shutdown`, `scripted-luks-unlock`) |
|
||||
| Sample machines in a window | `nix run .#sample-vm-<machine>`, see the [guide](guide.md#sample-machines) |
|
||||
| A sample machine's check | `nix build .#checks.x86_64-linux.vm-<machine>` |
|
||||
|
||||
To watch your own user manager start the sample units:
|
||||
|
||||
```sh
|
||||
units=$(nix build --no-link --print-out-paths .#sample-unit-files)
|
||||
systemctl --user link --runtime $units/*
|
||||
systemctl --user start --no-block bootvine-sample-services.target
|
||||
cargo run --bin bootvine -- --user --target bootvine-sample-services.target --hold 3s
|
||||
systemctl --user stop $(ls $units)
|
||||
systemctl --user disable --runtime $(ls $units)
|
||||
```
|
||||
|
||||
Everything a sample machine needs sits in its own folder under `vm-tests/`:
|
||||
`machine.nix`, `check.nix` and `check.py`. `vm-tests/shared/` holds the
|
||||
settings every machine shares, the window setup for `nix run`, the console
|
||||
helpers for the checks and the screen recorder. A new machine is a new folder
|
||||
plus its name in `vm-tests/default.nix`.
|
||||
|
||||
The VM checks read the console as text, hold the boot at fixed points and wait
|
||||
on marker files instead of sleeping. The failures check starts each failing
|
||||
unit by hand, so it knows which one is newest in the panel. While a check runs,
|
||||
`ScreenRecording` takes a frame every half second through a second QEMU
|
||||
monitor socket, so it never competes with the driver's own monitor; the frames
|
||||
land in the check's output under `recording/`. To step through a check by hand, run
|
||||
`nix run .#checks.x86_64-linux.vm-slow-services.driverInteractive` and
|
||||
call `test_script()`.
|
||||
|
||||
Prefix VM and recording commands with `env -u LD_LIBRARY_PATH` when your shell
|
||||
exports libraries that clash with [QEMU](https://www.qemu.org) or Chromium.
|
||||
|
||||
## Repository tasks
|
||||
|
||||
- `nix run .#record-screencasts` re-records the animations from the scripted
|
||||
demos and turns the frames each VM check captured into
|
||||
`recordings/<machine>.webp`, for the README and the [guide](guide.md).
|
||||
- `nix run .#publish-recordings` force-pushes `recordings/` as the single,
|
||||
parentless commit of the `recordings` branch, which the README and the guide
|
||||
link to. Keeping the recordings off `main` keeps them out of every clone and
|
||||
flake fetch.
|
||||
- `cargo xtask sync-default-config` rewrites the defaults block in
|
||||
[configuration](configuration.md#defaults) from `bootvine defaults`.
|
||||
- `cargo run --bin bootvine -- install --destdir <dir> --initrd dracut` stages an install
|
||||
without touching the system; `cargo run --bin bootvine -- uninstall --destdir <dir>` removes
|
||||
it again.
|
||||
|
||||
## Code style and design
|
||||
|
||||
- [Code style](style.md).
|
||||
- [Architecture](architecture.md): the event loop, the console
|
||||
takeover and the workarounds for systemd's private socket.
|
||||
@@ -1,214 +0,0 @@
|
||||
# Guide
|
||||
|
||||
What bootvine shows on the console, part by part, with the recordings that go
|
||||
with each. The GIFs come from the [scripted demos](#scripted-demos); the WebP
|
||||
animations are real boots of the [sample machines](#sample-machines), recorded
|
||||
by their [VM checks](development.md#testing).
|
||||
|
||||
## Reading the screen
|
||||
|
||||
<img src="https://codeberg.org/wvhulle/bootvine/raw/branch/recordings/boot.gif" width="691" alt="A boot through the initrd into stage 2, with one failed unit">
|
||||
|
||||
From top to bottom:
|
||||
|
||||
1. **The header**: the host name, the system and its generation on NixOS
|
||||
(otherwise the `PRETTY_NAME` from `os-release`), and the kernel. Once a
|
||||
stage has finished, the total time since the kernel started sits on the
|
||||
right.
|
||||
2. **The stages**: each finished stage, such as `Initrd`, with how long it
|
||||
took, how many units finished in it and how many of them failed. The stage
|
||||
still running is the last line, ending in `Running`.
|
||||
3. **The tree** of units with a pending job. Each unit is nested under the unit
|
||||
waiting on it, and the milestone targets (`sysinit.target`, `basic.target`,
|
||||
`multi-user.target`, `graphical.target`) open the levels:
|
||||
- `◆` is the stage being worked on, `◇` one still to come, `√` one reached
|
||||
(`*`, `o` and `+` on console fonts without those glyphs);
|
||||
- `[|]` with a spinner is running, `[ ]` is waiting, `[√]` finished in the
|
||||
last couple of seconds (`keep-finished-units-for`);
|
||||
- `[×]` in bold red broke or timed out; dimmed red failed only because a
|
||||
unit it needed did;
|
||||
- the `Running` column counts up while a unit runs, and after 5 seconds the
|
||||
`Timeout` column shows the limit systemd will stop it at, red once it
|
||||
is passed;
|
||||
- a unit waiting on exactly one other, which waits on exactly one other,
|
||||
folds into one row joined by `─`; mounts and devices show their
|
||||
description instead of their unit name.
|
||||
|
||||
When the tree is taller than the screen, finished and waiting rows give way
|
||||
first, and a last line counts the units left out.
|
||||
4. **The failure panel**, only once a unit broke or timed out; see
|
||||
[failures](#failures).
|
||||
5. **The timeline**, in the room left below the tree: the milestones reached,
|
||||
with how many units they took, the slowest finished units (up to five, and
|
||||
none shorter than `hide-runs-shorter-than`) and the units still running,
|
||||
as bars against seconds since the kernel started. A `│` marks the switch
|
||||
from the initrd to the real root.
|
||||
6. **The footer**: the units done, running, waiting and failed so far.
|
||||
|
||||
## Booting through the initrd
|
||||
|
||||
<img src="https://codeberg.org/wvhulle/bootvine/raw/branch/recordings/slow-services.webp" width="640" alt="A NixOS machine booting through the initrd into stage 2, handing over to a greetd login, then powering off">
|
||||
|
||||
The `slow-services` machine boots with a held hardware probe in the initrd,
|
||||
slow units in stage 2 and one failing unit, hands over to its greetd login
|
||||
and powers off. With a systemd initrd, bootvine starts about a second after
|
||||
the kernel:
|
||||
|
||||
- **The initrd stage**: udev settling, the root device and its file systems
|
||||
under `initrd.target`.
|
||||
- **The switch to the real root**: the initrd moves into the stages at the
|
||||
top, with its time and unit count, and the tree starts again under the
|
||||
default target. Until the new manager answers, the stage line says it is
|
||||
waiting for it. The timeline keeps the initrd's runs, left of the `│`.
|
||||
- **Stage 2** up to `graphical.target`.
|
||||
- **The handover**: bootvine hands the console back once the default target is
|
||||
reached, or earlier, once the display manager has switched to its own
|
||||
terminal.
|
||||
|
||||
How bootvine gets in that early and survives the switch is in
|
||||
[architecture](architecture.md#starting-in-the-initrd).
|
||||
|
||||
### Without a display manager
|
||||
|
||||
<img src="https://codeberg.org/wvhulle/bootvine/raw/branch/recordings/text-console.webp" width="640" alt="The same boot on a machine without a display manager, ending at a text login">
|
||||
|
||||
The `text-console` machine boots the same units without greetd. With no
|
||||
display manager to wait for, bootvine hands the console back as soon as the
|
||||
default target is reached, and the text login on `tty1` comes forward.
|
||||
|
||||
### Without a systemd initrd
|
||||
|
||||
<img src="https://codeberg.org/wvhulle/bootvine/raw/branch/recordings/scripted-initrd.webp" width="640" alt="The same boot with NixOS's scripted initrd: the kernel and initrd lines scroll past before bootvine starts in stage 2">
|
||||
|
||||
The `scripted-initrd` machine uses NixOS's older scripted initrd, which has no
|
||||
systemd. The initrd's lines scroll past as usual, and bootvine starts in
|
||||
stage 2, from `sysinit.target` on.
|
||||
|
||||
## Resuming from hibernation
|
||||
|
||||
<img src="https://codeberg.org/wvhulle/bootvine/raw/branch/recordings/hibernate-resume.webp" width="640" alt="The tree held still during a resume, with the kernel's image loading progress in a band across the middle of the screen">
|
||||
|
||||
Resuming from hibernation looks different from a boot, because the kernel
|
||||
freezes every process before it loads the image, bootvine included. The tree
|
||||
stops moving, and a band across the middle of the screen shows the kernel's own
|
||||
progress:
|
||||
|
||||
```
|
||||
─── Looking for a hibernated session ─────────────────────────────
|
||||
PM: Image loading progress: 60%
|
||||
|
||||
──────────────────────────────────────────────────────────────────
|
||||
```
|
||||
|
||||
The text comes straight from the kernel, which is why it is a line of text and
|
||||
not a bar. The screen stays like this until the restored system takes over.
|
||||
Bootvine does not draw again, because the restore replaces it along with the
|
||||
rest of the boot kernel's memory.
|
||||
|
||||
The last lines show how the time was spent. `Read ... in N seconds` is the
|
||||
image load. `Suspending console(s)` means the load has finished and the kernel
|
||||
is about to jump into the restored system. If the screen stays on that line for
|
||||
a long time, the wait is the restored kernel bringing devices back up, not the
|
||||
disk.
|
||||
|
||||
With no image to restore, `systemd-hibernate-resume` finishes at once and the
|
||||
band disappears. Some kernel console setups
|
||||
switch to a blank terminal for the load; the same lines then appear there.
|
||||
|
||||
## Shutdown
|
||||
|
||||
<img src="https://codeberg.org/wvhulle/bootvine/raw/branch/recordings/shutdown.gif" width="691" alt="A poweroff: units stopping under the targets waiting on them">
|
||||
|
||||
On a poweroff, reboot or halt the tree turns around:
|
||||
|
||||
- its root is the target being reached, such as `poweroff.target`;
|
||||
- each unit being stopped sits under the units that have to stop before it,
|
||||
so the unit holding up the shutdown is at the bottom of its branch;
|
||||
- `shutdown.target`, `umount.target` and `final.target` open the levels;
|
||||
- the screen stays until systemd hands over to `systemd-shutdown`.
|
||||
|
||||
## Passphrase prompts
|
||||
|
||||
<img src="https://codeberg.org/wvhulle/bootvine/raw/branch/recordings/encrypted-volume.webp" width="640" alt="A LUKS passphrase prompt floating over the initrd tree, a wrong answer, then the unlock">
|
||||
|
||||
The `encrypted-volume` machine asks for a LUKS passphrase in the initrd; its
|
||||
recording shows a wrong answer, then the right one.
|
||||
|
||||
|
||||
When a unit asks for a passphrase, such as `systemd-cryptsetup@….service`
|
||||
unlocking a [LUKS](https://gitlab.com/cryptsetup/cryptsetup) volume, the
|
||||
question floats over a dimmed tree:
|
||||
|
||||
- typing shows one mark per character;
|
||||
- `Enter` sends it, and the popup says it is checking;
|
||||
- a wrong passphrase brings the prompt back with "Wrong passphrase, try
|
||||
again";
|
||||
- once unlocked, the popup closes and the boot carries on.
|
||||
|
||||
If another password agent, such as Plymouth's, was already asking when
|
||||
bootvine started, bootvine waits behind it.
|
||||
|
||||
## Failures
|
||||
|
||||
<img src="https://codeberg.org/wvhulle/bootvine/raw/branch/recordings/failures.webp" width="640" alt="Units failing one after another, each landing in the failure panel with its reason and last journal lines">
|
||||
|
||||
A unit that broke or timed out gets an entry in the failure panel, newest
|
||||
first:
|
||||
|
||||
- **The headline**: the unit and why it failed, such as `exited with status 2`,
|
||||
`killed by SIGSEGV`, `timed out`, `restarted too often` or
|
||||
`exited with status 203` (systemd could not run the command). A service that
|
||||
reported a status with `sd_notify` adds it, as in
|
||||
`exited with status 1: Cannot reach database`.
|
||||
- **The journal lines**: up to six of the unit's last messages from this boot,
|
||||
the same ones `journalctl -u` shows, without systemd's own "Starting…" and
|
||||
"Failed with result…" lines.
|
||||
- **Out of room**: the newest failure keeps its lines, older ones shrink to
|
||||
their headline, and a last line counts the rest.
|
||||
- **What stays out**: a unit that failed only because one it needed did stays
|
||||
dimmed in the tree, so the panel points at the unit that actually broke.
|
||||
The footer counts both.
|
||||
|
||||
Failures from the initrd stay in the panel after the switch to the real root.
|
||||
The recording is the `failures` machine, where every kind of failure systemd
|
||||
reports happens one after another.
|
||||
|
||||
## Trying it
|
||||
|
||||
Neither of these touches your system's boot.
|
||||
|
||||
### Scripted demos
|
||||
|
||||
Play a scripted boot, poweroff and passphrase prompt in your terminal, with
|
||||
[Rust](https://www.rust-lang.org/tools/install) installed:
|
||||
|
||||
```sh
|
||||
git clone https://codeberg.org/wvhulle/bootvine.git
|
||||
cd bootvine
|
||||
cargo run --bin scripted-boot
|
||||
cargo run --bin scripted-shutdown
|
||||
cargo run --bin scripted-luks-unlock
|
||||
```
|
||||
|
||||
`q` quits. The encrypted root unlocks with the passphrase `demo`; `Esc` quits
|
||||
while it asks. These are the scenarios the animations above were recorded
|
||||
from.
|
||||
|
||||
### Sample machines
|
||||
|
||||
Each sample machine boots in a [QEMU](https://www.qemu.org) window with
|
||||
[Nix](https://nixos.org/download/), and logs in as root at the end. `poweroff`
|
||||
shows the shutdown.
|
||||
|
||||
| Run | Shows | Recording |
|
||||
| --- | --- | --- |
|
||||
| `nix run .#sample-vm-slow-services` | slow units in the initrd and stage 2, one failing unit, and the handover to a greetd login | [booting through the initrd](#booting-through-the-initrd) |
|
||||
| `nix run .#sample-vm-text-console` | the same units without a display manager, handing over at the default target | [without a display manager](#without-a-display-manager) |
|
||||
| `nix run .#sample-vm-scripted-initrd` | the same units with NixOS's scripted initrd, so bootvine starts in stage 2 only | [without a systemd initrd](#without-a-systemd-initrd) |
|
||||
| `nix run .#sample-vm-encrypted-volume` | a LUKS volume unlocked in the initrd; the passphrase is `sample passphrase` | [passphrase prompts](#passphrase-prompts) |
|
||||
| `nix run .#sample-vm-hibernate-resume` | a swap disk to hibernate to; run `systemctl hibernate`, then start the machine again | [resuming from hibernation](#resuming-from-hibernation) |
|
||||
| `nix run .#sample-vm-failures` | a firmware failure in the initrd, then units that exit with an error, crash, time out, cannot be run, restart too often, report a status, die after starting, and one that fails only through its dependency | [failures](#failures) |
|
||||
|
||||
Each machine keeps its disk in `~/.cache/bootvine-<machine>.qcow2`; delete it
|
||||
to start fresh. The machines live in `vm-tests/`, one folder each, next to the
|
||||
check that drives and records it.
|
||||
@@ -1,124 +0,0 @@
|
||||
# Install
|
||||
|
||||
bootvine always shows stage 2 and shutdown. To show the boot from the initrd
|
||||
as well, the initrd has to run systemd.
|
||||
|
||||
## NixOS
|
||||
|
||||
1. Add the flake to your system flake's inputs and pass its module in:
|
||||
|
||||
```nix
|
||||
{
|
||||
inputs.bootvine = {
|
||||
url = "git+https://codeberg.org/wvhulle/bootvine";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
outputs = { nixpkgs, bootvine, ... }: {
|
||||
nixosConfigurations.my-host = nixpkgs.lib.nixosSystem {
|
||||
modules = [
|
||||
bootvine.nixosModules.default
|
||||
./configuration.nix
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
2. Enable it in `configuration.nix`:
|
||||
|
||||
```nix
|
||||
{
|
||||
services.bootvine.enable = true;
|
||||
}
|
||||
```
|
||||
|
||||
The initrd is a systemd initrd by default since NixOS 26.05, and the only
|
||||
kind after it. On NixOS 25.11 and earlier, also set
|
||||
`boot.initrd.systemd.enable = true` to show the boot from the initrd.
|
||||
|
||||
3. Rebuild and reboot:
|
||||
|
||||
```sh
|
||||
sudo nixos-rebuild switch --flake .#my-host
|
||||
```
|
||||
|
||||
## Ubuntu
|
||||
|
||||
1. Install the build dependencies and Rust:
|
||||
|
||||
```sh
|
||||
sudo apt install build-essential pkg-config libdbus-1-dev libsystemd-dev git curl
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
||||
```
|
||||
|
||||
2. Build bootvine into `~/.cargo/bin`:
|
||||
|
||||
```sh
|
||||
cargo install --locked --git https://codeberg.org/wvhulle/bootvine bootvine
|
||||
```
|
||||
|
||||
3. Install it for the system and enable its units. It asks `sudo` itself for
|
||||
the copying and `systemctl enable`:
|
||||
|
||||
```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
|
||||
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`.
|
||||
|
||||
5. Reboot.
|
||||
|
||||
## Other distributions
|
||||
|
||||
Install as in the Ubuntu steps, with your distribution's packages for a C
|
||||
toolchain, `pkg-config` and the libdbus and libsystemd headers.
|
||||
|
||||
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
|
||||
bootvine install --initrd mkinitcpio
|
||||
```
|
||||
|
||||
2. Add `sd-bootvine` after `systemd` in `HOOKS` in `/etc/mkinitcpio.conf`.
|
||||
|
||||
3. Rebuild the initramfs:
|
||||
|
||||
```sh
|
||||
sudo mkinitcpio -P
|
||||
```
|
||||
|
||||
## Packaging
|
||||
|
||||
`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
|
||||
|
||||
`bootvine uninstall` disables and removes everything `bootvine install` put in
|
||||
place, with the same `--prefix` and `--destdir`. The current initramfs keeps
|
||||
its copy of bootvine until you rebuild it, so with an initrd hook installed it
|
||||
prints the command for that: `sudo dracut --force`, or for mkinitcpio, removing
|
||||
`sd-bootvine` from `HOOKS` and running `sudo mkinitcpio -P`. On NixOS, remove
|
||||
`services.bootvine.enable` and rebuild.
|
||||
@@ -1,10 +0,0 @@
|
||||
# Code style
|
||||
|
||||
- No comments; names and call flow carry the intent.
|
||||
- Public fields over getters, durations over raw integers, existing crates over
|
||||
hand-written formatting.
|
||||
- Iterator and stream combinators over loops.
|
||||
|
||||
Clippy runs with the pedantic lints and forbids absolute paths; formatting
|
||||
needs the nightly toolchain the dev shell provides. See
|
||||
[Development](development.md#before-committing) for the commands.
|
||||
|
After Width: | Height: | Size: 145 KiB |
|
After Width: | Height: | Size: 234 KiB |
@@ -1,64 +0,0 @@
|
||||
{
|
||||
"nodes": {
|
||||
"crane": {
|
||||
"locked": {
|
||||
"lastModified": 1790899423,
|
||||
"narHash": "sha256-THGtz65UGJU+sonZidRboyCMk+9DclpMF7pwL4uDV4M=",
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"rev": "47b6b27ed9a3a9181415e4367d0c30ab2a0e0250",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1790340521,
|
||||
"narHash": "sha256-cRrWlIjVRJ6BHDr9caUdXsZ3owzWIKYHpNmGPHBInIU=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "f5c082a40f7571c266e74e80ae2e68aadd8a9fc7",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"crane": "crane",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"rust-overlay": "rust-overlay"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1791707771,
|
||||
"narHash": "sha256-w3m8HtAVCfGTHw+gcCTAy7jFHSdGbokm8NngbeFrkek=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "c1cfa7a2c809d364ac1a7e9b3ec418afa3f19793",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
@@ -1,206 +0,0 @@
|
||||
{
|
||||
description = "bootvine — live dependency tree of systemd jobs on the boot console";
|
||||
|
||||
nixConfig = {
|
||||
extra-substituters = [ "https://wvhulle.cachix.org" ];
|
||||
extra-trusted-public-keys = [
|
||||
"wvhulle.cachix.org-1:heXx8DZMiRsKUx6l1TxNoF+Nmtmz66QEdsonQzc1ir0="
|
||||
];
|
||||
};
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
crane.url = "github:ipetkov/crane";
|
||||
rust-overlay = {
|
||||
url = "github:oxalica/rust-overlay";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs =
|
||||
{
|
||||
self,
|
||||
nixpkgs,
|
||||
crane,
|
||||
rust-overlay,
|
||||
}:
|
||||
let
|
||||
inherit (nixpkgs) lib;
|
||||
|
||||
forEachSystem =
|
||||
f:
|
||||
lib.genAttrs [ "x86_64-linux" "aarch64-linux" ] (
|
||||
system:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ (import rust-overlay) ];
|
||||
};
|
||||
rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
||||
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
|
||||
in
|
||||
f {
|
||||
inherit
|
||||
system
|
||||
pkgs
|
||||
craneLib
|
||||
rustToolchain
|
||||
;
|
||||
builds = import ./nix/crane-builds.nix { inherit lib pkgs craneLib; };
|
||||
}
|
||||
);
|
||||
|
||||
vmTests = import ./vm-tests {
|
||||
inherit lib;
|
||||
bootvineModule = self.nixosModules.bootvine;
|
||||
};
|
||||
in
|
||||
{
|
||||
packages = forEachSystem (
|
||||
{ pkgs, builds, ... }:
|
||||
{
|
||||
default = builds.bootvine;
|
||||
inherit (builds) bootvine scripted-demos repo-tasks;
|
||||
sample-unit-files = pkgs.callPackage ./vm-tests/slow-services/sample-unit-files.nix {
|
||||
inherit (vmTests) sampleUnits;
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
nixosModules = {
|
||||
default = self.nixosModules.bootvine;
|
||||
bootvine = import ./nix/nixos-module.nix { inherit self; };
|
||||
};
|
||||
|
||||
nixosConfigurations = lib.mapAttrs' (
|
||||
machineName: _:
|
||||
lib.nameValuePair "sample-${machineName}" (vmTests.nixosSystemFor "x86_64-linux" machineName)
|
||||
) vmTests.machines;
|
||||
|
||||
apps = forEachSystem (
|
||||
{
|
||||
pkgs,
|
||||
system,
|
||||
builds,
|
||||
rustToolchain,
|
||||
...
|
||||
}:
|
||||
let
|
||||
shellScriptApp = name: description: scriptArgs: {
|
||||
type = "app";
|
||||
meta.description = description;
|
||||
program = lib.getExe (pkgs.writeShellApplication ({ inherit name; } // scriptArgs));
|
||||
};
|
||||
|
||||
sampleMachineApps = lib.mapAttrs' (
|
||||
machineName: machineDescription:
|
||||
lib.nameValuePair "sample-vm-${machineName}" {
|
||||
type = "app";
|
||||
meta.description = "Boot the ${machineName} sample machine in QEMU: ${machineDescription}";
|
||||
program = lib.getExe (vmTests.nixosSystemFor system machineName).config.system.build.vm;
|
||||
}
|
||||
) vmTests.machineDescriptions;
|
||||
|
||||
releasePlzOnCodeberg =
|
||||
subcommand: description:
|
||||
shellScriptApp "release-plz-${subcommand}" description {
|
||||
runtimeInputs = [
|
||||
pkgs.release-plz
|
||||
pkgs.gitMinimal
|
||||
pkgs.pkg-config
|
||||
pkgs.stdenv.cc
|
||||
rustToolchain
|
||||
];
|
||||
runtimeEnv.PKG_CONFIG_PATH =
|
||||
lib.makeSearchPathOutput "dev" "lib/pkgconfig"
|
||||
builds.bootvine.buildInputs;
|
||||
text = ''exec release-plz ${subcommand} --forge gitea --git-token "$CODEBERG_TOKEN"'';
|
||||
};
|
||||
in
|
||||
sampleMachineApps
|
||||
// {
|
||||
release-plz-release = releasePlzOnCodeberg "release" "Publish unpublished versions to crates.io and tag them with a Codeberg release";
|
||||
release-plz-release-pr = releasePlzOnCodeberg "release-pr" "Open or update the Codeberg pull request that bumps the version and changelog";
|
||||
|
||||
record-screencasts =
|
||||
shellScriptApp "record-screencasts"
|
||||
"Re-record the scripted demo animations and the sample machine recordings into recordings/; publish them with publish-recordings"
|
||||
{
|
||||
runtimeInputs = [
|
||||
pkgs.vhs
|
||||
pkgs.libwebp
|
||||
builds.scripted-demos
|
||||
builds.repo-tasks
|
||||
];
|
||||
text = "exec xtask record-screencasts --vm-check-outputs ${
|
||||
pkgs.linkFarm "vm-check-outputs" (
|
||||
lib.mapAttrs (machineName: _: self.checks.${system}."vm-${machineName}") vmTests.machines
|
||||
)
|
||||
}";
|
||||
};
|
||||
|
||||
publish-recordings =
|
||||
shellScriptApp "publish-recordings"
|
||||
"Replace the recordings branch on origin with a single commit holding recordings/"
|
||||
{
|
||||
runtimeInputs = [
|
||||
pkgs.gitMinimal
|
||||
builds.repo-tasks
|
||||
];
|
||||
text = "exec xtask publish-recordings";
|
||||
};
|
||||
|
||||
build-and-push-to-cachix =
|
||||
shellScriptApp "build-and-push-to-cachix"
|
||||
"Build flake outputs and push everything built to the wvhulle Cachix cache"
|
||||
{
|
||||
runtimeInputs = [ pkgs.cachix ];
|
||||
text = ''exec cachix watch-exec wvhulle -- nix build --print-build-logs "$@"'';
|
||||
};
|
||||
|
||||
check-conventional-commits =
|
||||
shellScriptApp "check-conventional-commits"
|
||||
"Check that the commit messages in a git revision range are conventional commits"
|
||||
{
|
||||
runtimeInputs = [
|
||||
pkgs.convco
|
||||
pkgs.gitMinimal
|
||||
];
|
||||
text = ''exec convco check "$@"'';
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
checks = forEachSystem (
|
||||
{ pkgs, builds, ... }:
|
||||
{
|
||||
inherit (builds) rustfmt-formatting clippy-lints;
|
||||
bootvine-build = builds.bootvine;
|
||||
repo-tasks-build = builds.repo-tasks;
|
||||
}
|
||||
// lib.mapAttrs' (machineName: check: lib.nameValuePair "vm-${machineName}" check) (
|
||||
vmTests.checksFor pkgs
|
||||
)
|
||||
);
|
||||
|
||||
devShells = forEachSystem (
|
||||
{
|
||||
pkgs,
|
||||
craneLib,
|
||||
builds,
|
||||
...
|
||||
}:
|
||||
{
|
||||
default = craneLib.devShell {
|
||||
inputsFrom = [ builds.bootvine ];
|
||||
packages = [
|
||||
pkgs.prek
|
||||
pkgs.convco
|
||||
pkgs.release-plz
|
||||
pkgs.git-cliff
|
||||
];
|
||||
};
|
||||
}
|
||||
);
|
||||
};
|
||||
}
|
||||
|
After Width: | Height: | Size: 37 KiB |
@@ -1,85 +0,0 @@
|
||||
{
|
||||
lib,
|
||||
pkgs,
|
||||
craneLib,
|
||||
}:
|
||||
let
|
||||
bootvineCrate = craneLib.crateNameFromCargoToml { cargoToml = ../bootvine/Cargo.toml; };
|
||||
|
||||
commonArgs = {
|
||||
inherit (bootvineCrate) pname version;
|
||||
src = lib.fileset.toSource {
|
||||
root = ../.;
|
||||
fileset = lib.fileset.unions [
|
||||
(craneLib.fileset.commonCargoSources ../.)
|
||||
../bootvine/system-files
|
||||
../.rustfmt.toml
|
||||
];
|
||||
};
|
||||
strictDeps = true;
|
||||
nativeBuildInputs = [ pkgs.pkg-config ];
|
||||
buildInputs = [
|
||||
pkgs.dbus
|
||||
pkgs.systemd
|
||||
];
|
||||
};
|
||||
|
||||
cargoArtifacts = craneLib.buildDepsOnly (commonArgs // { pname = "bootvine-workspace"; });
|
||||
|
||||
buildWorkspaceMember =
|
||||
args: craneLib.buildPackage (commonArgs // { inherit cargoArtifacts; } // args);
|
||||
in
|
||||
{
|
||||
rustfmt-formatting = craneLib.cargoFmt {
|
||||
inherit (commonArgs) src pname version;
|
||||
cargoExtraArgs = "--all";
|
||||
};
|
||||
|
||||
clippy-lints = craneLib.cargoClippy (
|
||||
commonArgs
|
||||
// {
|
||||
inherit cargoArtifacts;
|
||||
cargoClippyExtraArgs = "--workspace --all-targets -- --deny warnings";
|
||||
}
|
||||
);
|
||||
|
||||
bootvine = buildWorkspaceMember {
|
||||
cargoExtraArgs = "-p bootvine";
|
||||
postInstall = ''
|
||||
for unit in bootvine.service bootvine-shutdown.service; do
|
||||
install -Dm644 bootvine/system-files/systemd/$unit $out/lib/systemd/system/$unit
|
||||
substituteInPlace $out/lib/systemd/system/$unit \
|
||||
--replace-fail /usr/bin/bootvine $out/bin/bootvine
|
||||
done
|
||||
resume_drop_in=systemd-hibernate-resume.service.d/bootvine.conf
|
||||
install -Dm644 bootvine/system-files/systemd/$resume_drop_in $out/lib/systemd/system/$resume_drop_in
|
||||
substituteInPlace $out/lib/systemd/system/$resume_drop_in \
|
||||
--replace-fail /usr/bin/bootvine $out/bin/bootvine
|
||||
install -Dm755 bootvine/system-files/dracut/90bootvine/module-setup.sh \
|
||||
$out/lib/dracut/modules.d/90bootvine/module-setup.sh
|
||||
install -Dm644 bootvine/system-files/mkinitcpio/install/sd-bootvine \
|
||||
$out/lib/initcpio/install/sd-bootvine
|
||||
'';
|
||||
meta = {
|
||||
mainProgram = "bootvine";
|
||||
platforms = lib.platforms.linux;
|
||||
license = lib.getLicenseFromSpdxId (lib.importTOML ../bootvine/Cargo.toml).package.license;
|
||||
};
|
||||
};
|
||||
|
||||
scripted-demos = buildWorkspaceMember {
|
||||
inherit (craneLib.crateNameFromCargoToml { cargoToml = ../scripted-demos/Cargo.toml; })
|
||||
pname
|
||||
version
|
||||
;
|
||||
cargoExtraArgs = "-p scripted-demos";
|
||||
doCheck = false;
|
||||
};
|
||||
|
||||
repo-tasks = buildWorkspaceMember {
|
||||
inherit (craneLib.crateNameFromCargoToml { cargoToml = ../xtask/Cargo.toml; }) pname version;
|
||||
cargoExtraArgs = "-p xtask";
|
||||
doCheck = false;
|
||||
meta.mainProgram = "xtask";
|
||||
};
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
{ self }:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.services.bootvine;
|
||||
settingsFormat = pkgs.formats.toml { };
|
||||
uncheckedConfigFile = settingsFormat.generate "bootvine-unchecked.toml" cfg.settings;
|
||||
canRunPackage = pkgs.stdenv.buildPlatform.canExecute pkgs.stdenv.hostPlatform;
|
||||
configFile = pkgs.runCommand "bootvine.toml" { } ''
|
||||
${lib.optionalString canRunPackage "${lib.getExe cfg.package} check ${uncheckedConfigFile}"}
|
||||
cp ${uncheckedConfigFile} $out
|
||||
'';
|
||||
hasSettings = cfg.settings != { };
|
||||
in
|
||||
{
|
||||
options.services.bootvine = {
|
||||
enable = lib.mkEnableOption ''
|
||||
a live dependency tree of systemd jobs on the boot console. With a
|
||||
systemd initrd it starts there and survives the switch to the real root;
|
||||
otherwise it starts in stage 2. It hands the console back once the
|
||||
display manager switches to its terminal or the default target is
|
||||
reached, and comes back
|
||||
for shutdown until systemd hands over to systemd-shutdown
|
||||
'';
|
||||
|
||||
package = lib.mkOption {
|
||||
type = lib.types.package;
|
||||
default = self.packages.${pkgs.stdenv.hostPlatform.system}.default;
|
||||
defaultText = lib.literalExpression "bootvine.packages.\${system}.default";
|
||||
description = "The bootvine package, which ships the systemd unit.";
|
||||
};
|
||||
|
||||
settings = lib.mkOption {
|
||||
inherit (settingsFormat) type;
|
||||
default = { };
|
||||
example = {
|
||||
colors.tree.running-marker = "light-yellow";
|
||||
timing.keep-final-frame-for = "500ms";
|
||||
};
|
||||
description = ''
|
||||
Written to {file}`/etc/bootvine.toml`, in the real root and the
|
||||
initrd. `bootvine defaults --format nix` prints every key with its
|
||||
default; the build fails if `bootvine check` rejects the result.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
environment = {
|
||||
systemPackages = [ cfg.package ];
|
||||
etc."bootvine.toml" = lib.mkIf hasSettings { source = configFile; };
|
||||
};
|
||||
|
||||
systemd = {
|
||||
packages = [ cfg.package ];
|
||||
services.bootvine.wantedBy = [ "sysinit.target" ];
|
||||
services.bootvine-shutdown.wantedBy = [ "shutdown.target" ];
|
||||
};
|
||||
|
||||
boot.initrd.systemd = {
|
||||
packages = [ cfg.package ];
|
||||
storePaths = [ (lib.getExe cfg.package) ];
|
||||
services.bootvine.wantedBy = [ "sysinit.target" ];
|
||||
contents."/etc/bootvine.toml" = lib.mkIf hasSettings { source = configFile; };
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
[workspace]
|
||||
release_always = true
|
||||
semver_check = false
|
||||
git_release_type = "prod"
|
||||
pr_labels = ["release"]
|
||||
pr_body = """
|
||||
{% for release in releases %}
|
||||
## `{{ release.package }}` {% if release.previous_version and release.previous_version != release.next_version %}{{ release.previous_version }} → {% endif %}{{ release.next_version }}
|
||||
|
||||
Merging this pull request into `main` will:
|
||||
|
||||
- tag the release commit as `v{{ release.next_version }}`
|
||||
- create the Codeberg release `v{{ release.next_version }}` with the changelog below
|
||||
- publish `{{ release.package }}` {{ release.next_version }} to crates.io
|
||||
|
||||
{% if release.changelog %}{{ release.changelog }}{% endif %}
|
||||
{% endfor %}
|
||||
"""
|
||||
|
||||
[[package]]
|
||||
name = "bootvine"
|
||||
changelog_path = "CHANGELOG.md"
|
||||
git_tag_name = "v{{ version }}"
|
||||
git_release_name = "v{{ version }}"
|
||||
|
||||
[changelog]
|
||||
tag_pattern = "v[0-9].*"
|
||||
sort_commits = "oldest"
|
||||
protect_breaking_commits = true
|
||||
commit_parsers = [
|
||||
{ message = "^feat", group = "Added" },
|
||||
{ message = "^fix", group = "Fixed" },
|
||||
{ message = "^doc", group = "Documentation" },
|
||||
{ message = "^perf", group = "Performance" },
|
||||
{ message = "^refactor", group = "Changed" },
|
||||
{ message = "^style", group = "Changed" },
|
||||
{ message = "^test", group = "Testing" },
|
||||
{ message = "^chore: release", skip = true },
|
||||
{ message = "^chore", group = "Miscellaneous" },
|
||||
{ message = "^ci", group = "CI" },
|
||||
{ message = "^build", group = "Build" },
|
||||
{ message = "^[Mm]erge", skip = true },
|
||||
{ message = ".*", group = "Other" },
|
||||
]
|
||||
@@ -1,3 +0,0 @@
|
||||
[toolchain]
|
||||
channel = "nightly-2026-07-19"
|
||||
components = ["rust-src", "rustfmt", "clippy", "rust-analyzer"]
|
||||
@@ -1,17 +0,0 @@
|
||||
[package]
|
||||
description = "Scripted boots, shutdowns and passphrase prompts that play bootvine's screen in a terminal"
|
||||
edition = "2024"
|
||||
license = "GPL-3.0-or-later"
|
||||
name = "scripted-demos"
|
||||
publish = false
|
||||
version = "0.1.0"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
bootvine = { path = "../bootvine" }
|
||||
futures = { version = "0.3.34", default-features = false, features = ["std"] }
|
||||
ratatui = "0.30.2"
|
||||
tokio = { version = "1.54.0", default-features = false, features = ["rt", "time"] }
|
||||
zeroize = "1.9.1"
|
||||
@@ -1,195 +0,0 @@
|
||||
use std::{io, time::Duration};
|
||||
|
||||
use bootvine::boot_model::Phase;
|
||||
use scripted_demos::scripted_boot::{Scenario, ScriptedFailure, Step, failing, play, step};
|
||||
|
||||
const INITRD: &[Step] = &[
|
||||
step(
|
||||
"initrd.target",
|
||||
&["initrd-fs.target", "initrd-root-device.target"],
|
||||
Duration::ZERO,
|
||||
),
|
||||
step("initrd-fs.target", &["sysroot.mount"], Duration::ZERO),
|
||||
step(
|
||||
"initrd-root-device.target",
|
||||
&["dev-disk-by\\x2dlabel-nixos.device"],
|
||||
Duration::ZERO,
|
||||
),
|
||||
step(
|
||||
"sysroot.mount",
|
||||
&["systemd-fsck-root.service"],
|
||||
Duration::from_millis(300),
|
||||
),
|
||||
step(
|
||||
"systemd-fsck-root.service",
|
||||
&["dev-disk-by\\x2dlabel-nixos.device"],
|
||||
Duration::from_millis(500),
|
||||
),
|
||||
step(
|
||||
"dev-disk-by\\x2dlabel-nixos.device",
|
||||
&[],
|
||||
Duration::from_millis(1200),
|
||||
),
|
||||
step("systemd-udevd.service", &[], Duration::from_millis(400)),
|
||||
step(
|
||||
"demo-initrd-probe.service",
|
||||
&[],
|
||||
Duration::from_millis(2500),
|
||||
),
|
||||
];
|
||||
|
||||
const HOST: &[Step] = &[
|
||||
step(
|
||||
"graphical.target",
|
||||
&["multi-user.target", "display-manager.service"],
|
||||
Duration::ZERO,
|
||||
),
|
||||
step(
|
||||
"display-manager.service",
|
||||
&["multi-user.target"],
|
||||
Duration::from_millis(400),
|
||||
),
|
||||
step(
|
||||
"multi-user.target",
|
||||
&[
|
||||
"basic.target",
|
||||
"NetworkManager-wait-online.service",
|
||||
"docker.service",
|
||||
"tailscaled.service",
|
||||
"nvidia-powerd.service",
|
||||
"systemd-rfkill.service",
|
||||
],
|
||||
Duration::ZERO,
|
||||
),
|
||||
step("basic.target", &["sysinit.target"], Duration::ZERO),
|
||||
step(
|
||||
"sysinit.target",
|
||||
&[
|
||||
"systemd-tmpfiles-setup.service",
|
||||
"systemd-udev-trigger.service",
|
||||
],
|
||||
Duration::ZERO,
|
||||
),
|
||||
step(
|
||||
"systemd-tmpfiles-setup.service",
|
||||
&[],
|
||||
Duration::from_millis(600),
|
||||
),
|
||||
step(
|
||||
"systemd-udev-trigger.service",
|
||||
&[],
|
||||
Duration::from_millis(900),
|
||||
),
|
||||
step(
|
||||
"NetworkManager.service",
|
||||
&["basic.target"],
|
||||
Duration::from_millis(1500),
|
||||
),
|
||||
step(
|
||||
"NetworkManager-wait-online.service",
|
||||
&["NetworkManager.service"],
|
||||
Duration::from_millis(3500),
|
||||
),
|
||||
step(
|
||||
"network-online.target",
|
||||
&["NetworkManager-wait-online.service"],
|
||||
Duration::ZERO,
|
||||
),
|
||||
step(
|
||||
"tailscaled.service",
|
||||
&["network-online.target"],
|
||||
Duration::from_millis(1200),
|
||||
),
|
||||
step(
|
||||
"containerd.service",
|
||||
&["basic.target"],
|
||||
Duration::from_millis(800),
|
||||
),
|
||||
step(
|
||||
"docker.socket",
|
||||
&["basic.target"],
|
||||
Duration::from_millis(200),
|
||||
),
|
||||
step("var-lib-docker.mount", &[], Duration::from_millis(1800)),
|
||||
step(
|
||||
"docker.service",
|
||||
&[
|
||||
"containerd.service",
|
||||
"docker.socket",
|
||||
"var-lib-docker.mount",
|
||||
"network-online.target",
|
||||
],
|
||||
Duration::from_millis(1500),
|
||||
),
|
||||
failing(
|
||||
"nvidia-powerd.service",
|
||||
&["basic.target"],
|
||||
Duration::from_millis(700),
|
||||
ScriptedFailure {
|
||||
reason: "exited with status 1",
|
||||
log_lines: &[
|
||||
"nvidia-powerd version:1.0(build 1)",
|
||||
"ERROR! Failed to get system power limits",
|
||||
"ERROR! Client (presumably SBIOS) has not registered for D-Notify events",
|
||||
],
|
||||
},
|
||||
),
|
||||
step(
|
||||
"sys-devices-virtual-misc-rfkill.device",
|
||||
&[],
|
||||
Duration::from_millis(7000),
|
||||
)
|
||||
.timing_out_after(Duration::from_secs(90)),
|
||||
step(
|
||||
"systemd-rfkill.service",
|
||||
&["sys-devices-virtual-misc-rfkill.device"],
|
||||
Duration::from_millis(300),
|
||||
),
|
||||
];
|
||||
|
||||
fn description(unit: &str) -> Option<&'static str> {
|
||||
let description = match unit {
|
||||
"initrd.target" => "Initrd Default Target",
|
||||
"initrd-fs.target" => "Initrd File Systems",
|
||||
"initrd-root-device.target" => "Initrd Root Device",
|
||||
"sysroot.mount" => "/sysroot",
|
||||
"systemd-fsck-root.service" => "File System Check on Root Device",
|
||||
"dev-disk-by\\x2dlabel-nixos.device" => "/dev/disk/by-label/nixos",
|
||||
"systemd-udevd.service" => "Rule-based Manager for Device Events and Files",
|
||||
"demo-initrd-probe.service" => "Slow hardware probe",
|
||||
"graphical.target" => "Graphical Interface",
|
||||
"display-manager.service" => "Display Manager",
|
||||
"multi-user.target" => "Multi-User System",
|
||||
"basic.target" => "Basic System",
|
||||
"sysinit.target" => "System Initialization",
|
||||
"systemd-tmpfiles-setup.service" => "Create System Files and Directories",
|
||||
"systemd-udev-trigger.service" => "Coldplug All udev Devices",
|
||||
"NetworkManager.service" => "Network Manager",
|
||||
"NetworkManager-wait-online.service" => "Network Manager Wait Online",
|
||||
"network-online.target" => "Network is Online",
|
||||
"tailscaled.service" => "Tailscale node agent",
|
||||
"containerd.service" => "containerd container runtime",
|
||||
"docker.socket" => "Docker Socket for the API",
|
||||
"docker.service" => "Docker Application Container Engine",
|
||||
"var-lib-docker.mount" => "/var/lib/docker",
|
||||
"nvidia-powerd.service" => "NVIDIA Dynamic Boost",
|
||||
"sys-devices-virtual-misc-rfkill.device" => "/sys/devices/virtual/misc/rfkill",
|
||||
"systemd-rfkill.service" => "Load/Save RF Kill Switch Status",
|
||||
_ => return None,
|
||||
};
|
||||
Some(description)
|
||||
}
|
||||
|
||||
fn main() -> io::Result<()> {
|
||||
ratatui::run(|terminal| {
|
||||
play(
|
||||
terminal,
|
||||
&Scenario {
|
||||
phase: Phase::Initrd,
|
||||
steps: INITRD,
|
||||
after_switch_root: HOST,
|
||||
describe: description,
|
||||
},
|
||||
)
|
||||
})
|
||||
}
|
||||
@@ -1,203 +0,0 @@
|
||||
use std::{io, time::Duration};
|
||||
|
||||
use bootvine::boot_model::Phase;
|
||||
use scripted_demos::scripted_boot::{Scenario, Step, play, step, unlocking};
|
||||
|
||||
const ROOT_PARTITION: &str =
|
||||
"dev-disk-by\\x2duuid-7c2e9f4a\\x2d1b3d\\x2d4e8f\\x2d9a6c\\x2d2d5b8e1f0c3a.device";
|
||||
|
||||
const INITRD: &[Step] = &[
|
||||
step(
|
||||
"initrd.target",
|
||||
&["initrd-fs.target", "initrd-root-fs.target"],
|
||||
Duration::ZERO,
|
||||
),
|
||||
step(
|
||||
"initrd-fs.target",
|
||||
&["initrd-root-fs.target"],
|
||||
Duration::ZERO,
|
||||
),
|
||||
step("initrd-root-fs.target", &["sysroot.mount"], Duration::ZERO),
|
||||
step(
|
||||
"sysroot.mount",
|
||||
&["systemd-fsck-root.service"],
|
||||
Duration::from_millis(400),
|
||||
),
|
||||
step(
|
||||
"systemd-fsck-root.service",
|
||||
&["initrd-root-device.target"],
|
||||
Duration::from_millis(600),
|
||||
),
|
||||
step(
|
||||
"initrd-root-device.target",
|
||||
&["dev-mapper-cryptroot.device"],
|
||||
Duration::ZERO,
|
||||
),
|
||||
step(
|
||||
"dev-mapper-cryptroot.device",
|
||||
&["cryptsetup.target"],
|
||||
Duration::from_millis(100),
|
||||
),
|
||||
step(
|
||||
"cryptsetup.target",
|
||||
&["systemd-cryptsetup@cryptroot.service"],
|
||||
Duration::ZERO,
|
||||
),
|
||||
unlocking(
|
||||
"systemd-cryptsetup@cryptroot.service",
|
||||
&["cryptsetup-pre.target", ROOT_PARTITION],
|
||||
"Please enter passphrase for disk Samsung SSD 980 PRO 1TB (cryptroot):",
|
||||
Duration::from_millis(2000),
|
||||
),
|
||||
step(
|
||||
"cryptsetup-pre.target",
|
||||
&["systemd-udevd.service"],
|
||||
Duration::ZERO,
|
||||
),
|
||||
step(
|
||||
ROOT_PARTITION,
|
||||
&["systemd-udev-trigger.service"],
|
||||
Duration::from_millis(1100),
|
||||
),
|
||||
step(
|
||||
"systemd-udev-trigger.service",
|
||||
&["systemd-udevd.service"],
|
||||
Duration::from_millis(500),
|
||||
),
|
||||
step(
|
||||
"systemd-udevd.service",
|
||||
&["systemd-tmpfiles-setup-dev.service"],
|
||||
Duration::from_millis(200),
|
||||
),
|
||||
step(
|
||||
"systemd-tmpfiles-setup-dev.service",
|
||||
&["kmod-static-nodes.service"],
|
||||
Duration::from_millis(100),
|
||||
),
|
||||
step("kmod-static-nodes.service", &[], Duration::from_millis(100)),
|
||||
step("systemd-journald.service", &[], Duration::from_millis(300)),
|
||||
step(
|
||||
"systemd-modules-load.service",
|
||||
&[],
|
||||
Duration::from_millis(900),
|
||||
),
|
||||
step(
|
||||
"systemd-vconsole-setup.service",
|
||||
&["systemd-modules-load.service"],
|
||||
Duration::from_millis(200),
|
||||
),
|
||||
step(
|
||||
"systemd-sysctl.service",
|
||||
&["systemd-modules-load.service"],
|
||||
Duration::from_millis(100),
|
||||
),
|
||||
];
|
||||
|
||||
const HOST: &[Step] = &[
|
||||
step(
|
||||
"graphical.target",
|
||||
&["multi-user.target", "display-manager.service"],
|
||||
Duration::ZERO,
|
||||
),
|
||||
step(
|
||||
"display-manager.service",
|
||||
&["systemd-logind.service"],
|
||||
Duration::from_millis(600),
|
||||
),
|
||||
step(
|
||||
"multi-user.target",
|
||||
&[
|
||||
"basic.target",
|
||||
"NetworkManager.service",
|
||||
"systemd-logind.service",
|
||||
"systemd-timesyncd.service",
|
||||
],
|
||||
Duration::ZERO,
|
||||
),
|
||||
step("basic.target", &["sysinit.target"], Duration::ZERO),
|
||||
step(
|
||||
"sysinit.target",
|
||||
&[
|
||||
"systemd-tmpfiles-setup.service",
|
||||
"systemd-udev-trigger.service",
|
||||
"home.mount",
|
||||
],
|
||||
Duration::ZERO,
|
||||
),
|
||||
step(
|
||||
"systemd-tmpfiles-setup.service",
|
||||
&[],
|
||||
Duration::from_millis(400),
|
||||
),
|
||||
step(
|
||||
"systemd-udev-trigger.service",
|
||||
&[],
|
||||
Duration::from_millis(800),
|
||||
),
|
||||
step("home.mount", &[], Duration::from_millis(300)),
|
||||
step(
|
||||
"systemd-logind.service",
|
||||
&["basic.target"],
|
||||
Duration::from_millis(300),
|
||||
),
|
||||
step(
|
||||
"NetworkManager.service",
|
||||
&["basic.target"],
|
||||
Duration::from_millis(1400),
|
||||
),
|
||||
step(
|
||||
"systemd-timesyncd.service",
|
||||
&["basic.target"],
|
||||
Duration::from_millis(500),
|
||||
),
|
||||
];
|
||||
|
||||
fn description(unit: &str) -> Option<&'static str> {
|
||||
let description = match unit {
|
||||
"initrd.target" => "Initrd Default Target",
|
||||
"initrd-fs.target" => "Initrd File Systems",
|
||||
"initrd-root-fs.target" => "Initrd Root File System",
|
||||
"initrd-root-device.target" => "Initrd Root Device",
|
||||
"sysroot.mount" => "/sysroot",
|
||||
"systemd-fsck-root.service" => "File System Check on /dev/mapper/cryptroot",
|
||||
"dev-mapper-cryptroot.device" => "/dev/mapper/cryptroot",
|
||||
"cryptsetup.target" => "Local Encrypted Volumes",
|
||||
"cryptsetup-pre.target" => "Local Encrypted Volumes (Pre)",
|
||||
"systemd-cryptsetup@cryptroot.service" => "Cryptography Setup for cryptroot",
|
||||
ROOT_PARTITION => "Samsung SSD 980 PRO 1TB cryptroot",
|
||||
"systemd-udev-trigger.service" => "Coldplug All udev Devices",
|
||||
"systemd-udevd.service" => "Rule-based Manager for Device Events and Files",
|
||||
"systemd-tmpfiles-setup-dev.service" => "Create Static Device Nodes in /dev",
|
||||
"kmod-static-nodes.service" => "Create List of Static Device Nodes",
|
||||
"systemd-journald.service" => "Journal Service",
|
||||
"systemd-modules-load.service" => "Load Kernel Modules",
|
||||
"systemd-vconsole-setup.service" => "Virtual Console Setup",
|
||||
"systemd-sysctl.service" => "Apply Kernel Variables",
|
||||
"graphical.target" => "Graphical Interface",
|
||||
"display-manager.service" => "Display Manager",
|
||||
"multi-user.target" => "Multi-User System",
|
||||
"basic.target" => "Basic System",
|
||||
"sysinit.target" => "System Initialization",
|
||||
"systemd-tmpfiles-setup.service" => "Create System Files and Directories",
|
||||
"home.mount" => "/home",
|
||||
"systemd-logind.service" => "User Login Management",
|
||||
"NetworkManager.service" => "Network Manager",
|
||||
"systemd-timesyncd.service" => "Network Time Synchronization",
|
||||
_ => return None,
|
||||
};
|
||||
Some(description)
|
||||
}
|
||||
|
||||
fn main() -> io::Result<()> {
|
||||
ratatui::run(|terminal| {
|
||||
play(
|
||||
terminal,
|
||||
&Scenario {
|
||||
phase: Phase::Initrd,
|
||||
steps: INITRD,
|
||||
after_switch_root: HOST,
|
||||
describe: description,
|
||||
},
|
||||
)
|
||||
})
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
use std::{io, time::Duration};
|
||||
|
||||
use bootvine::boot_model::Phase;
|
||||
use scripted_demos::scripted_boot::{Scenario, Step, play, step, stopping};
|
||||
|
||||
const SHUTDOWN: &[Step] = &[
|
||||
step(
|
||||
"poweroff.target",
|
||||
&["systemd-poweroff.service"],
|
||||
Duration::ZERO,
|
||||
),
|
||||
step(
|
||||
"systemd-poweroff.service",
|
||||
&["final.target"],
|
||||
Duration::from_millis(300),
|
||||
),
|
||||
step("final.target", &["umount.target"], Duration::ZERO),
|
||||
step(
|
||||
"umount.target",
|
||||
&["shutdown.target", "var-lib-docker.mount", "home.mount"],
|
||||
Duration::ZERO,
|
||||
),
|
||||
step(
|
||||
"shutdown.target",
|
||||
&[
|
||||
"display-manager.service",
|
||||
"user@1000.service",
|
||||
"docker.service",
|
||||
"containerd.service",
|
||||
"tailscaled.service",
|
||||
"NetworkManager.service",
|
||||
],
|
||||
Duration::ZERO,
|
||||
),
|
||||
stopping("display-manager.service", &[], Duration::from_millis(900)),
|
||||
stopping(
|
||||
"user@1000.service",
|
||||
&["display-manager.service"],
|
||||
Duration::from_millis(1600),
|
||||
),
|
||||
stopping("docker.service", &[], Duration::from_millis(6500))
|
||||
.timing_out_after(Duration::from_secs(90)),
|
||||
stopping(
|
||||
"containerd.service",
|
||||
&["docker.service"],
|
||||
Duration::from_millis(700),
|
||||
),
|
||||
stopping("tailscaled.service", &[], Duration::from_millis(1100)),
|
||||
stopping(
|
||||
"NetworkManager.service",
|
||||
&["tailscaled.service", "docker.service"],
|
||||
Duration::from_millis(600),
|
||||
),
|
||||
stopping(
|
||||
"var-lib-docker.mount",
|
||||
&["docker.service", "containerd.service"],
|
||||
Duration::from_millis(400),
|
||||
),
|
||||
stopping(
|
||||
"home.mount",
|
||||
&["user@1000.service"],
|
||||
Duration::from_millis(500),
|
||||
),
|
||||
];
|
||||
|
||||
fn description(unit: &str) -> Option<&'static str> {
|
||||
let description = match unit {
|
||||
"poweroff.target" | "systemd-poweroff.service" => "System Power Off",
|
||||
"final.target" => "Late Shutdown Services",
|
||||
"umount.target" => "Unmount All Filesystems",
|
||||
"shutdown.target" => "System Shutdown",
|
||||
"display-manager.service" => "Display Manager",
|
||||
"user@1000.service" => "User Manager for UID 1000",
|
||||
"docker.service" => "Docker Application Container Engine",
|
||||
"containerd.service" => "containerd container runtime",
|
||||
"tailscaled.service" => "Tailscale node agent",
|
||||
"NetworkManager.service" => "Network Manager",
|
||||
"var-lib-docker.mount" => "/var/lib/docker",
|
||||
"home.mount" => "/home",
|
||||
_ => return None,
|
||||
};
|
||||
Some(description)
|
||||
}
|
||||
|
||||
fn main() -> io::Result<()> {
|
||||
ratatui::run(|terminal| {
|
||||
play(
|
||||
terminal,
|
||||
&Scenario {
|
||||
phase: Phase::Shutdown,
|
||||
steps: SHUTDOWN,
|
||||
after_switch_root: &[],
|
||||
describe: description,
|
||||
},
|
||||
)
|
||||
})
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
pub mod scripted_boot;
|
||||
@@ -1,519 +0,0 @@
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
io,
|
||||
iter::once,
|
||||
mem,
|
||||
ops::ControlFlow,
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use bootvine::{
|
||||
boot_model::{
|
||||
ActiveState, Activity, BootChange, BootState, FailureCause, JobKind, JobResult, Phase,
|
||||
UnitFacts, UnitTimeouts, boot_origin::BootOrigin,
|
||||
},
|
||||
boot_view::PasswordPrompt,
|
||||
console_session::{
|
||||
passphrase_input,
|
||||
stream_sources::{frame_inputs, key_inputs},
|
||||
watch_screen::{ConsoleDesk, WatchEnding, WatchScreen, watch_until_ending},
|
||||
},
|
||||
screen_settings::{color_scheme::Colors, config_file::Timing},
|
||||
systemd_link::monotonic_clock::monotonic_now,
|
||||
};
|
||||
use futures::stream;
|
||||
use ratatui::{DefaultTerminal, crossterm::event::Event};
|
||||
use tokio::runtime::Builder;
|
||||
use zeroize::Zeroizing;
|
||||
|
||||
const FINAL_FRAME: Duration = Duration::from_secs(3);
|
||||
|
||||
pub const DEMO_PASSPHRASE: &str = "demo";
|
||||
const DEMO_PASSPHRASE_HINT: &str = "This demo unlocks with the passphrase \"demo\"";
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct ScriptedFailure {
|
||||
pub reason: &'static str,
|
||||
pub log_lines: &'static [&'static str],
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
enum StepEnding {
|
||||
Succeeds,
|
||||
Fails(ScriptedFailure),
|
||||
}
|
||||
|
||||
pub struct Step {
|
||||
unit: &'static str,
|
||||
after: &'static [&'static str],
|
||||
work: Duration,
|
||||
ending: StepEnding,
|
||||
stops: bool,
|
||||
asks: Option<&'static str>,
|
||||
timeout: Option<Duration>,
|
||||
}
|
||||
|
||||
impl Step {
|
||||
#[must_use]
|
||||
pub const fn timing_out_after(self, limit: Duration) -> Self {
|
||||
Self {
|
||||
timeout: Some(limit),
|
||||
..self
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub const fn step(unit: &'static str, after: &'static [&'static str], work: Duration) -> Step {
|
||||
Step {
|
||||
unit,
|
||||
after,
|
||||
work,
|
||||
ending: StepEnding::Succeeds,
|
||||
stops: false,
|
||||
asks: None,
|
||||
timeout: None,
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub const fn failing(
|
||||
unit: &'static str,
|
||||
after: &'static [&'static str],
|
||||
work: Duration,
|
||||
failure: ScriptedFailure,
|
||||
) -> Step {
|
||||
Step {
|
||||
ending: StepEnding::Fails(failure),
|
||||
..step(unit, after, work)
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub const fn stopping(unit: &'static str, after: &'static [&'static str], work: Duration) -> Step {
|
||||
Step {
|
||||
stops: true,
|
||||
..step(unit, after, work)
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub const fn unlocking(
|
||||
unit: &'static str,
|
||||
after: &'static [&'static str],
|
||||
message: &'static str,
|
||||
key_derivation: Duration,
|
||||
) -> Step {
|
||||
Step {
|
||||
asks: Some(message),
|
||||
..step(unit, after, key_derivation)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Scenario {
|
||||
pub phase: Phase,
|
||||
pub steps: &'static [Step],
|
||||
pub after_switch_root: &'static [Step],
|
||||
pub describe: fn(&str) -> Option<&'static str>,
|
||||
}
|
||||
|
||||
struct ScriptedJob {
|
||||
id: u32,
|
||||
step: &'static Step,
|
||||
}
|
||||
|
||||
impl ScriptedJob {
|
||||
fn facts(&self, steps: &[Step], describe: fn(&str) -> Option<&'static str>) -> UnitFacts {
|
||||
let is_stopping = |unit: &&str| steps.iter().any(|step| step.unit == *unit && step.stops);
|
||||
let (before, after): (Vec<&str>, Vec<&str>) =
|
||||
self.step.after.iter().copied().partition(is_stopping);
|
||||
UnitFacts {
|
||||
name: self.step.unit.to_owned(),
|
||||
description: describe(self.step.unit).map(str::to_owned),
|
||||
after: after.into_iter().map(ToString::to_string).collect(),
|
||||
before: before.into_iter().map(ToString::to_string).collect(),
|
||||
timeouts: UnitTimeouts {
|
||||
job_running: self.step.timeout,
|
||||
..UnitTimeouts::default()
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
fn kind(&self) -> JobKind {
|
||||
if self.step.stops {
|
||||
JobKind::TakesDown
|
||||
} else {
|
||||
JobKind::BringsUp
|
||||
}
|
||||
}
|
||||
|
||||
fn outcome(&self) -> JobResult {
|
||||
if matches!(self.step.ending, StepEnding::Fails(_)) {
|
||||
JobResult::Failed
|
||||
} else {
|
||||
JobResult::Done
|
||||
}
|
||||
}
|
||||
|
||||
fn explanation(&self) -> Option<BootChange> {
|
||||
let StepEnding::Fails(failure) = self.step.ending else {
|
||||
return None;
|
||||
};
|
||||
Some(BootChange::ExplainFailure {
|
||||
unit: self.step.unit.to_owned(),
|
||||
cause: FailureCause {
|
||||
reason: failure.reason.to_owned(),
|
||||
log_lines: failure.log_lines.iter().map(ToString::to_string).collect(),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
fn initial_activity(&self) -> Activity {
|
||||
Activity {
|
||||
state: self.step.stops.then_some(ActiveState::Active),
|
||||
..Activity::default()
|
||||
}
|
||||
}
|
||||
|
||||
fn started_activity(&self, now: Duration) -> Activity {
|
||||
if self.step.stops {
|
||||
Activity {
|
||||
state: Some(ActiveState::Deactivating),
|
||||
active_exit: Some(now),
|
||||
..Activity::default()
|
||||
}
|
||||
} else {
|
||||
Activity {
|
||||
state: Some(ActiveState::Activating),
|
||||
inactive_exit: Some(now),
|
||||
..Activity::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn settled_activity(&self, now: Duration) -> Activity {
|
||||
let state = if matches!(self.step.ending, StepEnding::Fails(_)) {
|
||||
ActiveState::Failed
|
||||
} else if self.step.stops {
|
||||
ActiveState::Inactive
|
||||
} else {
|
||||
ActiveState::Active
|
||||
};
|
||||
Activity {
|
||||
state: Some(state),
|
||||
active_enter: (!self.step.stops).then_some(now),
|
||||
..Activity::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct Script {
|
||||
steps: &'static [Step],
|
||||
jobs: Vec<ScriptedJob>,
|
||||
started: HashMap<&'static str, Duration>,
|
||||
finished: HashSet<&'static str>,
|
||||
answer: Option<Answer>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
struct Answer {
|
||||
checked_at: Duration,
|
||||
unlocks: bool,
|
||||
}
|
||||
|
||||
impl Script {
|
||||
fn begin(steps: &'static [Step], first_job: u32) -> Self {
|
||||
Self {
|
||||
steps,
|
||||
jobs: steps
|
||||
.iter()
|
||||
.zip(first_job..)
|
||||
.map(|(step, id)| ScriptedJob { id, step })
|
||||
.collect(),
|
||||
started: HashMap::new(),
|
||||
finished: HashSet::new(),
|
||||
answer: None,
|
||||
}
|
||||
}
|
||||
|
||||
fn opening_changes(
|
||||
&self,
|
||||
describe: fn(&str) -> Option<&'static str>,
|
||||
now: Duration,
|
||||
) -> Vec<BootChange> {
|
||||
once(BootChange::SetRoot(self.steps[0].unit.to_owned()))
|
||||
.chain(self.jobs.iter().map(|job| BootChange::TrackUnit {
|
||||
facts: job.facts(self.steps, describe),
|
||||
activity: job.initial_activity(),
|
||||
}))
|
||||
.chain(self.jobs.iter().map(|job| BootChange::QueueJob {
|
||||
id: job.id,
|
||||
unit: job.step.unit.to_owned(),
|
||||
kind: job.kind(),
|
||||
at: now,
|
||||
}))
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn asking(&self) -> Option<&'static Step> {
|
||||
self.jobs.iter().map(|job| job.step).find(|step| {
|
||||
step.asks.is_some()
|
||||
&& self.started.contains_key(step.unit)
|
||||
&& !self.finished.contains(step.unit)
|
||||
})
|
||||
}
|
||||
|
||||
fn is_checking(&self, now: Duration) -> bool {
|
||||
self.answer.is_some_and(|answer| now < answer.checked_at)
|
||||
}
|
||||
|
||||
fn was_rejected(&self, now: Duration) -> bool {
|
||||
self.answer
|
||||
.is_some_and(|answer| !answer.unlocks && now >= answer.checked_at)
|
||||
}
|
||||
|
||||
fn prompt(&self, typed: &str, now: Duration) -> Option<PasswordPrompt<'static>> {
|
||||
Some(PasswordPrompt {
|
||||
message: self.asking()?.asks?,
|
||||
hint: Some(DEMO_PASSPHRASE_HINT),
|
||||
input: passphrase_input::masked(typed),
|
||||
sent: self.is_checking(now),
|
||||
rejected: self.was_rejected(now),
|
||||
})
|
||||
}
|
||||
|
||||
fn answer(&mut self, submitted: &str, now: Duration) {
|
||||
let Some(step) = self.asking() else {
|
||||
return;
|
||||
};
|
||||
self.answer = Some(Answer {
|
||||
checked_at: now + step.work,
|
||||
unlocks: submitted == DEMO_PASSPHRASE,
|
||||
});
|
||||
}
|
||||
|
||||
fn is_ready(&self, job: &ScriptedJob) -> bool {
|
||||
!self.started.contains_key(job.step.unit)
|
||||
&& job
|
||||
.step
|
||||
.after
|
||||
.iter()
|
||||
.all(|dependency| self.finished.contains(dependency))
|
||||
}
|
||||
|
||||
fn is_done(&self) -> bool {
|
||||
self.finished.len() == self.jobs.len()
|
||||
}
|
||||
|
||||
fn is_due(&self, job: &ScriptedJob, now: Duration) -> bool {
|
||||
let done_at = match job.step.asks {
|
||||
Some(_) => self
|
||||
.answer
|
||||
.filter(|answer| answer.unlocks)
|
||||
.map(|answer| answer.checked_at),
|
||||
None => self
|
||||
.started
|
||||
.get(job.step.unit)
|
||||
.map(|started| *started + job.step.work),
|
||||
};
|
||||
!self.finished.contains(job.step.unit) && done_at.is_some_and(|done_at| now >= done_at)
|
||||
}
|
||||
|
||||
fn advance(&mut self, now: Duration) -> Vec<BootChange> {
|
||||
let starting: HashSet<&'static str> = self
|
||||
.jobs
|
||||
.iter()
|
||||
.filter(|job| self.is_ready(job))
|
||||
.map(|job| job.step.unit)
|
||||
.collect();
|
||||
self.started
|
||||
.extend(starting.iter().map(|unit| (*unit, now)));
|
||||
let due: HashSet<&'static str> = self
|
||||
.jobs
|
||||
.iter()
|
||||
.filter(|job| self.is_due(job, now))
|
||||
.map(|job| job.step.unit)
|
||||
.collect();
|
||||
let changes = self
|
||||
.jobs
|
||||
.iter()
|
||||
.filter(|job| starting.contains(job.step.unit))
|
||||
.map(|job| BootChange::UpdateActivity {
|
||||
unit: job.step.unit.to_owned(),
|
||||
activity: job.started_activity(now),
|
||||
})
|
||||
.chain(
|
||||
self.jobs
|
||||
.iter()
|
||||
.filter(|job| due.contains(job.step.unit))
|
||||
.flat_map(|job| {
|
||||
[
|
||||
BootChange::UpdateActivity {
|
||||
unit: job.step.unit.to_owned(),
|
||||
activity: job.settled_activity(now),
|
||||
},
|
||||
BootChange::FinishJob {
|
||||
id: job.id,
|
||||
result: job.outcome(),
|
||||
at: now,
|
||||
},
|
||||
]
|
||||
.into_iter()
|
||||
.chain(job.explanation())
|
||||
}),
|
||||
)
|
||||
.collect();
|
||||
self.finished.extend(due);
|
||||
changes
|
||||
}
|
||||
}
|
||||
|
||||
struct DemoDesk {
|
||||
script: Script,
|
||||
describe: fn(&str) -> Option<&'static str>,
|
||||
next_stage: &'static [Step],
|
||||
settled_at: Option<Duration>,
|
||||
typed: Zeroizing<String>,
|
||||
}
|
||||
|
||||
impl DemoDesk {
|
||||
fn enter_next_stage(&mut self, now: Duration) -> Vec<BootChange> {
|
||||
if !self.script.is_done() || self.next_stage.is_empty() {
|
||||
return Vec::new();
|
||||
}
|
||||
self.script = Script::begin(mem::take(&mut self.next_stage), 1000);
|
||||
once(BootChange::SwitchRoot { at: now })
|
||||
.chain(self.script.opening_changes(self.describe, now))
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
impl ConsoleDesk for DemoDesk {
|
||||
fn frame_passed(&mut self, now: Duration) -> ControlFlow<WatchEnding, Vec<BootChange>> {
|
||||
let changes: Vec<BootChange> = self
|
||||
.script
|
||||
.advance(now)
|
||||
.into_iter()
|
||||
.chain(self.enter_next_stage(now))
|
||||
.collect();
|
||||
if !self.script.is_done() {
|
||||
return ControlFlow::Continue(changes);
|
||||
}
|
||||
let settled_at = *self.settled_at.get_or_insert(now);
|
||||
if now.saturating_sub(settled_at) >= FINAL_FRAME {
|
||||
ControlFlow::Break(WatchEnding::BootCompleted)
|
||||
} else {
|
||||
ControlFlow::Continue(changes)
|
||||
}
|
||||
}
|
||||
|
||||
fn prompt(&self, now: Duration) -> Option<PasswordPrompt<'_>> {
|
||||
self.script.prompt(&self.typed, now)
|
||||
}
|
||||
|
||||
fn press_key(&mut self, event: &Event, now: Duration) -> ControlFlow<WatchEnding> {
|
||||
let asking = self.script.asking().is_some();
|
||||
if passphrase_input::asks_to_quit(event, asking) {
|
||||
return ControlFlow::Break(WatchEnding::ViewerLeft);
|
||||
}
|
||||
if asking
|
||||
&& !self.script.is_checking(now)
|
||||
&& let Some(submitted) = passphrase_input::type_key(&mut self.typed, event)
|
||||
{
|
||||
self.script.answer(&submitted, now);
|
||||
}
|
||||
ControlFlow::Continue(())
|
||||
}
|
||||
}
|
||||
|
||||
fn demo_origin() -> BootOrigin {
|
||||
BootOrigin {
|
||||
host: "demo".to_owned(),
|
||||
system: Some("NixOS 26.11.20261007.39ad350".to_owned()),
|
||||
generation: Some("42".to_owned()),
|
||||
kernel: "Linux 7.2.9".to_owned(),
|
||||
}
|
||||
}
|
||||
|
||||
async fn play_scenario(terminal: &mut DefaultTerminal, scenario: &Scenario) -> io::Result<()> {
|
||||
let script = Script::begin(scenario.steps, 1);
|
||||
let mut state = BootState::new(scenario.phase);
|
||||
script
|
||||
.opening_changes(scenario.describe, Duration::ZERO)
|
||||
.into_iter()
|
||||
.for_each(|change| state.apply(change));
|
||||
let desk = DemoDesk {
|
||||
script,
|
||||
describe: scenario.describe,
|
||||
next_stage: scenario.after_switch_root,
|
||||
settled_at: None,
|
||||
typed: passphrase_input::empty(),
|
||||
};
|
||||
let mut screen = WatchScreen::new(
|
||||
state,
|
||||
desk,
|
||||
demo_origin,
|
||||
Colors::default(),
|
||||
Timing::default(),
|
||||
monotonic_now(),
|
||||
);
|
||||
let inputs = stream::select(frame_inputs(), key_inputs()?);
|
||||
match watch_until_ending(&mut screen, terminal, inputs).await {
|
||||
WatchEnding::Failed(error) => Err(io::Error::other(error)),
|
||||
WatchEnding::BootCompleted | WatchEnding::ViewerLeft => Ok(()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn play(terminal: &mut DefaultTerminal, scenario: &Scenario) -> io::Result<()> {
|
||||
Builder::new_current_thread()
|
||||
.enable_io()
|
||||
.enable_time()
|
||||
.build()?
|
||||
.block_on(play_scenario(terminal, scenario))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
const KEY_DERIVATION: Duration = Duration::from_millis(500);
|
||||
const UNLOCK_ONLY: &[Step] = &[unlocking(
|
||||
"systemd-cryptsetup@root.service",
|
||||
&[],
|
||||
"Please enter passphrase for disk root:",
|
||||
KEY_DERIVATION,
|
||||
)];
|
||||
|
||||
fn asking_demo() -> Script {
|
||||
let mut script = Script::begin(UNLOCK_ONLY, 1);
|
||||
script.advance(Duration::ZERO);
|
||||
script
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_hint_names_the_demo_passphrase() {
|
||||
assert!(DEMO_PASSPHRASE_HINT.contains(&format!("\"{DEMO_PASSPHRASE}\"")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_wrong_answer_is_checked_then_called_out() {
|
||||
let mut script = asking_demo();
|
||||
let asked = script.prompt("", Duration::ZERO).expect("asking");
|
||||
assert_eq!(asked.hint, Some(DEMO_PASSPHRASE_HINT));
|
||||
assert!(!asked.rejected);
|
||||
script.answer("wrong", Duration::ZERO);
|
||||
let checking = script.prompt("", KEY_DERIVATION / 2).expect("asking");
|
||||
assert!(checking.sent && !checking.rejected);
|
||||
let rejected = script.prompt("", KEY_DERIVATION).expect("asking again");
|
||||
assert!(rejected.rejected && !rejected.sent);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_right_answer_unlocks_and_closes_the_prompt() {
|
||||
let mut script = asking_demo();
|
||||
script.answer(DEMO_PASSPHRASE, Duration::ZERO);
|
||||
script.advance(KEY_DERIVATION);
|
||||
assert!(script.is_done());
|
||||
assert!(script.prompt("", KEY_DERIVATION).is_none());
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
Output recordings/boot.gif
|
||||
|
||||
Require scripted-boot
|
||||
|
||||
Set Shell bash
|
||||
Set FontSize 22
|
||||
Set Width 1380
|
||||
Set Height 980
|
||||
Set Padding 16
|
||||
Set Theme "Monokai Vivid"
|
||||
Set TypingSpeed 0
|
||||
Set Framerate 10
|
||||
|
||||
Hide
|
||||
Type "clear && scripted-boot"
|
||||
Enter
|
||||
Show
|
||||
|
||||
Wait+Screen@60s /0 running\s+0 waiting/
|
||||
Sleep 2s
|
||||
Hide
|
||||
@@ -1,21 +0,0 @@
|
||||
Output recordings/shutdown.gif
|
||||
|
||||
Require scripted-shutdown
|
||||
|
||||
Set Shell bash
|
||||
Set FontSize 22
|
||||
Set Width 1380
|
||||
Set Height 980
|
||||
Set Padding 16
|
||||
Set Theme "Monokai Vivid"
|
||||
Set TypingSpeed 0
|
||||
Set Framerate 10
|
||||
|
||||
Hide
|
||||
Type "clear && scripted-shutdown"
|
||||
Enter
|
||||
Show
|
||||
|
||||
Wait+Screen@60s /0 running\s+0 waiting/
|
||||
Sleep 2s
|
||||
Hide
|
||||
|
After Width: | Height: | Size: 135 KiB |
|
After Width: | Height: | Size: 1012 KiB |
|
After Width: | Height: | Size: 215 KiB |
|
After Width: | Height: | Size: 163 KiB |
@@ -1,44 +0,0 @@
|
||||
{ lib, bootvineModule }:
|
||||
let
|
||||
machineModule = machineName: {
|
||||
imports = [
|
||||
bootvineModule
|
||||
./shared/common.nix
|
||||
./${machineName}/machine.nix
|
||||
];
|
||||
networking.hostName = "bootvine-${machineName}";
|
||||
};
|
||||
|
||||
machineDescriptions = {
|
||||
slow-services = "slow and failing units, a held initrd probe and a greetd login";
|
||||
text-console = "the slow units without a display manager, handing over at the default target";
|
||||
scripted-initrd = "the slow units with the scripted initrd, so bootvine starts in stage 2";
|
||||
encrypted-volume = "a LUKS volume unlocked in the initrd with the passphrase 'sample passphrase'";
|
||||
failures = "units that fail in every way systemd reports, each with journal messages";
|
||||
hibernate-resume = "a swap disk to hibernate to, showing the kernel's image loading progress on resume";
|
||||
};
|
||||
|
||||
machines = lib.mapAttrs (machineName: _: machineModule machineName) machineDescriptions;
|
||||
in
|
||||
{
|
||||
inherit machines machineDescriptions;
|
||||
|
||||
sampleUnits = import ./slow-services/sample-units.nix;
|
||||
|
||||
nixosSystemFor =
|
||||
system: machineName:
|
||||
lib.nixosSystem {
|
||||
inherit system;
|
||||
modules = [
|
||||
machines.${machineName}
|
||||
(import ./shared/interactive-vm.nix machineName)
|
||||
];
|
||||
};
|
||||
|
||||
checksFor =
|
||||
pkgs:
|
||||
lib.mapAttrs (
|
||||
machineName: machine:
|
||||
pkgs.testers.runNixOSTest (import ./${machineName}/check.nix { inherit machine pkgs; })
|
||||
) machines;
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
{ machine, pkgs }:
|
||||
let
|
||||
secretDisk = import ./secret-disk.nix { inherit pkgs; };
|
||||
in
|
||||
{
|
||||
name = "bootvine-encrypted-volume";
|
||||
nodes.machine = {
|
||||
imports = [
|
||||
machine
|
||||
../shared/recorded-display.nix
|
||||
];
|
||||
|
||||
testing.initrdBackdoor = true;
|
||||
|
||||
virtualisation.qemu.drives = [ secretDisk.qemuDrive ];
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
PASSPHRASE = "${secretDisk.passphrase}"
|
||||
''
|
||||
+ builtins.readFile ../shared/console.py
|
||||
+ builtins.readFile ../shared/screen_recording.py
|
||||
+ builtins.readFile ./check.py;
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
def answered_prompts():
|
||||
return bootvine_journal().count("answered a password prompt")
|
||||
|
||||
|
||||
def pending_prompt():
|
||||
listing = machine.succeed("ls /run/systemd/ask-password").split()
|
||||
return next((name for name in listing if name.startswith("ask.")), "")
|
||||
|
||||
|
||||
recording = ScreenRecording(machine)
|
||||
machine.start()
|
||||
recording.start()
|
||||
|
||||
retry(lambda _: pending_prompt() != "", timeout_seconds=60)
|
||||
wait_for_screen("passphrase")
|
||||
assert_text_visible(font_has_512_glyphs=True)
|
||||
first_prompt = pending_prompt()
|
||||
machine.send_chars("not the passphrase\n")
|
||||
retry(lambda _: answered_prompts() == 1, timeout_seconds=30)
|
||||
retry(lambda _: pending_prompt() not in ("", first_prompt), timeout_seconds=30)
|
||||
wait_for_screen("passphrase")
|
||||
assert_text_visible(font_has_512_glyphs=True)
|
||||
machine.send_chars(f"{PASSPHRASE}\n")
|
||||
machine.wait_for_unit("systemd-cryptsetup@secret.service")
|
||||
machine.switch_root()
|
||||
machine.wait_for_unit("multi-user.target")
|
||||
|
||||
machine.succeed("test -e /dev/mapper/secret")
|
||||
journal = bootvine_journal()
|
||||
print(journal)
|
||||
assert " in Initrd " in journal, "never ran in the initrd"
|
||||
assert journal.count("answered a password prompt") == 2, "did not answer both attempts itself"
|
||||
recording.stop()
|
||||
@@ -1,11 +0,0 @@
|
||||
{ lib, pkgs, ... }:
|
||||
let
|
||||
secretDisk = import ./secret-disk.nix { inherit pkgs; };
|
||||
in
|
||||
{
|
||||
boot.initrd.luks.devices = lib.mkVMOverride {
|
||||
secret.device = "/dev/disk/by-uuid/${secretDisk.uuid}";
|
||||
};
|
||||
|
||||
virtualisation.vmVariant.virtualisation.qemu.drives = [ secretDisk.qemuDrive ];
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
{ pkgs }:
|
||||
let
|
||||
passphrase = "sample passphrase";
|
||||
uuid = "9d1f2a8e-0b7c-4c55-9a8e-6b2f8f3c1d00";
|
||||
image = pkgs.runCommand "bootvine-luks-disk" { nativeBuildInputs = [ pkgs.cryptsetup ]; } ''
|
||||
truncate -s 32M disk.img
|
||||
echo -n '${passphrase}' | cryptsetup luksFormat -q --disable-locks --type luks2 \
|
||||
--pbkdf pbkdf2 --pbkdf-force-iterations 1000 --uuid ${uuid} disk.img -
|
||||
mv disk.img $out
|
||||
'';
|
||||
in
|
||||
{
|
||||
inherit passphrase uuid;
|
||||
qemuDrive = {
|
||||
name = "secret";
|
||||
file = "${image}";
|
||||
driveExtraOpts = {
|
||||
format = "raw";
|
||||
snapshot = "on";
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
{ machine, ... }:
|
||||
{
|
||||
name = "bootvine-failures";
|
||||
|
||||
nodes.machine =
|
||||
{ pkgs, ... }:
|
||||
let
|
||||
holdUntilReleased =
|
||||
marker: "${pkgs.bash}/bin/bash -c 'until [ -e /run/${marker} ]; do sleep 0.1; done'";
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
machine
|
||||
../shared/recorded-display.nix
|
||||
];
|
||||
bootvineSample.startFailuresByHand = true;
|
||||
testing.initrdBackdoor = true;
|
||||
|
||||
boot.initrd.systemd = {
|
||||
storePaths = [ "${pkgs.bash}/bin/bash" ];
|
||||
services.initrd-failures-hold = {
|
||||
description = "Initrd held for the check";
|
||||
wantedBy = [ "initrd.target" ];
|
||||
before = [ "initrd.target" ];
|
||||
unitConfig.DefaultDependencies = false;
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = holdUntilReleased "release-initrd-failures-hold";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services.boot-failures-hold = {
|
||||
description = "Boot held for the check";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = holdUntilReleased "release-boot-failures-hold";
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
testScript = builtins.readFile ../shared/console.py
|
||||
+ builtins.readFile ../shared/screen_recording.py + builtins.readFile ./check.py;
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
def start_failing_unit(unit):
|
||||
machine.succeed(f"systemctl start --no-block {unit}")
|
||||
|
||||
|
||||
def unit_result(unit):
|
||||
return machine.succeed(f"systemctl show -p Result --value {unit}").strip()
|
||||
|
||||
|
||||
def failure_panel():
|
||||
lines = screen().splitlines()
|
||||
start = next(index for index, line in enumerate(lines) if " Failures " in line)
|
||||
return "\n".join(lines[start:])
|
||||
|
||||
|
||||
recording = ScreenRecording(machine)
|
||||
machine.start()
|
||||
recording.start()
|
||||
|
||||
wait_for_screen("Initrd", "Initrd held for the check")
|
||||
start_failing_unit("initrd-nic-firmware-load")
|
||||
wait_for_screen("Failures", "initrd-nic-firmware-load exited with status 1", "rtl8168h-2.fw not found")
|
||||
assert_bootvine_in_front()
|
||||
assert_text_visible(font_has_512_glyphs=True)
|
||||
machine.succeed("touch /run/release-initrd-failures-hold")
|
||||
machine.switch_root()
|
||||
|
||||
wait_for_screen("Stage 2", "Boot held for the check")
|
||||
wait_for_screen("initrd-nic-firmware-load exited with status 1")
|
||||
|
||||
start_failing_unit("failure-report")
|
||||
wait_for_screen("app-config-check exited with status 2", "missing key 'listen'")
|
||||
retry(lambda _: unit_result("failure-report") != "", timeout_seconds=10)
|
||||
assert "× failure-report" not in failure_panel(), f"a dependency failure reached the panel:\n{screen()}"
|
||||
assert "failure-report" in screen(), f"the dependency failure left the tree:\n{screen()}"
|
||||
|
||||
start_failing_unit("worker-pool")
|
||||
wait_for_screen("worker-pool", "SIGSEGV", "starting worker pool with 4 threads")
|
||||
|
||||
start_failing_unit("license-server-wait")
|
||||
wait_for_screen("license-server-wait timed out", "waiting for license server at 10.0.0.9:27000")
|
||||
|
||||
start_failing_unit("metrics-agent")
|
||||
wait_for_screen("metrics-agent exited with status 203")
|
||||
|
||||
start_failing_unit("http-listener")
|
||||
wait_for_screen("http-listener restarted too often", "address already in use")
|
||||
|
||||
start_failing_unit("database-client")
|
||||
wait_for_screen("database-client exited with status 1: Cannot reach database", "connection refused")
|
||||
|
||||
start_failing_unit("upstream-uplink")
|
||||
wait_for_screen("upstream-uplink exited with status 1", "lost connection to upstream, giving up")
|
||||
|
||||
wait_for_screen("× 9 failed", "connection refused")
|
||||
assert "Started Upstream uplink" not in failure_panel(), f"systemd's own start line reached the panel:\n{screen()}"
|
||||
print(screen())
|
||||
|
||||
machine.succeed("touch /run/release-boot-failures-hold")
|
||||
retry(lambda _: "handing the console over" in bootvine_journal(), timeout_seconds=60)
|
||||
print(bootvine_journal())
|
||||
recording.stop()
|
||||
@@ -1,148 +0,0 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
startedByHand = config.bootvineSample.startFailuresByHand;
|
||||
wantedAtBoot = target: lib.optional (!startedByHand) target;
|
||||
|
||||
failingService =
|
||||
{
|
||||
description,
|
||||
script,
|
||||
serviceConfig ? { },
|
||||
unitConfig ? { },
|
||||
extraAttributes ? { },
|
||||
}:
|
||||
{
|
||||
inherit description unitConfig;
|
||||
wantedBy = wantedAtBoot "multi-user.target";
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = pkgs.writeShellScript "failing-service" script;
|
||||
}
|
||||
// serviceConfig;
|
||||
}
|
||||
// extraAttributes;
|
||||
|
||||
initrdFirmwareScript = pkgs.writeShellScript "initrd-nic-firmware-load" ''
|
||||
echo "loading firmware for enp1s0 (r8169)"
|
||||
echo "firmware: rtl_nic/rtl8168h-2.fw not found" >&2
|
||||
exit 1
|
||||
'';
|
||||
in
|
||||
{
|
||||
options.bootvineSample.startFailuresByHand = lib.mkEnableOption ''
|
||||
leaving the failing sample units out of the boot targets, so a check can
|
||||
start them one at a time
|
||||
'';
|
||||
|
||||
config = {
|
||||
boot.initrd.systemd = {
|
||||
storePaths = [
|
||||
initrdFirmwareScript
|
||||
"${pkgs.bash}/bin/bash"
|
||||
];
|
||||
services.initrd-nic-firmware-load = {
|
||||
description = "Network card firmware";
|
||||
wantedBy = wantedAtBoot "initrd.target";
|
||||
before = [ "initrd.target" ];
|
||||
unitConfig.DefaultDependencies = false;
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = "${pkgs.bash}/bin/bash ${initrdFirmwareScript}";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services = {
|
||||
app-config-check = failingService {
|
||||
description = "Application configuration check";
|
||||
script = ''
|
||||
echo "reading /etc/app/app.toml"
|
||||
echo "config: /etc/app/app.toml: missing key 'listen'" >&2
|
||||
exit 2
|
||||
'';
|
||||
};
|
||||
|
||||
worker-pool = failingService {
|
||||
description = "Worker pool";
|
||||
script = ''
|
||||
echo "starting worker pool with 4 threads"
|
||||
kill -SEGV $$
|
||||
'';
|
||||
};
|
||||
|
||||
license-server-wait = failingService {
|
||||
description = "License server check";
|
||||
script = ''
|
||||
echo "waiting for license server at 10.0.0.9:27000"
|
||||
sleep infinity
|
||||
'';
|
||||
serviceConfig.TimeoutStartSec = 4;
|
||||
};
|
||||
|
||||
metrics-agent = {
|
||||
description = "Metrics agent";
|
||||
wantedBy = wantedAtBoot "multi-user.target";
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = "/usr/bin/metrics-agent --listen :9100";
|
||||
};
|
||||
};
|
||||
|
||||
http-listener = failingService {
|
||||
description = "HTTP listener";
|
||||
script = ''
|
||||
echo "bind 0.0.0.0:8080: address already in use" >&2
|
||||
exit 1
|
||||
'';
|
||||
serviceConfig = {
|
||||
Restart = "on-failure";
|
||||
RestartSec = "200ms";
|
||||
};
|
||||
unitConfig = {
|
||||
StartLimitBurst = 3;
|
||||
StartLimitIntervalSec = 30;
|
||||
};
|
||||
};
|
||||
|
||||
database-client = failingService {
|
||||
description = "Database client";
|
||||
script = ''
|
||||
systemd-notify --status="Cannot reach database at db.internal:5432"
|
||||
echo "connect db.internal:5432: connection refused" >&2
|
||||
exit 1
|
||||
'';
|
||||
serviceConfig = {
|
||||
Type = "notify";
|
||||
NotifyAccess = "all";
|
||||
};
|
||||
};
|
||||
|
||||
upstream-uplink = failingService {
|
||||
description = "Upstream uplink";
|
||||
script = ''
|
||||
echo "connected to upstream"
|
||||
sleep 3
|
||||
echo "lost connection to upstream, giving up" >&2
|
||||
exit 1
|
||||
'';
|
||||
serviceConfig.Type = "simple";
|
||||
};
|
||||
|
||||
failure-report = failingService {
|
||||
description = "Failure report";
|
||||
script = ''
|
||||
echo "all checks passed"
|
||||
'';
|
||||
extraAttributes = {
|
||||
requires = [ "app-config-check.service" ];
|
||||
after = [ "app-config-check.service" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
{ machine, pkgs, ... }:
|
||||
{
|
||||
name = "bootvine-hibernate-resume";
|
||||
|
||||
nodes.machine =
|
||||
{ lib, ... }:
|
||||
{
|
||||
imports = [
|
||||
machine
|
||||
(pkgs.path + "/nixos/tests/common/auto-format-root-device.nix")
|
||||
];
|
||||
|
||||
boot.resumeDevice = "/dev/vdc";
|
||||
swapDevices = lib.mkOverride 0 [
|
||||
{
|
||||
device = "/dev/vdc";
|
||||
options = [ "x-systemd.makefs" ];
|
||||
}
|
||||
];
|
||||
|
||||
powerManagement = {
|
||||
powerDownCommands = "systemctl --no-block stop backdoor.service";
|
||||
resumeCommands = "systemctl --no-block restart backdoor.service";
|
||||
};
|
||||
|
||||
virtualisation = {
|
||||
memorySize = 2048;
|
||||
qemu.options = [
|
||||
"-vga none"
|
||||
"-device VGA,xres=1280,yres=800"
|
||||
"-chardev socket,id=recording-monitor,path=recording-monitor,server=on,wait=off"
|
||||
"-mon chardev=recording-monitor,mode=readline"
|
||||
];
|
||||
emptyDiskImages = [ 4096 ];
|
||||
useNixStoreImage = true;
|
||||
useEFIBoot = true;
|
||||
};
|
||||
};
|
||||
|
||||
testScript =
|
||||
builtins.readFile ../shared/console.py
|
||||
+ builtins.readFile ../shared/screen_recording.py
|
||||
+ builtins.readFile ./check.py;
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
RESUME_MARKER = "/run/bootvine/resume-console-open"
|
||||
BOOT_CONSOLE_LEVEL = "3"
|
||||
SENTINEL_TEXT = "held only in memory"
|
||||
|
||||
|
||||
def console_level():
|
||||
return machine.succeed("cut -f1 /proc/sys/kernel/printk").strip()
|
||||
|
||||
|
||||
def assert_console_returned():
|
||||
machine.wait_until_fails("systemctl is-active bootvine")
|
||||
machine.fail(f"test -e {RESUME_MARKER}")
|
||||
assert console_level() == BOOT_CONSOLE_LEVEL, f"kernel console level was not restored: {console_level()}"
|
||||
|
||||
|
||||
machine.start()
|
||||
|
||||
machine.wait_for_unit("default.target")
|
||||
assert_console_returned()
|
||||
machine.succeed("swapon --show=NAME --noheadings | grep -q .")
|
||||
machine.succeed(
|
||||
"mkdir /run/test",
|
||||
"mount -t ramfs ramfs /run/test",
|
||||
f"echo '{SENTINEL_TEXT}' > /run/test/sentinel",
|
||||
"dd if=/dev/urandom of=/run/test/ballast bs=1M count=500",
|
||||
)
|
||||
|
||||
machine.execute("systemctl hibernate >&2 &", check_return=False)
|
||||
machine.wait_for_shutdown()
|
||||
|
||||
resume_recording = ScreenRecording(machine)
|
||||
resume_recording.frame_seconds = 0.1
|
||||
machine.start()
|
||||
resume_recording.start()
|
||||
machine.wait_for_console_text("Image loading progress")
|
||||
machine.wait_for_console_text("Image loading done")
|
||||
machine.succeed(f"grep '{SENTINEL_TEXT}' /run/test/sentinel")
|
||||
assert console_level() == BOOT_CONSOLE_LEVEL, f"the restored system kept the opened level: {console_level()}"
|
||||
assert foreground_terminal() != f"tty{BOOTVINE_TERMINAL}", "the restored system came back on bootvine's terminal"
|
||||
machine.fail("systemctl is-active bootvine")
|
||||
machine.sleep(1)
|
||||
resume_recording.stop()
|
||||
|
||||
machine.crash()
|
||||
machine.start()
|
||||
machine.wait_for_unit("default.target")
|
||||
machine.fail("test -e /run/test/sentinel")
|
||||
assert_console_returned()
|
||||
journal = bootvine_journal()
|
||||
print(journal)
|
||||
assert " in Initrd " in journal, "bootvine did not run in the initrd of the boot without an image"
|
||||
machine.succeed('test "$(systemctl show -p Result --value bootvine)" = success')
|
||||
@@ -1,21 +0,0 @@
|
||||
{ lib, ... }:
|
||||
{
|
||||
boot.initrd.availableKernelModules = [ "bochs" ];
|
||||
|
||||
virtualisation.vmVariant = {
|
||||
boot.resumeDevice = "/dev/vdb";
|
||||
swapDevices = lib.mkOverride 0 [
|
||||
{
|
||||
device = "/dev/vdb";
|
||||
options = [ "x-systemd.makefs" ];
|
||||
}
|
||||
];
|
||||
virtualisation = {
|
||||
emptyDiskImages = [ 4096 ];
|
||||
qemu.options = lib.mkForce [
|
||||
"-vga none"
|
||||
"-device VGA,xres=1920,yres=1080"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
{ machine, ... }:
|
||||
{
|
||||
name = "bootvine-scripted-initrd";
|
||||
|
||||
nodes.machine =
|
||||
{ lib, ... }:
|
||||
let
|
||||
waitFor = flag: "/bin/sh -c 'until [ -e /run/${flag} ]; do sleep 0.1; done'";
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
machine
|
||||
../shared/recorded-display.nix
|
||||
];
|
||||
systemd.services = {
|
||||
sample-database.serviceConfig.ExecStop = lib.mkForce (waitFor "release-sample-database");
|
||||
backdoor.before = [ "sample-database.service" ];
|
||||
};
|
||||
};
|
||||
|
||||
testScript =
|
||||
builtins.readFile ../shared/console.py
|
||||
+ builtins.readFile ../shared/screen_recording.py
|
||||
+ builtins.readFile ./check.py;
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
def unit_state(unit):
|
||||
return machine.succeed(f"systemctl is-active {unit} || true").strip()
|
||||
|
||||
|
||||
recording = ScreenRecording(machine)
|
||||
machine.start()
|
||||
recording.start()
|
||||
|
||||
wait_for_screen("Stage 2", "sample-database")
|
||||
assert_bootvine_in_front()
|
||||
assert_text_visible(font_has_512_glyphs=True)
|
||||
|
||||
machine.wait_for_unit("greetd.service")
|
||||
retry(lambda _: unit_state("bootvine") == "inactive", timeout_seconds=60)
|
||||
journal = bootvine_journal()
|
||||
print(journal)
|
||||
watched = [line for line in journal.splitlines() if line.startswith("bootvine: watching")]
|
||||
assert watched, "bootvine never started"
|
||||
assert not any(" in Initrd " in line for line in watched), "bootvine ran in a scripted initrd"
|
||||
assert "handing the console over" in journal, "never handed the console over"
|
||||
|
||||
machine.succeed("systemctl poweroff --no-block")
|
||||
retry(lambda _: unit_state("sample-database") == "deactivating", timeout_seconds=60)
|
||||
wait_for_screen("Shutdown", "sample-database")
|
||||
assert_bootvine_in_front()
|
||||
machine.succeed("touch /run/release-sample-database")
|
||||
machine.wait_for_shutdown()
|
||||
recording.stop()
|
||||
@@ -1,6 +0,0 @@
|
||||
{ lib, ... }:
|
||||
{
|
||||
imports = [ ../slow-services/machine.nix ];
|
||||
|
||||
boot.initrd.systemd.enable = lib.mkForce false;
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
{ lib, pkgs, ... }:
|
||||
{
|
||||
system.stateVersion = "26.05";
|
||||
|
||||
boot.consoleLogLevel = lib.mkForce 3;
|
||||
|
||||
services.bootvine = {
|
||||
enable = true;
|
||||
settings.colors = {
|
||||
tree.current-stage = "light-yellow";
|
||||
tree.running-marker = "light-yellow";
|
||||
timeline.running = "light-yellow";
|
||||
footer.running = "light-yellow";
|
||||
password.frame = "light-yellow";
|
||||
};
|
||||
};
|
||||
|
||||
console = {
|
||||
colors = [
|
||||
"1d2021"
|
||||
"fb4934"
|
||||
"b8bb26"
|
||||
"fabd2f"
|
||||
"83a598"
|
||||
"d3869b"
|
||||
"8ec07c"
|
||||
"d5c4a1"
|
||||
"665c54"
|
||||
"fb4934"
|
||||
"b8bb26"
|
||||
"fabd2f"
|
||||
"83a598"
|
||||
"d3869b"
|
||||
"8ec07c"
|
||||
"fbf1c7"
|
||||
];
|
||||
earlySetup = true;
|
||||
font = "${pkgs.terminus_font}/share/consolefonts/ter-v20n.psf.gz";
|
||||
};
|
||||
|
||||
users.users.sample-user = {
|
||||
isNormalUser = true;
|
||||
password = "sample-user";
|
||||
};
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
import base64
|
||||
|
||||
BOOTVINE_TERMINAL = 12
|
||||
|
||||
|
||||
def read_terminal():
|
||||
attributed, characters = machine.succeed(
|
||||
f"base64 -w0 /dev/vcsa{BOOTVINE_TERMINAL}; echo; "
|
||||
f"base64 -w0 /dev/vcsu{BOOTVINE_TERMINAL}"
|
||||
).split()
|
||||
attributed = base64.b64decode(attributed)
|
||||
columns = attributed[1]
|
||||
attributes = attributed[5::2]
|
||||
text = base64.b64decode(characters).decode("utf-32-le")
|
||||
return columns, text, attributes
|
||||
|
||||
|
||||
def as_rows(text, columns):
|
||||
return "\n".join(text[start : start + columns] for start in range(0, len(text), columns))
|
||||
|
||||
|
||||
def screen():
|
||||
columns, text, _ = read_terminal()
|
||||
return as_rows(text, columns)
|
||||
|
||||
|
||||
def colours(attribute, font_has_512_glyphs):
|
||||
if font_has_512_glyphs:
|
||||
return (attribute >> 1) & 0x0F, (attribute >> 5) & 0x07
|
||||
return attribute & 0x0F, (attribute >> 4) & 0x07
|
||||
|
||||
|
||||
def assert_text_visible(font_has_512_glyphs=False):
|
||||
columns, text, attributes = read_terminal()
|
||||
|
||||
def is_hidden(character, attribute):
|
||||
foreground, background = colours(attribute, font_has_512_glyphs)
|
||||
return character != " " and foreground == background
|
||||
|
||||
hidden = "".join(
|
||||
"#" if is_hidden(character, attribute) else " "
|
||||
for character, attribute in zip(text, attributes)
|
||||
)
|
||||
assert "#" not in hidden, (
|
||||
f"text drawn in its background colour, marked #:\n{as_rows(hidden, columns)}\n{as_rows(text, columns)}"
|
||||
)
|
||||
|
||||
|
||||
def wait_for_screen(*fragments):
|
||||
def shows_all(last_try):
|
||||
text = screen()
|
||||
if last_try:
|
||||
print(text)
|
||||
print(bootvine_journal())
|
||||
return all(fragment in text for fragment in fragments)
|
||||
|
||||
retry(shows_all, timeout_seconds=60)
|
||||
|
||||
|
||||
def foreground_terminal():
|
||||
return machine.succeed("cat /sys/class/tty/tty0/active").strip()
|
||||
|
||||
|
||||
def assert_bootvine_in_front():
|
||||
active = foreground_terminal()
|
||||
assert active == f"tty{BOOTVINE_TERMINAL}", f"bootvine is not in front: {active}"
|
||||
|
||||
|
||||
def bootvine_journal():
|
||||
return machine.succeed("journalctl -b -u bootvine -o cat")
|
||||
@@ -1,20 +0,0 @@
|
||||
machineName: {
|
||||
boot.loader.grub.enable = false;
|
||||
|
||||
services.getty.autologinUser = "root";
|
||||
fileSystems."/" = {
|
||||
device = "/dev/disk/by-label/nixos";
|
||||
fsType = "ext4";
|
||||
};
|
||||
|
||||
virtualisation.vmVariant.virtualisation = {
|
||||
memorySize = 2048;
|
||||
cores = 2;
|
||||
graphics = true;
|
||||
diskImage = "\${XDG_CACHE_HOME:-$HOME/.cache}/bootvine-${machineName}.qcow2";
|
||||
qemu.options = [
|
||||
"-vga none"
|
||||
"-device virtio-vga,xres=1920,yres=1080"
|
||||
];
|
||||
};
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
{
|
||||
virtualisation = {
|
||||
memorySize = 2048;
|
||||
qemu.options = [
|
||||
"-vga none"
|
||||
"-device virtio-vga,xres=1280,yres=800"
|
||||
"-chardev socket,id=recording-monitor,path=recording-monitor,server=on,wait=off"
|
||||
"-mon chardev=recording-monitor,mode=readline"
|
||||
];
|
||||
};
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
import os
|
||||
import socket
|
||||
import subprocess
|
||||
import threading
|
||||
import time
|
||||
|
||||
RECORDING_FRAME_SECONDS = 0.5
|
||||
RECORDING_CONNECT_SECONDS = 30
|
||||
QEMU_PROMPT = b"(qemu) "
|
||||
|
||||
|
||||
class ScreenRecording:
|
||||
def __init__(self, recorded_machine):
|
||||
self.recorded_machine = recorded_machine
|
||||
self.frames_directory = os.path.join(recorded_machine.out_dir, "recording")
|
||||
self.raw_frame = os.path.join(recorded_machine.state_dir, "recording-frame.ppm")
|
||||
self.frame_seconds = RECORDING_FRAME_SECONDS
|
||||
self.stopping = threading.Event()
|
||||
self.thread = threading.Thread(target=self.record_frames, daemon=True)
|
||||
|
||||
def start(self):
|
||||
os.makedirs(self.frames_directory, exist_ok=True)
|
||||
self.thread.start()
|
||||
|
||||
def stop(self):
|
||||
self.stopping.set()
|
||||
self.thread.join()
|
||||
|
||||
def connect_monitor(self):
|
||||
monitor_path = os.path.join(self.recorded_machine.state_dir, "recording-monitor")
|
||||
deadline = time.monotonic() + RECORDING_CONNECT_SECONDS
|
||||
while time.monotonic() < deadline and not self.stopping.is_set():
|
||||
monitor = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||
try:
|
||||
monitor.connect(monitor_path)
|
||||
return monitor
|
||||
except OSError:
|
||||
monitor.close()
|
||||
time.sleep(0.1)
|
||||
return None
|
||||
|
||||
def read_until_prompt(self, monitor):
|
||||
received = b""
|
||||
while not received.endswith(QEMU_PROMPT):
|
||||
chunk = monitor.recv(4096)
|
||||
if not chunk:
|
||||
raise ConnectionError("the recording monitor closed")
|
||||
received += chunk
|
||||
|
||||
def save_frame(self, monitor, frame_number):
|
||||
monitor.sendall(f"screendump {self.raw_frame}\n".encode())
|
||||
self.read_until_prompt(monitor)
|
||||
frame_path = os.path.join(self.frames_directory, f"frame-{frame_number:05d}.png")
|
||||
unfinished_path = f"{frame_path}.unfinished"
|
||||
subprocess.run(f"pnmtopng '{self.raw_frame}' > '{unfinished_path}'", shell=True, check=True)
|
||||
os.replace(unfinished_path, frame_path)
|
||||
|
||||
def record_frames(self):
|
||||
monitor = self.connect_monitor()
|
||||
if monitor is None:
|
||||
return
|
||||
try:
|
||||
self.read_until_prompt(monitor)
|
||||
frame_number = 0
|
||||
while not self.stopping.is_set():
|
||||
self.save_frame(monitor, frame_number)
|
||||
frame_number += 1
|
||||
self.stopping.wait(self.frame_seconds)
|
||||
except (OSError, ConnectionError, subprocess.CalledProcessError):
|
||||
pass
|
||||
finally:
|
||||
monitor.close()
|
||||
for leftover in os.listdir(self.frames_directory):
|
||||
if leftover.endswith(".unfinished"):
|
||||
os.remove(os.path.join(self.frames_directory, leftover))
|
||||
@@ -1,36 +0,0 @@
|
||||
{ machine, ... }:
|
||||
{
|
||||
name = "bootvine-slow-services";
|
||||
|
||||
nodes.machine =
|
||||
{ lib, ... }:
|
||||
let
|
||||
waitFor = flag: "/bin/sh -c 'until [ -e /run/${flag} ]; do sleep 0.1; done'";
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
machine
|
||||
../shared/recorded-display.nix
|
||||
];
|
||||
testing.initrdBackdoor = true;
|
||||
boot.initrd.systemd.services.initrd-hardware-probe.serviceConfig.ExecStart = lib.mkForce (
|
||||
waitFor "release-initrd-hardware-probe"
|
||||
);
|
||||
systemd = {
|
||||
settings.Manager.ShowStatus = lib.mkForce true;
|
||||
services.sample-database.serviceConfig.ExecStop = lib.mkForce (waitFor "release-sample-database");
|
||||
services.backdoor.before = [ "sample-database.service" ];
|
||||
services.late-sensor-probe = {
|
||||
wantedBy = [ "graphical.target" ];
|
||||
after = [ "greetd.service" ];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = waitFor "release-late-sensor-probe";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
testScript = builtins.readFile ../shared/console.py
|
||||
+ builtins.readFile ../shared/screen_recording.py + builtins.readFile ./check.py;
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
def console_level():
|
||||
return machine.succeed("cut -f1 /proc/sys/kernel/printk").strip()
|
||||
|
||||
|
||||
def unit_state(unit):
|
||||
return machine.succeed(f"systemctl is-active {unit} || true").strip()
|
||||
|
||||
|
||||
recording = ScreenRecording(machine)
|
||||
machine.start()
|
||||
recording.start()
|
||||
|
||||
wait_for_screen("Initrd", "Slow hardware probe")
|
||||
assert_bootvine_in_front()
|
||||
assert_text_visible(font_has_512_glyphs=True)
|
||||
assert console_level() == "1", f"the kernel console was not quieted: {console_level()}"
|
||||
machine.succeed("touch /run/release-initrd-hardware-probe")
|
||||
machine.switch_root()
|
||||
|
||||
retry(lambda _: unit_state("sample-database") == "activating", timeout_seconds=60)
|
||||
wait_for_screen("Stage 2", "sample-database")
|
||||
assert_bootvine_in_front()
|
||||
assert_text_visible(font_has_512_glyphs=True)
|
||||
assert console_level() == "1", f"stage 2 sysctl reopened the kernel console: {console_level()}"
|
||||
|
||||
machine.wait_for_unit("greetd.service")
|
||||
retry(lambda _: unit_state("bootvine") == "inactive", timeout_seconds=60)
|
||||
assert unit_state("late-sensor-probe") == "activating", "the boot finished before the display manager took over"
|
||||
assert foreground_terminal() != f"tty{BOOTVINE_TERMINAL}", "bootvine took the console back from the display manager"
|
||||
machine.succeed("touch /run/release-late-sensor-probe")
|
||||
machine.wait_for_unit("graphical.target")
|
||||
|
||||
journal = bootvine_journal()
|
||||
print(journal)
|
||||
watched = [line for line in journal.splitlines() if line.startswith("bootvine: watching")]
|
||||
assert any(" in Initrd " in line for line in watched), "never ran in the initrd"
|
||||
assert any(" in Stage 2 " in line for line in watched), "never reconnected after the root switch"
|
||||
pids = {line.split(" as pid ")[1].split()[0] for line in watched}
|
||||
assert len(pids) == 1, f"the initrd process did not survive the root switch: {pids}"
|
||||
assert "handing the console over" in journal, "never handed the console over"
|
||||
|
||||
machine.succeed('test "$(systemctl show -p Result --value bootvine)" = success')
|
||||
assert console_level() != "1", f"kernel console level was not restored: {console_level()}"
|
||||
show_status = machine.succeed("systemctl show -p ShowStatus --value").strip()
|
||||
assert show_status == "yes", f"systemd status output was not restored: {show_status}"
|
||||
|
||||
foreground = foreground_terminal()
|
||||
assert foreground != f"tty{BOOTVINE_TERMINAL}", "bootvine kept the console after handing it over"
|
||||
machine.succeed("systemctl restart bootvine")
|
||||
retry(lambda _: unit_state("bootvine") == "inactive", timeout_seconds=10)
|
||||
assert "boot already finished" in bootvine_journal(), "a restart after boot did not stand down"
|
||||
assert foreground_terminal() == foreground, "a restart after boot took the console"
|
||||
|
||||
machine.succeed("systemctl poweroff --no-block")
|
||||
retry(lambda _: unit_state("sample-database") == "deactivating", timeout_seconds=60)
|
||||
wait_for_screen("Shutdown", "sample-database")
|
||||
assert_bootvine_in_front()
|
||||
assert_text_visible(font_has_512_glyphs=True)
|
||||
machine.succeed("touch /run/release-sample-database")
|
||||
machine.wait_for_shutdown()
|
||||
recording.stop()
|
||||
@@ -1,42 +0,0 @@
|
||||
{ lib, pkgs, ... }:
|
||||
let
|
||||
sampleUnits = import ./sample-units.nix;
|
||||
|
||||
sampleService = spec: {
|
||||
inherit (spec) description;
|
||||
after = map (dependency: "${dependency}.service") (spec.after or [ ]);
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = [
|
||||
"${pkgs.coreutils}/bin/sleep ${spec.seconds}"
|
||||
]
|
||||
++ lib.optional (spec.fails or false) "${pkgs.coreutils}/bin/false";
|
||||
}
|
||||
// lib.optionalAttrs (spec ? stopSeconds) {
|
||||
RemainAfterExit = true;
|
||||
ExecStop = "${pkgs.coreutils}/bin/sleep ${spec.stopSeconds}";
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
boot.initrd.systemd.services.initrd-hardware-probe = {
|
||||
description = "Slow hardware probe";
|
||||
wantedBy = [ "initrd.target" ];
|
||||
before = [ "initrd.target" ];
|
||||
unitConfig.DefaultDependencies = false;
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = "/bin/sleep ${sampleUnits.initrdProbeSeconds}";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services = lib.mapAttrs (_: sampleService) sampleUnits.services // {
|
||||
greetd.after = [ "multi-user.target" ];
|
||||
};
|
||||
|
||||
services.greetd = {
|
||||
enable = true;
|
||||
settings.default_session.command = "${pkgs.greetd}/bin/agreety --cmd ${pkgs.bashInteractive}/bin/bash";
|
||||
};
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
{
|
||||
sampleUnits,
|
||||
lib,
|
||||
coreutils,
|
||||
runCommand,
|
||||
writeText,
|
||||
}:
|
||||
let
|
||||
toUnitFile = lib.generators.toINI { listsAsDuplicateKeys = true; };
|
||||
|
||||
serviceFile =
|
||||
name: spec:
|
||||
writeText "${name}.service" (toUnitFile {
|
||||
Unit = {
|
||||
Description = spec.description;
|
||||
After = map (dependency: "${dependency}.service") (spec.after or [ ]);
|
||||
};
|
||||
Service = {
|
||||
Type = "oneshot";
|
||||
ExecStart = [
|
||||
"${coreutils}/bin/sleep ${spec.seconds}"
|
||||
]
|
||||
++ lib.optional (spec.fails or false) "${coreutils}/bin/false";
|
||||
}
|
||||
// lib.optionalAttrs (spec ? stopSeconds) {
|
||||
RemainAfterExit = true;
|
||||
ExecStop = "${coreutils}/bin/sleep ${spec.stopSeconds}";
|
||||
};
|
||||
});
|
||||
|
||||
serviceNames = map (name: "${name}.service") (lib.attrNames sampleUnits.services);
|
||||
|
||||
targetFile = writeText "${sampleUnits.target}.target" (toUnitFile {
|
||||
Unit = {
|
||||
Description = "bootvine demo services";
|
||||
Wants = serviceNames;
|
||||
After = serviceNames;
|
||||
};
|
||||
});
|
||||
unitFiles =
|
||||
lib.mapAttrsToList (name: spec: {
|
||||
name = "${name}.service";
|
||||
path = serviceFile name spec;
|
||||
}) sampleUnits.services
|
||||
++ [
|
||||
{
|
||||
name = "${sampleUnits.target}.target";
|
||||
path = targetFile;
|
||||
}
|
||||
];
|
||||
in
|
||||
runCommand "bootvine-sample-unit-files" { } (
|
||||
lib.concatMapStringsSep "\n" (unit: "install -Dm644 ${unit.path} $out/${unit.name}") unitFiles
|
||||
)
|
||||
@@ -1,52 +0,0 @@
|
||||
{
|
||||
target = "bootvine-sample-services";
|
||||
initrdProbeSeconds = "6";
|
||||
services = {
|
||||
scratch-disk-prepare = {
|
||||
description = "Scratch disk preparation";
|
||||
seconds = "2";
|
||||
stopSeconds = "2";
|
||||
};
|
||||
sample-database = {
|
||||
description = "Sample database";
|
||||
seconds = "3";
|
||||
stopSeconds = "3";
|
||||
after = [ "scratch-disk-prepare" ];
|
||||
};
|
||||
memory-cache = {
|
||||
description = "In-memory cache";
|
||||
seconds = "1.5";
|
||||
stopSeconds = "1";
|
||||
};
|
||||
web-frontend = {
|
||||
description = "Web frontend";
|
||||
seconds = "2";
|
||||
stopSeconds = "2";
|
||||
after = [
|
||||
"sample-database"
|
||||
"memory-cache"
|
||||
];
|
||||
};
|
||||
remote-content-sync = {
|
||||
description = "Remote content sync";
|
||||
seconds = "4";
|
||||
};
|
||||
flaky-health-check = {
|
||||
description = "Flaky health check";
|
||||
seconds = "1";
|
||||
fails = true;
|
||||
};
|
||||
slow-warm-up = {
|
||||
description = "Slow warm-up job";
|
||||
seconds = "8";
|
||||
};
|
||||
startup-report = {
|
||||
description = "Startup report";
|
||||
seconds = "1";
|
||||
after = [
|
||||
"web-frontend"
|
||||
"remote-content-sync"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
{ machine, ... }:
|
||||
{
|
||||
name = "bootvine-text-console";
|
||||
|
||||
nodes.machine =
|
||||
{ lib, ... }:
|
||||
let
|
||||
waitFor = flag: "/bin/sh -c 'until [ -e /run/${flag} ]; do sleep 0.1; done'";
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
machine
|
||||
../shared/recorded-display.nix
|
||||
];
|
||||
testing.initrdBackdoor = true;
|
||||
boot.initrd.systemd.services.initrd-hardware-probe.serviceConfig.ExecStart = lib.mkForce (
|
||||
waitFor "release-initrd-hardware-probe"
|
||||
);
|
||||
systemd.services = {
|
||||
sample-database.serviceConfig.ExecStop = lib.mkForce (waitFor "release-sample-database");
|
||||
backdoor.before = [ "sample-database.service" ];
|
||||
};
|
||||
};
|
||||
|
||||
testScript =
|
||||
builtins.readFile ../shared/console.py
|
||||
+ builtins.readFile ../shared/screen_recording.py
|
||||
+ builtins.readFile ./check.py;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
def unit_state(unit):
|
||||
return machine.succeed(f"systemctl is-active {unit} || true").strip()
|
||||
|
||||
|
||||
recording = ScreenRecording(machine)
|
||||
machine.start()
|
||||
recording.start()
|
||||
|
||||
wait_for_screen("Initrd", "Slow hardware probe")
|
||||
assert_bootvine_in_front()
|
||||
machine.succeed("touch /run/release-initrd-hardware-probe")
|
||||
machine.switch_root()
|
||||
|
||||
wait_for_screen("Stage 2", "slow-warm-up")
|
||||
assert_bootvine_in_front()
|
||||
assert_text_visible(font_has_512_glyphs=True)
|
||||
|
||||
retry(lambda _: unit_state("bootvine") == "inactive", timeout_seconds=60)
|
||||
journal = bootvine_journal()
|
||||
print(journal)
|
||||
assert "handing the console over" in journal, "never handed the console over"
|
||||
assert foreground_terminal() != f"tty{BOOTVINE_TERMINAL}", "bootvine kept the console without a display manager"
|
||||
machine.wait_until_tty_matches("1", "login: ")
|
||||
|
||||
machine.succeed("systemctl poweroff --no-block")
|
||||
retry(lambda _: unit_state("sample-database") == "deactivating", timeout_seconds=60)
|
||||
wait_for_screen("Shutdown", "sample-database")
|
||||
assert_bootvine_in_front()
|
||||
machine.succeed("touch /run/release-sample-database")
|
||||
machine.wait_for_shutdown()
|
||||
recording.stop()
|
||||
@@ -1,6 +0,0 @@
|
||||
{ lib, ... }:
|
||||
{
|
||||
imports = [ ../slow-services/machine.nix ];
|
||||
|
||||
services.greetd.enable = lib.mkForce false;
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
[package]
|
||||
edition = "2024"
|
||||
name = "xtask"
|
||||
version = "0.1.0"
|
||||
license = "GPL-3.0-or-later"
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.6.7", features = ["derive"] }
|
||||
thiserror = "2.0.12"
|
||||
xshell = "0.2.7"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
@@ -1,59 +0,0 @@
|
||||
mod publish_recordings;
|
||||
mod record_screencasts;
|
||||
mod sync_default_config;
|
||||
mod task_error;
|
||||
|
||||
use std::{path::PathBuf, process::ExitCode};
|
||||
|
||||
use clap::{Args, Parser, Subcommand};
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(about = "Repository tasks for bootvine")]
|
||||
struct RepoTasks {
|
||||
#[command(subcommand)]
|
||||
task: Task,
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
enum Task {
|
||||
#[command(
|
||||
about = "Record the screencasts with vhs and convert the passphrase and failures \
|
||||
screenshots to WebP in recordings/"
|
||||
)]
|
||||
RecordScreencasts(RecordScreencastsOptions),
|
||||
#[command(
|
||||
about = "Replace the recordings branch on origin with a single commit holding recordings/"
|
||||
)]
|
||||
PublishRecordings,
|
||||
#[command(
|
||||
about = "Rewrite the defaults block in docs/configuration.md from `bootvine defaults`"
|
||||
)]
|
||||
SyncDefaultConfig,
|
||||
}
|
||||
|
||||
#[derive(Args)]
|
||||
struct RecordScreencastsOptions {
|
||||
#[arg(
|
||||
long,
|
||||
help = "Directory with one entry per sample machine, each the output of its vm-<machine> \
|
||||
check"
|
||||
)]
|
||||
vm_check_outputs: PathBuf,
|
||||
}
|
||||
|
||||
fn main() -> ExitCode {
|
||||
let outcome = match RepoTasks::parse().task {
|
||||
Task::RecordScreencasts(options) => {
|
||||
record_screencasts::record_screencasts(&options.vm_check_outputs)
|
||||
}
|
||||
Task::PublishRecordings => publish_recordings::publish_recordings(),
|
||||
Task::SyncDefaultConfig => sync_default_config::sync_default_config(),
|
||||
};
|
||||
match outcome {
|
||||
Ok(()) => ExitCode::SUCCESS,
|
||||
Err(error) => {
|
||||
eprintln!("xtask: {error}");
|
||||
ExitCode::FAILURE
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
use std::path::Path;
|
||||
|
||||
use xshell::{Shell, cmd};
|
||||
|
||||
use crate::{record_screencasts::RECORDINGS_DIRECTORY, task_error::TaskError};
|
||||
|
||||
const RECORDINGS_BRANCH: &str = "refs/heads/recordings";
|
||||
|
||||
pub fn publish_recordings() -> Result<(), TaskError> {
|
||||
if !Path::new(RECORDINGS_DIRECTORY).is_dir() {
|
||||
return Err(TaskError::RecordingsMissing);
|
||||
}
|
||||
let shell = Shell::new()?;
|
||||
let git_directory = cmd!(shell, "git rev-parse --absolute-git-dir").read()?;
|
||||
let temporary_directory = shell.create_temp_dir()?;
|
||||
let _index_override = shell.push_env(
|
||||
"GIT_INDEX_FILE",
|
||||
temporary_directory.path().join("recordings-index"),
|
||||
);
|
||||
let _git_directory_override = shell.push_env("GIT_DIR", &git_directory);
|
||||
let _recordings_directory = shell.push_dir(RECORDINGS_DIRECTORY);
|
||||
cmd!(shell, "git --work-tree=. add --all --force .")
|
||||
.quiet()
|
||||
.run()?;
|
||||
let recordings_tree = cmd!(shell, "git write-tree").read()?;
|
||||
let recordings_commit = cmd!(
|
||||
shell,
|
||||
"git commit-tree {recordings_tree} -m 'chore: sample recordings [skip ci]'"
|
||||
)
|
||||
.read()?;
|
||||
let branch = RECORDINGS_BRANCH;
|
||||
cmd!(
|
||||
shell,
|
||||
"git push --force origin {recordings_commit}:{branch}"
|
||||
)
|
||||
.run()?;
|
||||
Ok(())
|
||||
}
|
||||
@@ -1,126 +0,0 @@
|
||||
use std::{
|
||||
fs::{self, File},
|
||||
io::Read,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
use xshell::{Shell, cmd};
|
||||
|
||||
use crate::task_error::TaskError;
|
||||
|
||||
const TAPES: [&str; 2] = [
|
||||
"scripted-demos/tapes/scripted-boot.tape",
|
||||
"scripted-demos/tapes/scripted-shutdown.tape",
|
||||
];
|
||||
const RECORDING_FRAME_MILLISECONDS: &str = "500";
|
||||
pub const RECORDINGS_DIRECTORY: &str = "recordings";
|
||||
|
||||
fn sorted_entries(directory: &Path) -> Result<Vec<PathBuf>, TaskError> {
|
||||
let read_failure = |source| TaskError::File {
|
||||
path: directory.to_path_buf(),
|
||||
source,
|
||||
};
|
||||
let mut entries = fs::read_dir(directory)
|
||||
.map_err(read_failure)?
|
||||
.map(|entry| entry.map(|entry| entry.path()))
|
||||
.collect::<Result<Vec<_>, _>>()
|
||||
.map_err(read_failure)?;
|
||||
entries.sort();
|
||||
Ok(entries)
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
struct FrameSize {
|
||||
width: u32,
|
||||
height: u32,
|
||||
}
|
||||
|
||||
fn png_frame_size(frame: &Path) -> Result<FrameSize, TaskError> {
|
||||
let mut header = [0_u8; 24];
|
||||
File::open(frame)
|
||||
.and_then(|mut file| file.read_exact(&mut header))
|
||||
.map_err(|source| TaskError::File {
|
||||
path: frame.to_path_buf(),
|
||||
source,
|
||||
})?;
|
||||
let big_endian = |offset: usize| {
|
||||
u32::from_be_bytes([
|
||||
header[offset],
|
||||
header[offset + 1],
|
||||
header[offset + 2],
|
||||
header[offset + 3],
|
||||
])
|
||||
};
|
||||
Ok(FrameSize {
|
||||
width: big_endian(16),
|
||||
height: big_endian(20),
|
||||
})
|
||||
}
|
||||
|
||||
fn frames_at_final_size(frames: Vec<PathBuf>) -> Result<Vec<PathBuf>, TaskError> {
|
||||
let Some(final_frame) = frames.last() else {
|
||||
return Ok(frames);
|
||||
};
|
||||
let final_size = png_frame_size(final_frame)?;
|
||||
let sizes = frames
|
||||
.iter()
|
||||
.map(|frame| png_frame_size(frame))
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
Ok(frames
|
||||
.into_iter()
|
||||
.zip(sizes)
|
||||
.filter(|(_, size)| *size == final_size)
|
||||
.map(|(frame, _)| frame)
|
||||
.collect())
|
||||
}
|
||||
|
||||
fn encode_machine_recording(
|
||||
shell: &Shell,
|
||||
check_output: &Path,
|
||||
recordings: &Path,
|
||||
) -> Result<(), TaskError> {
|
||||
let Some(machine_name) = check_output.file_name() else {
|
||||
return Ok(());
|
||||
};
|
||||
let frames = frames_at_final_size(
|
||||
sorted_entries(&check_output.join("recording"))?
|
||||
.into_iter()
|
||||
.filter(|frame| {
|
||||
frame
|
||||
.extension()
|
||||
.is_some_and(|extension| extension == "png")
|
||||
})
|
||||
.collect(),
|
||||
)?;
|
||||
if frames.is_empty() {
|
||||
return Err(TaskError::NoRecordingFrames(check_output.to_path_buf()));
|
||||
}
|
||||
let animation = recordings.join(machine_name).with_extension("webp");
|
||||
let frame_duration = RECORDING_FRAME_MILLISECONDS;
|
||||
cmd!(
|
||||
shell,
|
||||
"img2webp -loop 0 -min_size -mixed -d {frame_duration} {frames...} -o {animation}"
|
||||
)
|
||||
.quiet()
|
||||
.run()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn record_screencasts(vm_check_outputs: &Path) -> Result<(), TaskError> {
|
||||
if !TAPES.iter().all(|tape| Path::new(tape).is_file()) {
|
||||
return Err(TaskError::NotInRepositoryRoot);
|
||||
}
|
||||
let recordings = Path::new(RECORDINGS_DIRECTORY);
|
||||
fs::create_dir_all(recordings).map_err(|source| TaskError::File {
|
||||
path: recordings.to_path_buf(),
|
||||
source,
|
||||
})?;
|
||||
let shell = Shell::new()?;
|
||||
TAPES.iter().try_for_each(|tape| {
|
||||
let tape_path = Path::new(tape);
|
||||
cmd!(shell, "vhs {tape_path}").run()
|
||||
})?;
|
||||
sorted_entries(vm_check_outputs)?
|
||||
.iter()
|
||||
.try_for_each(|check_output| encode_machine_recording(&shell, check_output, recordings))
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
use std::{fs, path::Path};
|
||||
|
||||
use xshell::{Shell, cmd};
|
||||
|
||||
use crate::task_error::TaskError;
|
||||
|
||||
const CONFIGURATION_DOC: &str = "docs/configuration.md";
|
||||
const DEFAULTS_HEADING: &str = "## Defaults\n";
|
||||
const TOML_FENCE_OPEN: &str = "```toml\n";
|
||||
const FENCE_CLOSE: &str = "```\n";
|
||||
|
||||
pub fn sync_default_config() -> Result<(), TaskError> {
|
||||
let doc_path = Path::new(CONFIGURATION_DOC);
|
||||
let doc_file_error = |source| TaskError::File {
|
||||
path: doc_path.to_path_buf(),
|
||||
source,
|
||||
};
|
||||
let doc_text = fs::read_to_string(doc_path).map_err(doc_file_error)?;
|
||||
let shell = Shell::new()?;
|
||||
let printed_defaults =
|
||||
cmd!(shell, "cargo run --quiet --package bootvine -- defaults").read()?;
|
||||
let synced_text = replace_defaults_block(&doc_text, &printed_defaults)
|
||||
.ok_or(TaskError::DefaultsBlockMissing(CONFIGURATION_DOC))?;
|
||||
if synced_text != doc_text {
|
||||
fs::write(doc_path, synced_text).map_err(doc_file_error)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn replace_defaults_block(doc_text: &str, printed_defaults: &str) -> Option<String> {
|
||||
let section_start = doc_text.find(DEFAULTS_HEADING)?;
|
||||
let block_start =
|
||||
section_start + doc_text[section_start..].find(TOML_FENCE_OPEN)? + TOML_FENCE_OPEN.len();
|
||||
let block_end = block_start + doc_text[block_start..].find(FENCE_CLOSE)?;
|
||||
Some(format!(
|
||||
"{}{}\n{}",
|
||||
&doc_text[..block_start],
|
||||
printed_defaults.trim_end(),
|
||||
&doc_text[block_end..]
|
||||
))
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
use std::{io, path::PathBuf};
|
||||
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum TaskError {
|
||||
#[error(transparent)]
|
||||
Shell(#[from] xshell::Error),
|
||||
#[error("{}: {source}", path.display())]
|
||||
File { path: PathBuf, source: io::Error },
|
||||
#[error("{} has no recording frames", .0.display())]
|
||||
NoRecordingFrames(PathBuf),
|
||||
#[error("no VHS tapes here; run from the repository root")]
|
||||
NotInRepositoryRoot,
|
||||
#[error("no recordings/ directory here; run record-screencasts from the repository root first")]
|
||||
RecordingsMissing,
|
||||
#[error("{0} has no ```toml block under its Defaults heading")]
|
||||
DefaultsBlockMissing(&'static str),
|
||||
}
|
||||