3 Commits
Author SHA256 Message Date
kira 43c04f6d41 Some fixes and debug messages 2026-10-23 23:22:23 +02:00
kira aec7de0cc4 Quickfix of early exit in pac_start 2026-10-11 23:32:47 +02:00
kira e13806ce05 Add check for /var/lib/hive-up directory existance 2026-10-11 23:17:47 +02:00
4 changed files with 45 additions and 17 deletions

No files matched your search

Generated
+1 -1
View File
@@ -152,7 +152,7 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]]
name = "hive-up"
version = "0.2.4"
version = "0.2.6"
dependencies = [
"clap",
"nix",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "hive-up"
version = "0.2.4"
version = "0.2.6"
edition = "2024"
[dependencies]
+39 -13
View File
@@ -38,6 +38,7 @@ const BOOT_UKI_IMAGE_NAME: &str = "\\EFI\\boot\\linux-kira-lts.efi";
const BOOT_UKI_IMAGE_NAME_BACK: &str = "\\EFI\\boot\\linux-kira-lts-back.efi";
const PAC_LOCK_FILE: &str = "/var/lib/hive-up/pac-lock";
const PAC_LOCK_DIR: &str = "/var/lib/hive-up";
#[derive(Debug)]
pub struct CommandFailed {
@@ -299,6 +300,17 @@ pub fn clean_snaps(snaps_conf: &SnapshotsConfig) -> Result<(), ExecCommandError>
pub fn pac_start(hive_config: &HiveConfig) -> Result<(), ExecCommandError> {
use std::path::Path;
// checking is PAC_LOCK_DIR ("/var/lib/hive-up") exist
// and creating it if it does not.
let pack_lock_dir_path = Path::new(PAC_LOCK_DIR);
if !pack_lock_dir_path.exists() {
println!(
"Warning! {} directory do not exist. Creating...",
PAC_LOCK_DIR
);
fs::create_dir_all(pack_lock_dir_path)?;
}
// if snapshots is configured
if let Some(snaps_conf) = &hive_config.snapshots {
if snaps_conf.enable.unwrap_or(false) {
@@ -338,7 +350,7 @@ pub fn pac_finish() -> Result<(), ExecCommandError> {
// Check if lock file exist
let pack_lock_path = Path::new(PAC_LOCK_FILE);
if pack_lock_path.exists() {
println!("Remowing pac-lock...");
println!("Removing pac-lock...");
fs::remove_file(pack_lock_path)?;
} else {
println!("Warning! Pac Lock file does not exist...");
@@ -484,7 +496,6 @@ pub fn check_if_run_as_root() -> bool {
/// We need more complex logic for it.
/// Need to alterate between two boot records.
///
///
fn get_efi_part_info() -> Result<(String, String), ExecCommandError> {
use regex_lite::Regex;
let re = Regex::new(r#"^PARTN="([0-9]+)" PKNAME="([0-9a-Z]+)"$"#).unwrap();
@@ -516,11 +527,15 @@ fn list_efi_bootnums() -> Result<Vec<String>, ExecCommandError> {
// for each line in output match bootnum
// and collect to vector
Ok(str_res
.lines()
.filter_map(|hs| re.captures(hs))
.map(|captured| captured[1].to_string())
.collect())
println!("Parsing bootnums");
let mut res: Vec<String> = Vec::new();
for ln in str_res.lines() {
if let Some(captured) = re.captures(ln) {
res.push(captured[1].to_string());
}
}
println!("Done parsing bootnums");
Ok(res)
}
///
@@ -537,6 +552,7 @@ fn delete_efi_bootnum(bootnum: &str) -> Result<(), ExecCommandError> {
///
fn delete_all_efi_bootnums() -> Result<usize, ExecCommandError> {
let bootnums = list_efi_bootnums()?;
println!("Deleting bootnums...");
for bootnum in &bootnums {
delete_efi_bootnum(bootnum)?;
}
@@ -657,18 +673,28 @@ pub fn init_efi_boot_partition_content() -> Result<(), ExecCommandError> {
/// sudo cp /usr/lib/modules/6.18.46-1-kira-lts/vmlinuz /beefi/EFI/kira-linux-lts.efi
///
pub fn boot_update() -> Result<(), ExecCommandError> {
use std::path::Path;
// find vmlinuz path in filesystem
let kernel_dirs = list_installed_kernels()?;
// check if kernel even exist lol
if let Some(kernel_dir) = kernel_dirs.last() {
let kernel_img_path = format!("/usr/lib/modules/{}/vmlinuz", kernel_dir);
// rename old kernel to
println!(
"Renaming old kernel {} to {}",
UKI_IMAGE_NAME, UKI_IMAGE_BACK_NAME
);
fs::rename(UKI_IMAGE_NAME, UKI_IMAGE_BACK_NAME)?;
// rename old kernel
// checking if UKI image exist
let uki_img_path = Path::new(UKI_IMAGE_NAME);
if !uki_img_path.exists() {
println!(
"Renaming old kernel {} to {}",
UKI_IMAGE_NAME, UKI_IMAGE_BACK_NAME
);
// rename old kernel
fs::rename(UKI_IMAGE_NAME, UKI_IMAGE_BACK_NAME)?;
} else {
println!("Warning! UKI image {} do not exists.", UKI_IMAGE_NAME);
}
// copy new kernel image
println!(
"Copy new kernel from {} to {}",
+4 -2
View File
@@ -153,11 +153,13 @@ fn main() -> Result<(), HiveUpError> {
}
BootCommand::Init => {
println!("Init EFI boot menu and EFI partition content...");
println!("Init EFI Partition content...");
hive_system::init_efi_boot_partition_content()?;
println!("Init EFI boot menu...");
let kernel_cmd = bzz_config.kernel.and_then(|kk| kk.cmd.clone());
hive_system::init_efi_boot_record(&kernel_cmd)?;
println!("Init EFI boot menu...");
hive_system::init_efi_boot_partition_content()?;
}
},
HiveUpMode::Pac(pac_mode) => match pac_mode {