refactor: group modules by data-flow stage behind a thin main

This commit is contained in:
Willem Vanhulle committed 2026-10-21 12:12:49 +02:00
1 parent f9cc94c633
commit 2191a27b82
38 files changed
+104 -88

No files matched your search

+1 -1
View File
@@ -2,7 +2,7 @@ use std::{io, time::Duration};
use bootvine::{ use bootvine::{
boot_model::Phase, boot_model::Phase,
scripted_boot::{Scenario, Step, failing, play, step}, demo_script::scripted_boot::{Scenario, Step, failing, play, step},
}; };
const INITRD: &[Step] = &[ const INITRD: &[Step] = &[
+1 -1
View File
@@ -2,7 +2,7 @@ use std::{io, time::Duration};
use bootvine::{ use bootvine::{
boot_model::Phase, boot_model::Phase,
scripted_boot::{Scenario, Step, play, step, unlocking}, demo_script::scripted_boot::{Scenario, Step, play, step, unlocking},
}; };
const ROOT_PARTITION: &str = const ROOT_PARTITION: &str =
+1 -1
View File
@@ -2,7 +2,7 @@ use std::{io, time::Duration};
use bootvine::{ use bootvine::{
boot_model::Phase, boot_model::Phase,
scripted_boot::{Scenario, Step, play, step, stopping}, demo_script::scripted_boot::{Scenario, Step, play, step, stopping},
}; };
const SHUTDOWN: &[Step] = &[ const SHUTDOWN: &[Step] = &[
+1
View File
@@ -1,3 +1,4 @@
pub mod boot_origin;
mod job_ingestion; mod job_ingestion;
mod reached_milestones; mod reached_milestones;
mod unit_facts; mod unit_facts;
File renamed without changes.
+1 -1
View File
@@ -258,7 +258,7 @@ mod tests {
use super::*; use super::*;
use crate::{ use crate::{
boot_model::RowStatus, boot_model::RowStatus,
boot_test_fixtures::{ demo_script::boot_test_fixtures::{
MS, activating, facts, nested_boot_sample as sample, queue_unit, queued_boot, waiting, MS, activating, facts, nested_boot_sample as sample, queue_unit, queued_boot, waiting,
waiting_rows, waiting_rows,
}, },
+3 -1
View File
@@ -92,7 +92,9 @@ mod tests {
use super::*; use super::*;
use crate::{ use crate::{
boot_model::{Activity, JobResult, Phase}, boot_model::{Activity, JobResult, Phase},
boot_test_fixtures::{MS, nested_boot_sample, queued_boot, waiting, waiting_rows}, demo_script::boot_test_fixtures::{
MS, nested_boot_sample, queued_boot, waiting, waiting_rows,
},
}; };
#[test] #[test]
+1 -1
View File
@@ -172,7 +172,7 @@ pub(super) fn summary(facts: &UnitFacts) -> String {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::boot_test_fixtures::{facts, waiting}; use crate::demo_script::boot_test_fixtures::{facts, waiting};
#[test] #[test]
fn kinds_with_a_tag_drop_their_suffix() { fn kinds_with_a_tag_drop_their_suffix() {
+1 -1
View File
@@ -241,7 +241,7 @@ impl BootState {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::boot_test_fixtures::{ use crate::demo_script::boot_test_fixtures::{
nested_boot_sample, queued_boot, tree_outline, waiting, waiting_rows, nested_boot_sample, queued_boot, tree_outline, waiting, waiting_rows,
}; };
+4 -5
View File
@@ -32,11 +32,10 @@ use self::{
unit_tree::UnitTree, unit_tree::UnitTree,
}; };
use crate::{ use crate::{
boot_model::{BootState, RowStatus, TreeRow, UnitKind, flatten_forest}, boot_model::{
boot_origin::BootOrigin, BootState, RowStatus, TreeRow, UnitKind, boot_origin::BootOrigin, flatten_forest,
color_scheme::Colors, },
config_file::Timing, screen_settings::{color_scheme::Colors, config_file::Timing, font_glyphs::Glyphs},
font_glyphs::Glyphs,
}; };
const DURATION_WIDTH: u16 = 8; const DURATION_WIDTH: u16 = 8;
+2 -2
View File
@@ -6,8 +6,8 @@ use super::{
}; };
use crate::{ use crate::{
boot_model::{BootState, JobResult, Phase}, boot_model::{BootState, JobResult, Phase},
boot_test_fixtures::{MS, queue_unit, queued_boot, running, waiting}, demo_script::boot_test_fixtures::{MS, queue_unit, queued_boot, running, waiting},
color_scheme::Colors, screen_settings::color_scheme::Colors,
}; };
const CRYPTSETUP_MESSAGE: &str = const CRYPTSETUP_MESSAGE: &str =
+1 -2
View File
@@ -16,8 +16,7 @@ use ratatui::{
use super::{fit_width, rule, unit_count}; use super::{fit_width, rule, unit_count};
use crate::{ use crate::{
boot_model::{FinishedRun, MilestoneRow}, boot_model::{FinishedRun, MilestoneRow},
color_scheme::TimelineColors, screen_settings::{color_scheme::TimelineColors, font_glyphs::Glyphs},
font_glyphs::Glyphs,
}; };
pub const LABEL_WIDTH: u16 = 28; pub const LABEL_WIDTH: u16 = 28;
+5 -4
View File
@@ -10,10 +10,11 @@ use ratatui::{
use super::{DURATION_WIDTH, ELAPSED}; use super::{DURATION_WIDTH, ELAPSED};
use crate::{ use crate::{
boot_model::Tally, boot_model::{Tally, boot_origin::BootOrigin},
boot_origin::BootOrigin, screen_settings::{
color_scheme::{FooterColors, HeaderColors, PasswordColors}, color_scheme::{FooterColors, HeaderColors, PasswordColors},
font_glyphs::Glyphs, font_glyphs::Glyphs,
},
}; };
pub const FOOTER_HEIGHT: u16 = 2; pub const FOOTER_HEIGHT: u16 = 2;
+3 -6
View File
@@ -4,12 +4,9 @@ use ratatui::{Terminal, backend::TestBackend, buffer::Buffer};
use super::{BootView, PasswordPrompt}; use super::{BootView, PasswordPrompt};
use crate::{ use crate::{
boot_model::{BootState, JobResult, Phase}, boot_model::{BootState, JobResult, Phase, boot_origin::BootOrigin},
boot_origin::BootOrigin, demo_script::boot_test_fixtures::{MS, queued_boot, running, waiting},
boot_test_fixtures::{MS, queued_boot, running, waiting}, screen_settings::{color_scheme::Colors, config_file::Timing, font_glyphs::Glyphs},
color_scheme::Colors,
config_file::Timing,
font_glyphs::Glyphs,
}; };
pub fn render(state: &BootState, now: Duration, width: u16, height: u16) -> Vec<String> { pub fn render(state: &BootState, now: Duration, width: u16, height: u16) -> Vec<String> {
+4 -1
View File
@@ -9,7 +9,10 @@ use ratatui::{
}; };
use super::{BRANCH, ELAPSED, LAST_BRANCH, unit_count}; use super::{BRANCH, ELAPSED, LAST_BRANCH, unit_count};
use crate::{boot_model::BootState, color_scheme::StageColors, font_glyphs::Glyphs}; use crate::{
boot_model::BootState,
screen_settings::{color_scheme::StageColors, font_glyphs::Glyphs},
};
const SHUTDOWN_SUCCESSOR: &str = "systemd-shutdown"; const SHUTDOWN_SUCCESSOR: &str = "systemd-shutdown";
const PHASE_WIDTH: usize = 9; const PHASE_WIDTH: usize = 9;
+1 -1
View File
@@ -94,7 +94,7 @@ mod tests {
use super::*; use super::*;
use crate::{ use crate::{
boot_model::{BootState, Phase}, boot_model::{BootState, Phase},
boot_test_fixtures::{ demo_script::boot_test_fixtures::{
activating, nested_boot_sample, queued_boot, running, tree_outline, waiting, activating, nested_boot_sample, queued_boot, running, tree_outline, waiting,
}, },
}; };
+1 -1
View File
@@ -5,7 +5,7 @@ use unicode_width::UnicodeWidthStr;
use super::screen_render_fixtures::{boot_in_progress, chain_boot, described_boot, render}; use super::screen_render_fixtures::{boot_in_progress, chain_boot, described_boot, render};
use crate::{ use crate::{
boot_model::{JobResult, Phase}, boot_model::{JobResult, Phase},
boot_test_fixtures::{MS, queue_unit, queued_boot, running, waiting}, demo_script::boot_test_fixtures::{MS, queue_unit, queued_boot, running, waiting},
}; };
#[test] #[test]
+1 -2
View File
@@ -12,8 +12,7 @@ use unicode_width::UnicodeWidthStr;
use super::{BRANCH, DURATION_WIDTH, ELAPSED, ENDED_TRUNK, LAST_BRANCH, PASSING_TRUNK, fit_width}; use super::{BRANCH, DURATION_WIDTH, ELAPSED, ENDED_TRUNK, LAST_BRANCH, PASSING_TRUNK, fit_width};
use crate::{ use crate::{
boot_model::{RowStatus, TreeRow, UnitKind}, boot_model::{RowStatus, TreeRow, UnitKind},
color_scheme::TreeColors, screen_settings::{color_scheme::TreeColors, font_glyphs::Glyphs},
font_glyphs::Glyphs,
}; };
const SPINNER: [char; 4] = ['|', '/', '-', '\\']; const SPINNER: [char; 4] = ['|', '/', '-', '\\'];
+4
View File
@@ -0,0 +1,4 @@
pub mod ask_password;
pub mod console_takeover;
pub mod passphrase_input;
pub mod watch_loop;
@@ -8,7 +8,6 @@ use std::{
time::Duration, time::Duration,
}; };
use bootvine::{boot_view::PasswordPrompt, passphrase_input};
use crossterm::event::Event; use crossterm::event::Event;
use rustix::{ use rustix::{
fs::inotify::{self, CreateFlags, WatchFlags}, fs::inotify::{self, CreateFlags, WatchFlags},
@@ -17,7 +16,10 @@ use rustix::{
}; };
use zeroize::Zeroizing; use zeroize::Zeroizing;
use crate::monotonic_clock::monotonic_now; use crate::{
boot_view::PasswordPrompt, console_session::passphrase_input,
systemd_link::monotonic_clock::monotonic_now,
};
const REQUESTS: &str = "/run/systemd/ask-password"; const REQUESTS: &str = "/run/systemd/ask-password";
const REQUEST_PREFIX: &str = "ask."; const REQUEST_PREFIX: &str = "ask.";
@@ -29,6 +31,7 @@ pub struct RequestWatch {
} }
impl RequestWatch { impl RequestWatch {
#[must_use]
pub fn open() -> Option<Self> { pub fn open() -> Option<Self> {
fs::create_dir_all(REQUESTS).ok()?; fs::create_dir_all(REQUESTS).ok()?;
let inotify = inotify::init(CreateFlags::CLOEXEC | CreateFlags::NONBLOCK).ok()?; let inotify = inotify::init(CreateFlags::CLOEXEC | CreateFlags::NONBLOCK).ok()?;
@@ -45,6 +48,7 @@ impl RequestWatch {
Some(Self { inotify }) Some(Self { inotify })
} }
#[must_use]
pub fn changed(&self) -> bool { pub fn changed(&self) -> bool {
let mut events = [0_u8; INOTIFY_BUFFER]; let mut events = [0_u8; INOTIFY_BUFFER];
iter::from_fn(|| { iter::from_fn(|| {
@@ -74,6 +78,7 @@ pub struct PasswordRequest {
asker: Option<Pid>, asker: Option<Pid>,
} }
#[must_use]
pub fn requested() -> bool { pub fn requested() -> bool {
!request_files().is_empty() !request_files().is_empty()
} }
@@ -195,6 +200,7 @@ impl PasswordEntry {
self.request.is_awaited() && (!requests_changed || self.request.file.exists()) self.request.is_awaited() && (!requests_changed || self.request.file.exists())
} }
#[must_use]
pub fn prompt(&self) -> PasswordPrompt<'_> { pub fn prompt(&self) -> PasswordPrompt<'_> {
let input = if self.request.silent { let input = if self.request.silent {
String::new() String::new()
@@ -1,6 +1,5 @@
use std::{collections::HashSet, fs, ptr}; use std::{collections::HashSet, fs, ptr};
use bootvine::font_glyphs::Glyphs;
use rustix::{ use rustix::{
io::Errno, io::Errno,
ioctl::{Getter, IntegerSetter, Opcode, Updater, ioctl}, ioctl::{Getter, IntegerSetter, Opcode, Updater, ioctl},
@@ -8,7 +7,7 @@ use rustix::{
termios::ttyname, termios::ttyname,
}; };
use crate::ask_password; use crate::{console_session::ask_password, screen_settings::font_glyphs::Glyphs};
const GIO_UNIMAP: Opcode = 0x4B66; const GIO_UNIMAP: Opcode = 0x4B66;
const VT_GETSTATE: Opcode = 0x5603; const VT_GETSTATE: Opcode = 0x5603;
@@ -43,6 +42,7 @@ impl Console {
} }
} }
#[must_use]
pub fn answers_password_prompts(&self) -> bool { pub fn answers_password_prompts(&self) -> bool {
self.for_system && self.foreground.is_some() self.for_system && self.foreground.is_some()
} }
File renamed without changes.
@@ -10,14 +10,6 @@ use std::{
time::{Duration, Instant}, time::{Duration, Instant},
}; };
use bootvine::{
boot_model::{BootState, Phase},
boot_origin::BootOrigin,
boot_view::BootView,
color_scheme::Colors,
config_file::Timing,
passphrase_input::asks_to_quit,
};
use crossterm::event; use crossterm::event;
use ratatui::{ use ratatui::{
DefaultTerminal, DefaultTerminal,
@@ -34,13 +26,21 @@ use rustix::{
use signal_hook::{consts::SIGTERM, flag}; use signal_hook::{consts::SIGTERM, flag};
use crate::{ use crate::{
ask_password::{PasswordEntry, RequestWatch}, boot_model::{BootState, Phase, boot_origin::BootOrigin},
boot_feed::{Feed, RootRequest}, boot_view::BootView,
console_takeover::Console, console_session::{
monotonic_clock::monotonic_now, ask_password::{PasswordEntry, RequestWatch},
switch_root::INITRD_RELEASE, console_takeover::Console,
systemd_bus::{Scope, Session}, passphrase_input::asks_to_quit,
watch_error::Error, },
screen_settings::{color_scheme::Colors, config_file::Timing},
systemd_link::{
boot_feed::{Feed, RootRequest},
link_error::Error,
monotonic_clock::monotonic_now,
switch_root::INITRD_RELEASE,
systemd_bus::{Scope, Session},
},
}; };
const FRAME_INTERVAL: Duration = Duration::from_millis(100); const FRAME_INTERVAL: Duration = Duration::from_millis(100);
+3
View File
@@ -0,0 +1,3 @@
#[cfg(test)]
pub(crate) mod boot_test_fixtures;
pub mod scripted_boot;
File renamed without changes.
@@ -10,13 +10,13 @@ use ratatui::{
}; };
use crate::{ use crate::{
boot_model::{ActiveState, Activity, BootState, JobKind, JobResult, Phase, UnitFacts}, boot_model::{
boot_origin::BootOrigin, ActiveState, Activity, BootState, JobKind, JobResult, Phase, UnitFacts,
boot_origin::BootOrigin,
},
boot_view::{BootView, PasswordPrompt}, boot_view::{BootView, PasswordPrompt},
color_scheme::Colors, console_session::passphrase_input,
config_file::Timing, screen_settings::{color_scheme::Colors, config_file::Timing, font_glyphs::Glyphs},
font_glyphs::Glyphs,
passphrase_input,
}; };
const FRAME_INTERVAL: Duration = Duration::from_millis(100); const FRAME_INTERVAL: Duration = Duration::from_millis(100);
+4 -8
View File
@@ -1,10 +1,6 @@
pub mod boot_model; pub mod boot_model;
pub mod boot_origin;
#[cfg(test)]
mod boot_test_fixtures;
pub mod boot_view; pub mod boot_view;
pub mod color_scheme; pub mod console_session;
pub mod config_file; pub mod demo_script;
pub mod font_glyphs; pub mod screen_settings;
pub mod passphrase_input; pub mod systemd_link;
pub mod scripted_boot;
+7 -16
View File
@@ -1,12 +1,3 @@
mod ask_password;
mod boot_feed;
mod console_takeover;
mod monotonic_clock;
mod switch_root;
mod systemd_bus;
mod watch_error;
mod watch_loop;
use std::{ use std::{
error::Error, error::Error,
io::ErrorKind, io::ErrorKind,
@@ -15,16 +6,16 @@ use std::{
time::Duration, time::Duration,
}; };
use bootvine::config_file::{Config, ConfigError, Timing, default_config_table, read_config_file}; use bootvine::{
console_session::watch_loop::{Settings, run},
screen_settings::config_file::{
Config, ConfigError, Timing, default_config_table, read_config_file,
},
systemd_link::{boot_feed::RootRequest, systemd_bus::Scope},
};
use clap::{Parser, Subcommand, ValueEnum}; use clap::{Parser, Subcommand, ValueEnum};
use jiff::fmt::friendly::SpanParser; use jiff::fmt::friendly::SpanParser;
use crate::{
boot_feed::RootRequest,
systemd_bus::Scope,
watch_loop::{Settings, run},
};
#[derive(Parser)] #[derive(Parser)]
#[command( #[command(
about = "Live dependency tree of systemd jobs while the system boots", about = "Live dependency tree of systemd jobs while the system boots",
+3
View File
@@ -0,0 +1,3 @@
pub mod color_scheme;
pub mod config_file;
pub mod font_glyphs;
File renamed without changes.
@@ -5,7 +5,7 @@ use jiff::fmt::serde::unsigned_duration::friendly::compact::required as friendly
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use toml::{Table, Value, de::Error as ParseError, ser::Error as SerializeError}; use toml::{Table, Value, de::Error as ParseError, ser::Error as SerializeError};
use crate::color_scheme::Colors; use crate::screen_settings::color_scheme::Colors;
#[derive(Clone, Copy, Debug, Default, Deserialize, Serialize, PartialEq, Eq)] #[derive(Clone, Copy, Debug, Default, Deserialize, Serialize, PartialEq, Eq)]
#[serde(default, deny_unknown_fields, rename_all = "kebab-case")] #[serde(default, deny_unknown_fields, rename_all = "kebab-case")]
File renamed without changes.
+5
View File
@@ -0,0 +1,5 @@
pub mod boot_feed;
pub mod link_error;
pub mod monotonic_clock;
pub mod switch_root;
pub mod systemd_bus;
@@ -6,14 +6,16 @@ use std::{
time::{Duration, Instant}, time::{Duration, Instant},
}; };
use bootvine::boot_model::{BootState, HANDOFF_UNIT, JobKind, Phase};
use dbus::Path; use dbus::Path;
use crate::{ use crate::{
monotonic_clock::monotonic_now, boot_model::{BootState, HANDOFF_UNIT, JobKind, Phase},
switch_root::Sysroot, systemd_link::{
systemd_bus::{Scope, Session, Signal}, link_error::Error,
watch_error::Error, monotonic_clock::monotonic_now,
switch_root::Sysroot,
systemd_bus::{Scope, Session, Signal},
},
}; };
const RECONNECT_PATIENCE: Duration = Duration::from_secs(60); const RECONNECT_PATIENCE: Duration = Duration::from_secs(60);
@@ -65,6 +67,7 @@ pub struct Feed {
} }
impl Feed { impl Feed {
#[must_use]
pub fn new(phase: Phase, scope: Scope, target: RootRequest) -> Self { pub fn new(phase: Phase, scope: Scope, target: RootRequest) -> Self {
Self { Self {
connections: 0, connections: 0,
@@ -81,6 +84,7 @@ impl Feed {
} }
} }
#[must_use]
pub fn session_fd(&self) -> Option<BorrowedFd<'_>> { pub fn session_fd(&self) -> Option<BorrowedFd<'_>> {
match &self.link { match &self.link {
Link::Connected(session) => Some(session.as_fd()), Link::Connected(session) => Some(session.as_fd()),
File renamed without changes.
@@ -2,6 +2,7 @@ use std::time::Duration;
use rustix::time::{ClockId, clock_gettime}; use rustix::time::{ClockId, clock_gettime};
#[must_use]
pub fn monotonic_now() -> Duration { pub fn monotonic_now() -> Duration {
let now = clock_gettime(ClockId::Monotonic); let now = clock_gettime(ClockId::Monotonic);
Duration::new( Duration::new(
File renamed without changes.
@@ -4,14 +4,16 @@ use std::{
time::Duration, time::Duration,
}; };
use bootvine::boot_model::{ActiveState, Activity, JobKind, JobResult, UnitFacts};
use dbus::{ use dbus::{
Message, MessageType, Path, Message, MessageType, Path,
arg::{AppendAll, PropMap, RefArg, Variant}, arg::{AppendAll, PropMap, RefArg, Variant},
channel::{BusType, Channel}, channel::{BusType, Channel},
}; };
use crate::watch_error::Error; use crate::{
boot_model::{ActiveState, Activity, JobKind, JobResult, UnitFacts},
systemd_link::link_error::Error,
};
const DESTINATION: &str = "org.freedesktop.systemd1"; const DESTINATION: &str = "org.freedesktop.systemd1";
const MANAGER_PATH: &str = "/org/freedesktop/systemd1"; const MANAGER_PATH: &str = "/org/freedesktop/systemd1";