diff --git a/Cargo.lock b/Cargo.lock index c3f92cc..7025f84 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -284,7 +284,7 @@ checksum = "6aa2c4e539b869820a2b82e1aef6ff40aa85e65decdd5185e83fb4b1249cd00f" [[package]] name = "nyanit" -version = "0.2.7" +version = "0.2.8" dependencies = [ "nix", "ratatui", diff --git a/Cargo.toml b/Cargo.toml index f660f0a..8a86d9a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nyanit" -version = "0.2.7" +version = "0.2.8" edition = "2024" [dependencies] diff --git a/src/main.rs b/src/main.rs index fe1de84..3937a8e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -267,6 +267,7 @@ impl NyanitTUI<'_> { let mut tty_input_async = termion::async_stdin().keys(); self.time_counter = 0; + self.time_counter_sec = 0; while !self.exit { terminal.draw(|frame| self.draw(frame))?; self.handle_events(&mut tty_input_async)?; @@ -321,7 +322,7 @@ impl NyanitTUI<'_> { let f2_lines: Vec = vec![ Line::from("Press F2 for options"), Line::default(), - Line::from((WAIT_FOR_F2_SEC.saturating_sub(self.time_counter)).to_string()), + Line::from((WAIT_FOR_F2_SEC.saturating_sub(self.time_counter_sec)).to_string()), ]; let f2_paragraph = Paragraph::new(f2_lines).centered().magenta().bold(); @@ -411,8 +412,6 @@ impl NyanitTUI<'_> { ok_text, vertical_chunks[1].centered_vertically(Constraint::Length(3)), ); - // just some time to look at beez - thread::sleep(Duration::from_millis(1000)) } _ => (), }; @@ -540,6 +539,13 @@ impl NyanitTUI<'_> { } _ => (), }, + NyanitState::HandOff => { + // just some time to look at beez + thread::sleep(Duration::from_millis(1000)); + if let Err(ex) = nyan_system::hand_off_control(TMP_ROOT, SYS_INIT) { + self.state = NyanitState::Error(ex.to_string()) + } + } _ => (), } } diff --git a/src/nyan_system.rs b/src/nyan_system.rs index afb6f79..d807350 100644 --- a/src/nyan_system.rs +++ b/src/nyan_system.rs @@ -19,10 +19,9 @@ */ use nix; +use regex_lite::Regex; use std::fs; use std::process::Command; -use regex_lite::Regex; - /// timeout for block deices population const WAIT_FOR_BLK_DEVS: u64 = 5u64; @@ -138,7 +137,6 @@ pub fn exec_command(cmd: &str, args: &Vec<&str>) -> Result<(), ExecCommandError> } } - #[derive(PartialEq)] pub struct BlkIdRes { pub fs_type: String, @@ -149,8 +147,7 @@ impl BlkIdRes { pub fn is_bcachefs(&self) -> bool { if self.fs_type == "bcachefs" { true - } - else { + } else { false } } @@ -158,7 +155,7 @@ impl BlkIdRes { /// /// Will block up to timeout_secs -/// +/// pub fn try_find_partlabel(partlabel: &str, timeout_secs: u64) -> Option { use std::{thread, time::Duration}; @@ -186,17 +183,23 @@ pub fn find_partlabel(partlabel: &str) -> Result, ExecCommandEr ]) .output()?; if out.status.success() { - let re = Regex::new(r#"^(/dev/[a-z0-9-]+): TYPE="([a-z]+)" PARTLABEL="[a-z0-9-]+""#) - .unwrap(); + let re = + Regex::new(r#"^(/dev/[a-z0-9-]+): TYPE="([a-z]+)" PARTLABEL="[a-z0-9-]+""#).unwrap(); let out_text = String::from_utf8(out.stdout)?; let out_text_trimmed = out_text.trim(); if let Some(captured) = re.captures(out_text_trimmed) { // let part_no = captured[1]; // let parent_dev = captured[2]; - let res = BlkIdRes{ fs_type: captured[2].to_string(), dev_node: captured[1].to_string()}; + let res = BlkIdRes { + fs_type: captured[2].to_string(), + dev_node: captured[1].to_string(), + }; Ok(Some(res)) } else { - Err(ExecCommandError::Other(format!("Unexpected blkid output format: \"{}\"", out_text))) + Err(ExecCommandError::Other(format!( + "Unexpected blkid output format: \"{}\"", + out_text + ))) } } else { if let Some(code) = out.status.code() @@ -512,7 +515,6 @@ impl Iterator for RollBackIterator { } } - /// /// Checks if pac_lock file exist and returns date-time from it if it does, /// Otherwise return None