SHA256
Compare commits
| Author | SHA256 | Date | |
|---|---|---|---|
|
|
1621a11e3f | ||
|
|
43c04f6d41 | ||
|
|
aec7de0cc4 |
No files matched your search
Generated
+1
-1
@@ -152,7 +152,7 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hive-up"
|
name = "hive-up"
|
||||||
version = "0.2.5"
|
version = "0.2.8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"nix",
|
"nix",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "hive-up"
|
name = "hive-up"
|
||||||
version = "0.2.5"
|
version = "0.2.8"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
+27
-11
@@ -304,9 +304,11 @@ pub fn pac_start(hive_config: &HiveConfig) -> Result<(), ExecCommandError> {
|
|||||||
// and creating it if it does not.
|
// and creating it if it does not.
|
||||||
let pack_lock_dir_path = Path::new(PAC_LOCK_DIR);
|
let pack_lock_dir_path = Path::new(PAC_LOCK_DIR);
|
||||||
if !pack_lock_dir_path.exists() {
|
if !pack_lock_dir_path.exists() {
|
||||||
println!("Warning! {} directory do not exist. Creating...", PAC_LOCK_DIR);
|
println!(
|
||||||
|
"Warning! {} directory do not exist. Creating...",
|
||||||
|
PAC_LOCK_DIR
|
||||||
|
);
|
||||||
fs::create_dir_all(pack_lock_dir_path)?;
|
fs::create_dir_all(pack_lock_dir_path)?;
|
||||||
return Ok(());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if snapshots is configured
|
// if snapshots is configured
|
||||||
@@ -494,10 +496,9 @@ pub fn check_if_run_as_root() -> bool {
|
|||||||
/// We need more complex logic for it.
|
/// We need more complex logic for it.
|
||||||
/// Need to alterate between two boot records.
|
/// Need to alterate between two boot records.
|
||||||
///
|
///
|
||||||
///
|
|
||||||
fn get_efi_part_info() -> Result<(String, String), ExecCommandError> {
|
fn get_efi_part_info() -> Result<(String, String), ExecCommandError> {
|
||||||
use regex_lite::Regex;
|
use regex_lite::Regex;
|
||||||
let re = Regex::new(r#"^PARTN="([0-9]+)" PKNAME="([0-9a-Z]+)"$"#).unwrap();
|
let re = Regex::new(r#"^PARTN="([0-9]+)" PKNAME="([a-zA-Z0-9]+)"$"#).unwrap();
|
||||||
|
|
||||||
let lsblk_query = format!("PARTLABEL==\"{}\"", EFI_PARTLABEL);
|
let lsblk_query = format!("PARTLABEL==\"{}\"", EFI_PARTLABEL);
|
||||||
let lsblk_args: Vec<&str> = vec!["-P", "-p", "-Q", &lsblk_query, "-o", "PARTN,PKNAME"];
|
let lsblk_args: Vec<&str> = vec!["-P", "-p", "-Q", &lsblk_query, "-o", "PARTN,PKNAME"];
|
||||||
@@ -526,11 +527,15 @@ fn list_efi_bootnums() -> Result<Vec<String>, ExecCommandError> {
|
|||||||
|
|
||||||
// for each line in output match bootnum
|
// for each line in output match bootnum
|
||||||
// and collect to vector
|
// and collect to vector
|
||||||
Ok(str_res
|
println!("Parsing bootnums");
|
||||||
.lines()
|
let mut res: Vec<String> = Vec::new();
|
||||||
.filter_map(|hs| re.captures(hs))
|
for ln in str_res.lines() {
|
||||||
.map(|captured| captured[1].to_string())
|
if let Some(captured) = re.captures(ln) {
|
||||||
.collect())
|
res.push(captured[1].to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
println!("Done parsing bootnums");
|
||||||
|
Ok(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -547,6 +552,7 @@ fn delete_efi_bootnum(bootnum: &str) -> Result<(), ExecCommandError> {
|
|||||||
///
|
///
|
||||||
fn delete_all_efi_bootnums() -> Result<usize, ExecCommandError> {
|
fn delete_all_efi_bootnums() -> Result<usize, ExecCommandError> {
|
||||||
let bootnums = list_efi_bootnums()?;
|
let bootnums = list_efi_bootnums()?;
|
||||||
|
println!("Deleting bootnums...");
|
||||||
for bootnum in &bootnums {
|
for bootnum in &bootnums {
|
||||||
delete_efi_bootnum(bootnum)?;
|
delete_efi_bootnum(bootnum)?;
|
||||||
}
|
}
|
||||||
@@ -642,7 +648,7 @@ pub fn init_efi_boot_partition_content() -> Result<(), ExecCommandError> {
|
|||||||
let kernel_img_path = format!("/usr/lib/modules/{}/vmlinuz", kernel_dir);
|
let kernel_img_path = format!("/usr/lib/modules/{}/vmlinuz", kernel_dir);
|
||||||
let efi_dir = format!("{}/EFI", EFI_BOOT_MOUNT_POINT);
|
let efi_dir = format!("{}/EFI", EFI_BOOT_MOUNT_POINT);
|
||||||
println!("Romoving efi dir {}", efi_dir);
|
println!("Romoving efi dir {}", efi_dir);
|
||||||
fs::remove_dir_all(&efi_dir)?;
|
let _ = fs::remove_dir_all(&efi_dir);
|
||||||
|
|
||||||
println!("Creating efi dir {}", EFI_BOOT_DIR);
|
println!("Creating efi dir {}", EFI_BOOT_DIR);
|
||||||
fs::create_dir_all(EFI_BOOT_DIR)?;
|
fs::create_dir_all(EFI_BOOT_DIR)?;
|
||||||
@@ -667,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
|
/// sudo cp /usr/lib/modules/6.18.46-1-kira-lts/vmlinuz /beefi/EFI/kira-linux-lts.efi
|
||||||
///
|
///
|
||||||
pub fn boot_update() -> Result<(), ExecCommandError> {
|
pub fn boot_update() -> Result<(), ExecCommandError> {
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
// find vmlinuz path in filesystem
|
// find vmlinuz path in filesystem
|
||||||
let kernel_dirs = list_installed_kernels()?;
|
let kernel_dirs = list_installed_kernels()?;
|
||||||
|
|
||||||
// check if kernel even exist lol
|
// check if kernel even exist lol
|
||||||
if let Some(kernel_dir) = kernel_dirs.last() {
|
if let Some(kernel_dir) = kernel_dirs.last() {
|
||||||
let kernel_img_path = format!("/usr/lib/modules/{}/vmlinuz", kernel_dir);
|
let kernel_img_path = format!("/usr/lib/modules/{}/vmlinuz", kernel_dir);
|
||||||
// rename old kernel to
|
// rename old kernel
|
||||||
|
// checking if UKI image exist
|
||||||
|
let uki_img_path = Path::new(UKI_IMAGE_NAME);
|
||||||
|
if !uki_img_path.exists() {
|
||||||
println!(
|
println!(
|
||||||
"Renaming old kernel {} to {}",
|
"Renaming old kernel {} to {}",
|
||||||
UKI_IMAGE_NAME, UKI_IMAGE_BACK_NAME
|
UKI_IMAGE_NAME, UKI_IMAGE_BACK_NAME
|
||||||
);
|
);
|
||||||
|
// rename old kernel
|
||||||
fs::rename(UKI_IMAGE_NAME, UKI_IMAGE_BACK_NAME)?;
|
fs::rename(UKI_IMAGE_NAME, UKI_IMAGE_BACK_NAME)?;
|
||||||
|
} else {
|
||||||
|
println!("Warning! UKI image {} do not exists.", UKI_IMAGE_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
// copy new kernel image
|
// copy new kernel image
|
||||||
println!(
|
println!(
|
||||||
"Copy new kernel from {} to {}",
|
"Copy new kernel from {} to {}",
|
||||||
|
|||||||
+4
-2
@@ -153,11 +153,13 @@ fn main() -> Result<(), HiveUpError> {
|
|||||||
}
|
}
|
||||||
BootCommand::Init => {
|
BootCommand::Init => {
|
||||||
println!("Init EFI boot menu and EFI partition content...");
|
println!("Init EFI boot menu and EFI partition content...");
|
||||||
|
|
||||||
println!("Init 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());
|
let kernel_cmd = bzz_config.kernel.and_then(|kk| kk.cmd.clone());
|
||||||
hive_system::init_efi_boot_record(&kernel_cmd)?;
|
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 {
|
HiveUpMode::Pac(pac_mode) => match pac_mode {
|
||||||
|
|||||||
Reference in new issue
Block a user