add installer kb options
All checks were successful
ci/woodpecker/push/build Pipeline was successful

This commit is contained in:
JMARyA 2024-12-29 11:43:52 +01:00
parent db1acbbd3c
commit 6b3314d032
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
5 changed files with 37 additions and 5 deletions

View file

@ -1,9 +1,19 @@
use crate::{
install::{str_vec, uncomment_tag},
is_root, run_command,
is_root, print_status, run_command,
};
pub fn create_iso(without_gui: bool) {
pub fn build_kxkbrc(layout: &str, variant: Option<&str>) -> String {
let mut res = String::from("[Layout]\nUse=true\n");
res.push_str(&format!("LayoutList={layout}\n"));
if let Some(variant) = variant {
res.push_str(&format!("VariantList={variant}\n"));
}
res
}
pub fn create_iso(without_gui: bool, kb_layout: &str, kb_variant: Option<&str>) {
if !is_root() {
eprintln!("Error: You need root to create an ISO");
std::process::exit(1);
@ -17,10 +27,18 @@ pub fn create_iso(without_gui: bool) {
if without_gui {
std::fs::remove_file("./iso/airootfs/etc/systemd/system/display-manager.service").unwrap();
} else {
println!("Adding GUI packages");
print_status("Adding GUI packages");
uncomment_tag("#gui: ", "./iso/packages.x86_64");
}
print_status("Setting keyboard layout");
std::fs::create_dir("./iso/airootfs/etc/skel/.config").unwrap();
std::fs::write(
"./iso/airootfs/etc/skel/.config/kxkbrc",
build_kxkbrc(kb_layout, kb_variant),
)
.unwrap();
std::fs::create_dir_all("./work").unwrap();
let mount_cmd = str_vec(vec![