From c26a5c5af5d1cd3b3d614fdcc1a15a5c9593ce01 Mon Sep 17 00:00:00 2001 From: UsernameSwift Date: Fri, 24 Jun 2022 20:52:48 -0400 Subject: [PATCH 1/8] Fix default hostname and unakite config --- src/args.rs | 3 +++ src/functions/base.rs | 2 +- src/functions/unakite.rs | 6 +++--- src/internal/config.rs | 14 ++++++++------ src/main.rs | 1 + 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/args.rs b/src/args.rs index 3bdf1aa..2372aab 100644 --- a/src/args.rs +++ b/src/args.rs @@ -126,6 +126,9 @@ pub struct UnakiteArgs { /// device of boot device #[clap(long)] pub bootdev: String, + /// name of kernel to use + #[clap(long)] + pub kernel: String, } #[derive(Debug)] diff --git a/src/functions/base.rs b/src/functions/base.rs index a24fd5a..9bf0572 100755 --- a/src/functions/base.rs +++ b/src/functions/base.rs @@ -9,7 +9,7 @@ pub fn install_base_packages(kernel: String) { std::fs::create_dir_all("/mnt/etc").unwrap(); files::copy_file("/etc/pacman.conf", "/mnt/etc/pacman.conf"); if kernel.is_empty() { - kernel_to_install = "linux".to_string + kernel_to_install = "linux".to_string(); } else { match kernel.as_str() { "linux" => kernel_to_install = "linux".to_string(), diff --git a/src/functions/unakite.rs b/src/functions/unakite.rs index 35640dd..bacdc47 100644 --- a/src/functions/unakite.rs +++ b/src/functions/unakite.rs @@ -141,10 +141,10 @@ pub fn remount(root: &str, oldroot: &str, efi: bool, efidir: &str, bootdev: &str } } -pub fn setup_unakite(root: &str, oldroot: &str, efi: bool, efidir: &str, bootdev: &str) { +pub fn setup_unakite(root: &str, oldroot: &str, efi: bool, efidir: &str, bootdev: &str, kernel: &str) { log::debug!("Setting up Unakite"); remount(root, oldroot, efi, efidir, bootdev, true); - base::install_base_packages(); + base::install_base_packages(kernel.to_string()); base::genfstab(); locale::set_locale("en_US.UTF-8 UTF-8".to_string()); locale::set_timezone("Europe/Berlin"); // TODO: get the proper timezone @@ -203,4 +203,4 @@ pub fn setup_unakite(root: &str, oldroot: &str, efi: bool, efidir: &str, bootdev ), "Recreate grub.cfg in crystal" ); -} \ No newline at end of file +} diff --git a/src/internal/config.rs b/src/internal/config.rs index 1b7cd99..bbbf3b6 100755 --- a/src/internal/config.rs +++ b/src/internal/config.rs @@ -62,6 +62,7 @@ struct Unakite { oldroot: String, efidir: String, bootdev: String, + kernel: String, } pub fn read_config(configpath: PathBuf) { @@ -107,7 +108,8 @@ pub fn read_config(configpath: PathBuf) { &mut partitions, config.unakite.enable ); - base::install_base_packages(kernel); + let kerneltype = config.unakite.kernel.clone(); // Implemented because the borrow checker doesn't allow passing the value itself to the function + base::install_base_packages(kerneltype); base::genfstab(); println!(); log::info!("Installing bootloader : {}", config.bootloader.r#type); @@ -184,18 +186,18 @@ pub fn read_config(configpath: PathBuf) { log::info!("Setup unakite"); if config.partition.mode == PartitionMode::Auto && !config.partition.efi && config.unakite.enable && !config.partition.device.to_string().contains("nvme") { let root = PathBuf::from("/dev/").join(config.partition.device.as_str()); - unakite::setup_unakite(format!("{}2",root.to_str().unwrap()).as_str(), format!("{}3",root.to_str().unwrap()).as_str(), config.partition.efi, "/boot", format!("{}1",root.to_str().unwrap()).as_str()) + unakite::setup_unakite(format!("{}2",root.to_str().unwrap()).as_str(), format!("{}3",root.to_str().unwrap()).as_str(), config.partition.efi, "/boot", format!("{}1",root.to_str().unwrap()).as_str(), &config.unakite.kernel) } else if config.partition.mode == PartitionMode::Auto && config.partition.efi && config.unakite.enable && !config.partition.device.to_string().contains("nvme") { let root = PathBuf::from("/dev/").join(config.partition.device.as_str()); - unakite::setup_unakite(format!("{}2",root.to_str().unwrap()).as_str(), format!("{}3",root.to_str().unwrap()).as_str(), config.partition.efi, "/boot/efi", format!("{}1",root.to_str().unwrap()).as_str()) + unakite::setup_unakite(format!("{}2",root.to_str().unwrap()).as_str(), format!("{}3",root.to_str().unwrap()).as_str(), config.partition.efi, "/boot/efi", format!("{}1",root.to_str().unwrap()).as_str(), &config.unakite.kernel) } else if config.unakite.enable { - unakite::setup_unakite(&config.unakite.root, &config.unakite.oldroot, config.partition.efi, &config.unakite.efidir, &config.unakite.bootdev); + unakite::setup_unakite(&config.unakite.root, &config.unakite.oldroot, config.partition.efi, &config.unakite.efidir, &config.unakite.bootdev, &config.unakite.kernel); } else if config.partition.mode == PartitionMode::Auto && config.partition.efi && config.unakite.enable && config.partition.device.to_string().contains("nvme") { let root = PathBuf::from("/dev/").join(config.partition.device.as_str()); - unakite::setup_unakite(format!("{}p2",root.to_str().unwrap()).as_str(), format!("{}p3",root.to_str().unwrap()).as_str(), config.partition.efi, "/boot/efi", format!("{}p1",root.to_str().unwrap()).as_str()) + unakite::setup_unakite(format!("{}p2",root.to_str().unwrap()).as_str(), format!("{}p3",root.to_str().unwrap()).as_str(), config.partition.efi, "/boot/efi", format!("{}p1",root.to_str().unwrap()).as_str(), &config.unakite.kernel) } else if config.partition.mode == PartitionMode::Auto && !config.partition.efi && config.unakite.enable && config.partition.device.to_string().contains("nvme") { let root = PathBuf::from("/dev/").join(config.partition.device.as_str()); - unakite::setup_unakite(format!("{}p2",root.to_str().unwrap()).as_str(), format!("{}p3",root.to_str().unwrap()).as_str(), config.partition.efi, "/boot", format!("{}p1",root.to_str().unwrap()).as_str()) + unakite::setup_unakite(format!("{}p2",root.to_str().unwrap()).as_str(), format!("{}p3",root.to_str().unwrap()).as_str(), config.partition.efi, "/boot", format!("{}p1",root.to_str().unwrap()).as_str(), &config.unakite.kernel) } else { log::info!("Unakite disabled"); } diff --git a/src/main.rs b/src/main.rs index adee0c8..3d88ad0 100755 --- a/src/main.rs +++ b/src/main.rs @@ -68,6 +68,7 @@ fn main() { args.efi, &args.efidir, &args.bootdev, + &args.kernel, ); }, Command::Config { config } => { From bff226f95c086ea9a8edab46995b8646aa5f8752 Mon Sep 17 00:00:00 2001 From: UsernameSwift Date: Fri, 24 Jun 2022 21:27:32 -0400 Subject: [PATCH 2/8] Fixed a typo in the readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 221dc42..3d55f92 100755 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ jade genfstab jade locale colemak Europe/Berlin en_US.UTF-8 UTF-8 ``` -### configue network settings +### configure network settings ```sh # set the hostname to getcryst.al with ipv6 disabled jade networking getcryst.al From 7afdac632dafda50b3f6bbc5dbfe3131ea14ed5c Mon Sep 17 00:00:00 2001 From: UsernameSwift Date: Sat, 25 Jun 2022 09:13:53 -0400 Subject: [PATCH 3/8] Changed hostname generation --- src/functions/network.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/functions/network.rs b/src/functions/network.rs index f69f72e..43c4172 100755 --- a/src/functions/network.rs +++ b/src/functions/network.rs @@ -1,6 +1,9 @@ use crate::internal::*; -pub fn set_hostname(hostname: &str) { +pub fn set_hostname(mut hostname: &str) { + if hostname == "---------" { + hostname = "crystal"; + } println!("Setting hostname to {}", hostname); files::create_file("/mnt/etc/hostname"); files_eval( From e3d76f7312742471d2faf14f5977eeb90faa7758 Mon Sep 17 00:00:00 2001 From: UsernameSwift Date: Sat, 25 Jun 2022 09:18:56 -0400 Subject: [PATCH 4/8] Changed hostname generation --- src/functions/network.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/functions/network.rs b/src/functions/network.rs index 43c4172..15c7689 100755 --- a/src/functions/network.rs +++ b/src/functions/network.rs @@ -1,7 +1,7 @@ use crate::internal::*; pub fn set_hostname(mut hostname: &str) { - if hostname == "---------" { + if hostname == "" { hostname = "crystal"; } println!("Setting hostname to {}", hostname); From 57d892452a4f1d65b0428385b25c3882bf93bc51 Mon Sep 17 00:00:00 2001 From: UsernameSwift Date: Sat, 25 Jun 2022 09:40:56 -0400 Subject: [PATCH 5/8] Undid unnecessary network code --- src/functions/network.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/functions/network.rs b/src/functions/network.rs index 15c7689..f69f72e 100755 --- a/src/functions/network.rs +++ b/src/functions/network.rs @@ -1,9 +1,6 @@ use crate::internal::*; -pub fn set_hostname(mut hostname: &str) { - if hostname == "" { - hostname = "crystal"; - } +pub fn set_hostname(hostname: &str) { println!("Setting hostname to {}", hostname); files::create_file("/mnt/etc/hostname"); files_eval( From e8d1fce55b80242bef188c2f4bbbeea6d953456c Mon Sep 17 00:00:00 2001 From: UsernameSwift Date: Sat, 25 Jun 2022 10:09:21 -0400 Subject: [PATCH 6/8] Undid changes for unakite that weren't needed --- src/functions/unakite.rs | 4 ++-- src/internal/config.rs | 14 ++++++-------- src/main.rs | 1 - 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/functions/unakite.rs b/src/functions/unakite.rs index bacdc47..089d5b0 100644 --- a/src/functions/unakite.rs +++ b/src/functions/unakite.rs @@ -141,10 +141,10 @@ pub fn remount(root: &str, oldroot: &str, efi: bool, efidir: &str, bootdev: &str } } -pub fn setup_unakite(root: &str, oldroot: &str, efi: bool, efidir: &str, bootdev: &str, kernel: &str) { +pub fn setup_unakite(root: &str, oldroot: &str, efi: bool, efidir: &str, bootdev: &str) { log::debug!("Setting up Unakite"); remount(root, oldroot, efi, efidir, bootdev, true); - base::install_base_packages(kernel.to_string()); + base::install_base_packages("kernel".to_string()); base::genfstab(); locale::set_locale("en_US.UTF-8 UTF-8".to_string()); locale::set_timezone("Europe/Berlin"); // TODO: get the proper timezone diff --git a/src/internal/config.rs b/src/internal/config.rs index bbbf3b6..1b7cd99 100755 --- a/src/internal/config.rs +++ b/src/internal/config.rs @@ -62,7 +62,6 @@ struct Unakite { oldroot: String, efidir: String, bootdev: String, - kernel: String, } pub fn read_config(configpath: PathBuf) { @@ -108,8 +107,7 @@ pub fn read_config(configpath: PathBuf) { &mut partitions, config.unakite.enable ); - let kerneltype = config.unakite.kernel.clone(); // Implemented because the borrow checker doesn't allow passing the value itself to the function - base::install_base_packages(kerneltype); + base::install_base_packages(kernel); base::genfstab(); println!(); log::info!("Installing bootloader : {}", config.bootloader.r#type); @@ -186,18 +184,18 @@ pub fn read_config(configpath: PathBuf) { log::info!("Setup unakite"); if config.partition.mode == PartitionMode::Auto && !config.partition.efi && config.unakite.enable && !config.partition.device.to_string().contains("nvme") { let root = PathBuf::from("/dev/").join(config.partition.device.as_str()); - unakite::setup_unakite(format!("{}2",root.to_str().unwrap()).as_str(), format!("{}3",root.to_str().unwrap()).as_str(), config.partition.efi, "/boot", format!("{}1",root.to_str().unwrap()).as_str(), &config.unakite.kernel) + unakite::setup_unakite(format!("{}2",root.to_str().unwrap()).as_str(), format!("{}3",root.to_str().unwrap()).as_str(), config.partition.efi, "/boot", format!("{}1",root.to_str().unwrap()).as_str()) } else if config.partition.mode == PartitionMode::Auto && config.partition.efi && config.unakite.enable && !config.partition.device.to_string().contains("nvme") { let root = PathBuf::from("/dev/").join(config.partition.device.as_str()); - unakite::setup_unakite(format!("{}2",root.to_str().unwrap()).as_str(), format!("{}3",root.to_str().unwrap()).as_str(), config.partition.efi, "/boot/efi", format!("{}1",root.to_str().unwrap()).as_str(), &config.unakite.kernel) + unakite::setup_unakite(format!("{}2",root.to_str().unwrap()).as_str(), format!("{}3",root.to_str().unwrap()).as_str(), config.partition.efi, "/boot/efi", format!("{}1",root.to_str().unwrap()).as_str()) } else if config.unakite.enable { - unakite::setup_unakite(&config.unakite.root, &config.unakite.oldroot, config.partition.efi, &config.unakite.efidir, &config.unakite.bootdev, &config.unakite.kernel); + unakite::setup_unakite(&config.unakite.root, &config.unakite.oldroot, config.partition.efi, &config.unakite.efidir, &config.unakite.bootdev); } else if config.partition.mode == PartitionMode::Auto && config.partition.efi && config.unakite.enable && config.partition.device.to_string().contains("nvme") { let root = PathBuf::from("/dev/").join(config.partition.device.as_str()); - unakite::setup_unakite(format!("{}p2",root.to_str().unwrap()).as_str(), format!("{}p3",root.to_str().unwrap()).as_str(), config.partition.efi, "/boot/efi", format!("{}p1",root.to_str().unwrap()).as_str(), &config.unakite.kernel) + unakite::setup_unakite(format!("{}p2",root.to_str().unwrap()).as_str(), format!("{}p3",root.to_str().unwrap()).as_str(), config.partition.efi, "/boot/efi", format!("{}p1",root.to_str().unwrap()).as_str()) } else if config.partition.mode == PartitionMode::Auto && !config.partition.efi && config.unakite.enable && config.partition.device.to_string().contains("nvme") { let root = PathBuf::from("/dev/").join(config.partition.device.as_str()); - unakite::setup_unakite(format!("{}p2",root.to_str().unwrap()).as_str(), format!("{}p3",root.to_str().unwrap()).as_str(), config.partition.efi, "/boot", format!("{}p1",root.to_str().unwrap()).as_str(), &config.unakite.kernel) + unakite::setup_unakite(format!("{}p2",root.to_str().unwrap()).as_str(), format!("{}p3",root.to_str().unwrap()).as_str(), config.partition.efi, "/boot", format!("{}p1",root.to_str().unwrap()).as_str()) } else { log::info!("Unakite disabled"); } diff --git a/src/main.rs b/src/main.rs index 3d88ad0..adee0c8 100755 --- a/src/main.rs +++ b/src/main.rs @@ -68,7 +68,6 @@ fn main() { args.efi, &args.efidir, &args.bootdev, - &args.kernel, ); }, Command::Config { config } => { From 89afd9a6117bed88cfacae90cafb64535f341d3c Mon Sep 17 00:00:00 2001 From: UsernameSwift Date: Sat, 25 Jun 2022 10:14:37 -0400 Subject: [PATCH 7/8] Undid changes for unakite that weren't needed --- src/functions/unakite.rs | 2 +- src/internal/config.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/functions/unakite.rs b/src/functions/unakite.rs index 089d5b0..0391eb0 100644 --- a/src/functions/unakite.rs +++ b/src/functions/unakite.rs @@ -144,7 +144,7 @@ pub fn remount(root: &str, oldroot: &str, efi: bool, efidir: &str, bootdev: &str pub fn setup_unakite(root: &str, oldroot: &str, efi: bool, efidir: &str, bootdev: &str) { log::debug!("Setting up Unakite"); remount(root, oldroot, efi, efidir, bootdev, true); - base::install_base_packages("kernel".to_string()); + base::install_base_packages("linux".to_string()); base::genfstab(); locale::set_locale("en_US.UTF-8 UTF-8".to_string()); locale::set_timezone("Europe/Berlin"); // TODO: get the proper timezone diff --git a/src/internal/config.rs b/src/internal/config.rs index 1b7cd99..bdf217a 100755 --- a/src/internal/config.rs +++ b/src/internal/config.rs @@ -107,7 +107,7 @@ pub fn read_config(configpath: PathBuf) { &mut partitions, config.unakite.enable ); - base::install_base_packages(kernel); + base::install_base_packages(config.kernel); base::genfstab(); println!(); log::info!("Installing bootloader : {}", config.bootloader.r#type); From b489ac9bc30ebf76d43873738f8837c94889000b Mon Sep 17 00:00:00 2001 From: UsernameSwift Date: Sat, 25 Jun 2022 10:16:22 -0400 Subject: [PATCH 8/8] Undid changes for unakite that weren't needed --- src/args.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/args.rs b/src/args.rs index 2372aab..3bdf1aa 100644 --- a/src/args.rs +++ b/src/args.rs @@ -126,9 +126,6 @@ pub struct UnakiteArgs { /// device of boot device #[clap(long)] pub bootdev: String, - /// name of kernel to use - #[clap(long)] - pub kernel: String, } #[derive(Debug)]