refactor: group modules by data-flow stage behind a thin main
This commit is contained in:
1 parent
f9cc94c633
commit
2191a27b82
38 files changed
+104
-88
No files matched your search
+1
-1
@@ -2,7 +2,7 @@ use std::{io, time::Duration};
|
||||
|
||||
use bootvine::{
|
||||
boot_model::Phase,
|
||||
scripted_boot::{Scenario, Step, failing, play, step},
|
||||
demo_script::scripted_boot::{Scenario, Step, failing, play, step},
|
||||
};
|
||||
|
||||
const INITRD: &[Step] = &[
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ use std::{io, time::Duration};
|
||||
|
||||
use bootvine::{
|
||||
boot_model::Phase,
|
||||
scripted_boot::{Scenario, Step, play, step, unlocking},
|
||||
demo_script::scripted_boot::{Scenario, Step, play, step, unlocking},
|
||||
};
|
||||
|
||||
const ROOT_PARTITION: &str =
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::{io, time::Duration};
|
||||
|
||||
use bootvine::{
|
||||
boot_model::Phase,
|
||||
scripted_boot::{Scenario, Step, play, step, stopping},
|
||||
demo_script::scripted_boot::{Scenario, Step, play, step, stopping},
|
||||
};
|
||||
|
||||
const SHUTDOWN: &[Step] = &[
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
pub mod boot_origin;
|
||||
mod job_ingestion;
|
||||
mod reached_milestones;
|
||||
mod unit_facts;
|
||||
|
||||
File renamed without changes.
@@ -258,7 +258,7 @@ mod tests {
|
||||
use super::*;
|
||||
use crate::{
|
||||
boot_model::RowStatus,
|
||||
boot_test_fixtures::{
|
||||
demo_script::boot_test_fixtures::{
|
||||
MS, activating, facts, nested_boot_sample as sample, queue_unit, queued_boot, waiting,
|
||||
waiting_rows,
|
||||
},
|
||||
|
||||
@@ -92,7 +92,9 @@ mod tests {
|
||||
use super::*;
|
||||
use crate::{
|
||||
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]
|
||||
|
||||
@@ -172,7 +172,7 @@ pub(super) fn summary(facts: &UnitFacts) -> String {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::boot_test_fixtures::{facts, waiting};
|
||||
use crate::demo_script::boot_test_fixtures::{facts, waiting};
|
||||
|
||||
#[test]
|
||||
fn kinds_with_a_tag_drop_their_suffix() {
|
||||
|
||||
@@ -241,7 +241,7 @@ impl BootState {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::boot_test_fixtures::{
|
||||
use crate::demo_script::boot_test_fixtures::{
|
||||
nested_boot_sample, queued_boot, tree_outline, waiting, waiting_rows,
|
||||
};
|
||||
|
||||
|
||||
+4
-5
@@ -32,11 +32,10 @@ use self::{
|
||||
unit_tree::UnitTree,
|
||||
};
|
||||
use crate::{
|
||||
boot_model::{BootState, RowStatus, TreeRow, UnitKind, flatten_forest},
|
||||
boot_origin::BootOrigin,
|
||||
color_scheme::Colors,
|
||||
config_file::Timing,
|
||||
font_glyphs::Glyphs,
|
||||
boot_model::{
|
||||
BootState, RowStatus, TreeRow, UnitKind, boot_origin::BootOrigin, flatten_forest,
|
||||
},
|
||||
screen_settings::{color_scheme::Colors, config_file::Timing, font_glyphs::Glyphs},
|
||||
};
|
||||
|
||||
const DURATION_WIDTH: u16 = 8;
|
||||
|
||||
@@ -6,8 +6,8 @@ use super::{
|
||||
};
|
||||
use crate::{
|
||||
boot_model::{BootState, JobResult, Phase},
|
||||
boot_test_fixtures::{MS, queue_unit, queued_boot, running, waiting},
|
||||
color_scheme::Colors,
|
||||
demo_script::boot_test_fixtures::{MS, queue_unit, queued_boot, running, waiting},
|
||||
screen_settings::color_scheme::Colors,
|
||||
};
|
||||
|
||||
const CRYPTSETUP_MESSAGE: &str =
|
||||
|
||||
@@ -16,8 +16,7 @@ use ratatui::{
|
||||
use super::{fit_width, rule, unit_count};
|
||||
use crate::{
|
||||
boot_model::{FinishedRun, MilestoneRow},
|
||||
color_scheme::TimelineColors,
|
||||
font_glyphs::Glyphs,
|
||||
screen_settings::{color_scheme::TimelineColors, font_glyphs::Glyphs},
|
||||
};
|
||||
|
||||
pub const LABEL_WIDTH: u16 = 28;
|
||||
|
||||
@@ -10,10 +10,11 @@ use ratatui::{
|
||||
|
||||
use super::{DURATION_WIDTH, ELAPSED};
|
||||
use crate::{
|
||||
boot_model::Tally,
|
||||
boot_origin::BootOrigin,
|
||||
color_scheme::{FooterColors, HeaderColors, PasswordColors},
|
||||
font_glyphs::Glyphs,
|
||||
boot_model::{Tally, boot_origin::BootOrigin},
|
||||
screen_settings::{
|
||||
color_scheme::{FooterColors, HeaderColors, PasswordColors},
|
||||
font_glyphs::Glyphs,
|
||||
},
|
||||
};
|
||||
|
||||
pub const FOOTER_HEIGHT: u16 = 2;
|
||||
|
||||
@@ -4,12 +4,9 @@ use ratatui::{Terminal, backend::TestBackend, buffer::Buffer};
|
||||
|
||||
use super::{BootView, PasswordPrompt};
|
||||
use crate::{
|
||||
boot_model::{BootState, JobResult, Phase},
|
||||
boot_origin::BootOrigin,
|
||||
boot_test_fixtures::{MS, queued_boot, running, waiting},
|
||||
color_scheme::Colors,
|
||||
config_file::Timing,
|
||||
font_glyphs::Glyphs,
|
||||
boot_model::{BootState, JobResult, Phase, boot_origin::BootOrigin},
|
||||
demo_script::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> {
|
||||
|
||||
@@ -9,7 +9,10 @@ use ratatui::{
|
||||
};
|
||||
|
||||
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 PHASE_WIDTH: usize = 9;
|
||||
|
||||
@@ -94,7 +94,7 @@ mod tests {
|
||||
use super::*;
|
||||
use crate::{
|
||||
boot_model::{BootState, Phase},
|
||||
boot_test_fixtures::{
|
||||
demo_script::boot_test_fixtures::{
|
||||
activating, nested_boot_sample, queued_boot, running, tree_outline, waiting,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -5,7 +5,7 @@ use unicode_width::UnicodeWidthStr;
|
||||
use super::screen_render_fixtures::{boot_in_progress, chain_boot, described_boot, render};
|
||||
use crate::{
|
||||
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]
|
||||
|
||||
@@ -12,8 +12,7 @@ use unicode_width::UnicodeWidthStr;
|
||||
use super::{BRANCH, DURATION_WIDTH, ELAPSED, ENDED_TRUNK, LAST_BRANCH, PASSING_TRUNK, fit_width};
|
||||
use crate::{
|
||||
boot_model::{RowStatus, TreeRow, UnitKind},
|
||||
color_scheme::TreeColors,
|
||||
font_glyphs::Glyphs,
|
||||
screen_settings::{color_scheme::TreeColors, font_glyphs::Glyphs},
|
||||
};
|
||||
|
||||
const SPINNER: [char; 4] = ['|', '/', '-', '\\'];
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
use bootvine::{boot_view::PasswordPrompt, passphrase_input};
|
||||
use crossterm::event::Event;
|
||||
use rustix::{
|
||||
fs::inotify::{self, CreateFlags, WatchFlags},
|
||||
@@ -17,7 +16,10 @@ use rustix::{
|
||||
};
|
||||
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 REQUEST_PREFIX: &str = "ask.";
|
||||
@@ -29,6 +31,7 @@ pub struct RequestWatch {
|
||||
}
|
||||
|
||||
impl RequestWatch {
|
||||
#[must_use]
|
||||
pub fn open() -> Option<Self> {
|
||||
fs::create_dir_all(REQUESTS).ok()?;
|
||||
let inotify = inotify::init(CreateFlags::CLOEXEC | CreateFlags::NONBLOCK).ok()?;
|
||||
@@ -45,6 +48,7 @@ impl RequestWatch {
|
||||
Some(Self { inotify })
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn changed(&self) -> bool {
|
||||
let mut events = [0_u8; INOTIFY_BUFFER];
|
||||
iter::from_fn(|| {
|
||||
@@ -74,6 +78,7 @@ pub struct PasswordRequest {
|
||||
asker: Option<Pid>,
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn requested() -> bool {
|
||||
!request_files().is_empty()
|
||||
}
|
||||
@@ -195,6 +200,7 @@ impl PasswordEntry {
|
||||
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()
|
||||
@@ -1,6 +1,5 @@
|
||||
use std::{collections::HashSet, fs, ptr};
|
||||
|
||||
use bootvine::font_glyphs::Glyphs;
|
||||
use rustix::{
|
||||
io::Errno,
|
||||
ioctl::{Getter, IntegerSetter, Opcode, Updater, ioctl},
|
||||
@@ -8,7 +7,7 @@ use rustix::{
|
||||
termios::ttyname,
|
||||
};
|
||||
|
||||
use crate::ask_password;
|
||||
use crate::{console_session::ask_password, screen_settings::font_glyphs::Glyphs};
|
||||
|
||||
const GIO_UNIMAP: Opcode = 0x4B66;
|
||||
const VT_GETSTATE: Opcode = 0x5603;
|
||||
@@ -43,6 +42,7 @@ impl Console {
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn answers_password_prompts(&self) -> bool {
|
||||
self.for_system && self.foreground.is_some()
|
||||
}
|
||||
File renamed without changes.
@@ -10,14 +10,6 @@ use std::{
|
||||
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 ratatui::{
|
||||
DefaultTerminal,
|
||||
@@ -34,13 +26,21 @@ use rustix::{
|
||||
use signal_hook::{consts::SIGTERM, flag};
|
||||
|
||||
use crate::{
|
||||
ask_password::{PasswordEntry, RequestWatch},
|
||||
boot_feed::{Feed, RootRequest},
|
||||
console_takeover::Console,
|
||||
monotonic_clock::monotonic_now,
|
||||
switch_root::INITRD_RELEASE,
|
||||
systemd_bus::{Scope, Session},
|
||||
watch_error::Error,
|
||||
boot_model::{BootState, Phase, boot_origin::BootOrigin},
|
||||
boot_view::BootView,
|
||||
console_session::{
|
||||
ask_password::{PasswordEntry, RequestWatch},
|
||||
console_takeover::Console,
|
||||
passphrase_input::asks_to_quit,
|
||||
},
|
||||
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);
|
||||
@@ -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::{
|
||||
boot_model::{ActiveState, Activity, BootState, JobKind, JobResult, Phase, UnitFacts},
|
||||
boot_origin::BootOrigin,
|
||||
boot_model::{
|
||||
ActiveState, Activity, BootState, JobKind, JobResult, Phase, UnitFacts,
|
||||
boot_origin::BootOrigin,
|
||||
},
|
||||
boot_view::{BootView, PasswordPrompt},
|
||||
color_scheme::Colors,
|
||||
config_file::Timing,
|
||||
font_glyphs::Glyphs,
|
||||
passphrase_input,
|
||||
console_session::passphrase_input,
|
||||
screen_settings::{color_scheme::Colors, config_file::Timing, font_glyphs::Glyphs},
|
||||
};
|
||||
|
||||
const FRAME_INTERVAL: Duration = Duration::from_millis(100);
|
||||
+4
-8
@@ -1,10 +1,6 @@
|
||||
pub mod boot_model;
|
||||
pub mod boot_origin;
|
||||
#[cfg(test)]
|
||||
mod boot_test_fixtures;
|
||||
pub mod boot_view;
|
||||
pub mod color_scheme;
|
||||
pub mod config_file;
|
||||
pub mod font_glyphs;
|
||||
pub mod passphrase_input;
|
||||
pub mod scripted_boot;
|
||||
pub mod console_session;
|
||||
pub mod demo_script;
|
||||
pub mod screen_settings;
|
||||
pub mod systemd_link;
|
||||
+7
-16
@@ -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::{
|
||||
error::Error,
|
||||
io::ErrorKind,
|
||||
@@ -15,16 +6,16 @@ use std::{
|
||||
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 jiff::fmt::friendly::SpanParser;
|
||||
|
||||
use crate::{
|
||||
boot_feed::RootRequest,
|
||||
systemd_bus::Scope,
|
||||
watch_loop::{Settings, run},
|
||||
};
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(
|
||||
about = "Live dependency tree of systemd jobs while the system boots",
|
||||
|
||||
@@ -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 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)]
|
||||
#[serde(default, deny_unknown_fields, rename_all = "kebab-case")]
|
||||
File renamed without changes.
@@ -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},
|
||||
};
|
||||
|
||||
use bootvine::boot_model::{BootState, HANDOFF_UNIT, JobKind, Phase};
|
||||
use dbus::Path;
|
||||
|
||||
use crate::{
|
||||
monotonic_clock::monotonic_now,
|
||||
switch_root::Sysroot,
|
||||
systemd_bus::{Scope, Session, Signal},
|
||||
watch_error::Error,
|
||||
boot_model::{BootState, HANDOFF_UNIT, JobKind, Phase},
|
||||
systemd_link::{
|
||||
link_error::Error,
|
||||
monotonic_clock::monotonic_now,
|
||||
switch_root::Sysroot,
|
||||
systemd_bus::{Scope, Session, Signal},
|
||||
},
|
||||
};
|
||||
|
||||
const RECONNECT_PATIENCE: Duration = Duration::from_secs(60);
|
||||
@@ -65,6 +67,7 @@ pub struct Feed {
|
||||
}
|
||||
|
||||
impl Feed {
|
||||
#[must_use]
|
||||
pub fn new(phase: Phase, scope: Scope, target: RootRequest) -> Self {
|
||||
Self {
|
||||
connections: 0,
|
||||
@@ -81,6 +84,7 @@ impl Feed {
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn session_fd(&self) -> Option<BorrowedFd<'_>> {
|
||||
match &self.link {
|
||||
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};
|
||||
|
||||
#[must_use]
|
||||
pub fn monotonic_now() -> Duration {
|
||||
let now = clock_gettime(ClockId::Monotonic);
|
||||
Duration::new(
|
||||
File renamed without changes.
@@ -4,14 +4,16 @@ use std::{
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use bootvine::boot_model::{ActiveState, Activity, JobKind, JobResult, UnitFacts};
|
||||
use dbus::{
|
||||
Message, MessageType, Path,
|
||||
arg::{AppendAll, PropMap, RefArg, Variant},
|
||||
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 MANAGER_PATH: &str = "/org/freedesktop/systemd1";
|
||||
Reference in new issue
Block a user