4 Commits
Author SHA256 Message Date
kira c7b57d0b68 Fixing hand off absense after F2 stage, and F2 times display. 2026-10-13 01:00:13 +02:00
kira 0862b4f37f Chores 2026-10-12 23:45:34 +02:00
kira 5583e52477 Rename mnt/bee_root to mnt/bee-root 2026-10-12 23:42:37 +02:00
kira 1fb8560381 Another fix for find_partlabel, more robust blkid parsing 2026-10-12 22:35:59 +02:00
5 changed files with 27 additions and 137 deletions

No files matched your search

Generated
+1 -1
View File
@@ -284,7 +284,7 @@ checksum = "6aa2c4e539b869820a2b82e1aef6ff40aa85e65decdd5185e83fb4b1249cd00f"
[[package]]
name = "nyanit"
version = "0.2.5"
version = "0.2.8"
dependencies = [
"nix",
"ratatui",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "nyanit"
version = "0.2.5"
version = "0.2.8"
edition = "2024"
[dependencies]
+1 -1
View File
@@ -14,7 +14,7 @@ workdir=$1
echo "Populate initdramfs tree..."
cd $workdir
mkdir -p initramfs/{dev,proc,sys,run,mnt,mnt/bee_root,tmp,etc,usr,usr/bin,usr/lib}
mkdir -p initramfs/{dev,proc,sys,run,mnt,mnt/bee-root,tmp,etc,usr,usr/bin,usr/lib}
echo "Create /bin /lib /lib64 simlinks"
cd $workdir/initramfs
+9 -3
View File
@@ -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<Line> = 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())
}
}
_ => (),
}
}
+15 -131
View File
@@ -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<BlkIdRes> {
use std::{thread, time::Duration};
@@ -186,17 +183,23 @@ pub fn find_partlabel(partlabel: &str) -> Result<Option<BlkIdRes>, 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)?;
if let Some(captured) = re.captures(&out_text) {
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,125 +515,6 @@ impl Iterator for RollBackIterator {
}
}
// pub fn roll_back_snap(
// snaps_list: Vec<String>,
// target_snap: String,
// ) -> impl Iterator<Item = Result<String, ExecCommandError>> {
// let usr_ro_snap_path = format!("{}/bzz-{}-{}", TMP_ROOT_SNAPS, "usr", target_snap);
// let var_ro_snap_path = format!("{}/bzz-{}-{}", TMP_ROOT_SNAPS, "usr", target_snap);
// let mut roll_state = RollbackStates::Start;
// std::iter::from_fn(move || match roll_state {
// RollbackStates::Start => {
// roll_state = RollbackStates::RenameUsrVarAct;
// Some(Ok("Move usr and var to temporary location".into()))
// }
// RollbackStates::RenameUsrVarAct => {
// let move_res = fs::rename(TMP_ROOT_USR, TMP_ROOT_SNAPS_USR)
// .and_then(|_| fs::rename(TMP_ROOT_VAR, TMP_ROOT_SNAPS_VAR));
// if let Err(ex) = move_res {
// roll_state = RollbackStates::Err;
// Some(Err(ex.into()))
// } else {
// roll_state = RollbackStates::ChangeToRw;
// Some(Ok("Setting snapshot as current system ...".into()))
// }
// }
// RollbackStates::ChangeToRw => {
// let rw_res = snapshot_rw(&usr_ro_snap_path, TMP_ROOT_USR)
// .and_then(|_| snapshot_rw(&var_ro_snap_path, TMP_ROOT_VAR));
// if let Err(ex) = rw_res {
// roll_state = RollbackStates::Err;
// Some(Err(ex))
// } else {
// roll_state = RollbackStates::MoveSubvolums;
// Some(Ok(
// "Moving subvolumes from old /usr and /var to new one".into()
// ))
// }
// }
// RollbackStates::MoveSubvolums => {
// let mut mv_res = Some(Ok("Removing old /usr and /var".into()));
// for (vol, svol_path) in SBUVOL_TO_MOVE {
// let v_from = format!("{}{}{}", TMP_ROOT_SNAPS_PREFIX, vol, svol_path);
// let v_dest = format!("{}/{}{}", TMP_ROOT, vol, svol_path);
// if let Err(ex) = fs::rename(v_from, v_dest) {
// roll_state = RollbackStates::Err;
// mv_res = Some(Err(ex.into()));
// break;
// }
// }
// roll_state = RollbackStates::RemoveOldVols;
// mv_res
// }
// RollbackStates::RemoveOldVols => {
// let rem_old_res = subvolume_delete(TMP_ROOT_SNAPS_USR)
// .and_then(|_| subvolume_delete(TMP_ROOT_SNAPS_VAR));
// if let Err(ex) = rem_old_res {
// roll_state = RollbackStates::Err;
// Some(Err(ex))
// } else {
// roll_state = RollbackStates::ClearSnaps;
// Some(Ok("Clearing snapshots...".into()))
// }
// }
// RollbackStates::ClearSnaps => {
// let mut clr_snap_res = Some(Ok("All done!".into()));
// for snap_date_time in snaps_list.iter().rev() {
// let usr_snap = format!("{}/bzz-{}-{}", TMP_ROOT_SNAPS, "usr", snap_date_time);
// let var_snap = format!("{}/bzz-{}-{}", TMP_ROOT_SNAPS, "var", snap_date_time);
// if let Err(ex) =
// subvolume_delete(&usr_snap).and_then(|_| subvolume_delete(&var_snap))
// {
// clr_snap_res = Some(Err(ex));
// roll_state = RollbackStates::Err;
// break;
// }
// if snap_date_time == &target_snap {
// break;
// }
// }
// clr_snap_res
// }
// RollbackStates::Finish => None,
// RollbackStates::Err => None,
// })
// // 1. Rename usr and var to TMP_ROOT_SNAPS/tmp_var|usr
// // fs::rename(TMP_ROOT_USR, TMP_ROOT_SNAPS_USR)?;
// // fs::rename(TMP_ROOT_VAR, TMP_ROOT_SNAPS_VAR)?;
// // 2. snapshot desired snaps as RW to /usr and /var
// // snapshot_rw(&usr_ro_snap_path, TMP_ROOT_USR)?;
// // snapshot_rw(&var_ro_snap_path, TMP_ROOT_VAR)?;
// // 3. move subvolumes from old /usr and /var
// // for (vol, svol_path) in SBUVOL_TO_MOVE {
// // let v_from = format!("{}{}{}", TMP_ROOT_SNAPS_PREFIX, vol, svol_path);
// // let v_dest = format!("{}/{}{}",TMP_ROOT,vol,svol_path);
// // fs::rename(v_from, v_dest)?;
// // }
// // 4. removing tmp /usr /var
// // subvolume_delete(TMP_ROOT_SNAPS_USR)?;
// // subvolume_delete(TMP_ROOT_SNAPS_VAR)?;
// // 5. Removing all snapshoots made after one we restored, including inself
// // Iterate in reverse untill we get to target_snap in snaps list
// // for snap_date_time in snaps_list.iter().rev() {
// // let usr_snap = format!("{}/bzz-{}-{}", TMP_ROOT_SNAPS, "usr", snap_date_time);
// // let var_snap = format!("{}/bzz-{}-{}", TMP_ROOT_SNAPS, "usr", snap_date_time);
// // subvolume_delete(&usr_snap)?;
// // subvolume_delete(&var_snap)?;
// // if snap_date_time == target_snap {
// // break;
// // }
// // }
// // Ok(())
// }
///
/// Checks if pac_lock file exist and returns date-time from it if it does,
/// Otherwise return None