From b78301cb3255ca8f2c24b80559f6c69ed9e533b6 Mon Sep 17 00:00:00 2001 From: axtlos Date: Tue, 21 Jun 2022 16:13:18 +0200 Subject: [PATCH] allow different kernels for installation --- PKGBUILD | 4 ++-- src/args.rs | 10 ++++++++-- src/functions/base.rs | 20 ++++++++++++++++++-- src/functions/users.rs | 2 +- src/internal/config.rs | 3 ++- src/main.rs | 6 ++++-- 6 files changed, 35 insertions(+), 10 deletions(-) diff --git a/PKGBUILD b/PKGBUILD index 34c4565..0175da4 100755 --- a/PKGBUILD +++ b/PKGBUILD @@ -1,8 +1,8 @@ # Maintainer: Matt C pkgname=jade -pkgver=1.0.4 -pkgrel=2 +pkgver=1.0.5 +pkgrel=1 pkgdesc="Scriptable backend & TUI Installer for Crystal Linux" arch=('x86_64') url="https://git.tar.black/crystal/programs/jade" diff --git a/src/args.rs b/src/args.rs index 004898f..3bdf1aa 100644 --- a/src/args.rs +++ b/src/args.rs @@ -18,9 +18,9 @@ pub enum Command { #[clap(name = "partition")] Partition(PartitionArgs), - /// Install base packages + /// Install base packages, optionally define a different kernel #[clap(name = "install-base")] - InstallBase, + InstallBase(InstallBaseArgs), /// Generate fstab file for mounting partitions #[clap(name = "genfstab")] @@ -103,6 +103,12 @@ pub struct PartitionArgs { pub partitions: Vec, } +#[derive(Debug, Args)] +pub struct InstallBaseArgs { + #[clap(long)] + pub kernel: String, +} + #[derive(Debug, Args)] pub struct UnakiteArgs { /// root device of unakite diff --git a/src/functions/base.rs b/src/functions/base.rs index 04990c6..a24fd5a 100755 --- a/src/functions/base.rs +++ b/src/functions/base.rs @@ -2,13 +2,29 @@ use crate::internal::exec::*; use crate::internal::*; use crate::internal::files::append_file; use std::path::PathBuf; +use log::warn; -pub fn install_base_packages() { +pub fn install_base_packages(kernel: String) { + let mut kernel_to_install: String = String::new(); 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 + } else { + match kernel.as_str() { + "linux" => kernel_to_install = "linux".to_string(), + "linux-lts" => kernel_to_install = "linux-lts".to_string(), + "linux-zen" => kernel_to_install = "linux-zen".to_string(), + "linux-hardened" => kernel_to_install = "linux-hardened".to_string(), + _ => { + warn!("Unknown kernel: {}, using default instead", kernel); + kernel_to_install = "linux".to_string(); + } + } + } install::install(vec![ "base", - "linux", + kernel_to_install.as_str(), "linux-firmware", "systemd-sysvcompat", "networkmanager", diff --git a/src/functions/users.rs b/src/functions/users.rs index 6f3bff0..7dfb7f3 100755 --- a/src/functions/users.rs +++ b/src/functions/users.rs @@ -54,4 +54,4 @@ pub fn root_pass(root_pass: &str) { ), "set root password", ); -} +} \ No newline at end of file diff --git a/src/internal/config.rs b/src/internal/config.rs index 11c3f41..f54d5d2 100755 --- a/src/internal/config.rs +++ b/src/internal/config.rs @@ -7,6 +7,7 @@ use std::path::PathBuf; #[derive(Serialize, Deserialize)] struct Config { + kernel: String, partition: Partition, bootloader: Bootloader, locale: Locale, @@ -106,7 +107,7 @@ pub fn read_config(configpath: PathBuf) { &mut partitions, config.unakite.enable ); - base::install_base_packages(); + base::install_base_packages(kernel); base::genfstab(); println!(); log::info!("Installing bootloader : {}", config.bootloader.r#type); diff --git a/src/main.rs b/src/main.rs index ecb4750..adee0c8 100755 --- a/src/main.rs +++ b/src/main.rs @@ -16,8 +16,10 @@ fn main() { let mut partitions = args.partitions; partition::partition(args.device, args.mode, args.efi, &mut partitions, args.unakite); } - Command::InstallBase => { - base::install_base_packages(); + Command::InstallBase(args) => { + base::install_base_packages( + args.kernel, + ); } Command::GenFstab => { base::genfstab();