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

@ -12,3 +12,4 @@ steps:
from_secret: pacco_token from_secret: pacco_token
KEY: KEY:
from_secret: navos_key from_secret: navos_key

View file

@ -6,7 +6,9 @@ pub fn get_args() -> clap::ArgMatches {
.subcommand( .subcommand(
command!("create-iso") command!("create-iso")
.about("Create a new installation medium ISO") .about("Create a new installation medium ISO")
.arg(arg!(--without_gui "Create ISO with just terminal")), .arg(arg!(--without_gui "Create ISO with just terminal"))
.arg(arg!(--kb_layout <LAYOUT> "Create ISO with this keyboard layout"))
.arg(arg!(--kb_variant <VARIANT> "Create ISO with this keyboard layout variant")),
) )
.subcommand( .subcommand(
command!() command!()

View file

@ -1,9 +1,19 @@
use crate::{ use crate::{
install::{str_vec, uncomment_tag}, 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() { if !is_root() {
eprintln!("Error: You need root to create an ISO"); eprintln!("Error: You need root to create an ISO");
std::process::exit(1); std::process::exit(1);
@ -17,10 +27,18 @@ pub fn create_iso(without_gui: bool) {
if without_gui { if without_gui {
std::fs::remove_file("./iso/airootfs/etc/systemd/system/display-manager.service").unwrap(); std::fs::remove_file("./iso/airootfs/etc/systemd/system/display-manager.service").unwrap();
} else { } else {
println!("Adding GUI packages"); print_status("Adding GUI packages");
uncomment_tag("#gui: ", "./iso/packages.x86_64"); 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(); std::fs::create_dir_all("./work").unwrap();
let mount_cmd = str_vec(vec![ let mount_cmd = str_vec(vec![

View file

@ -101,6 +101,9 @@ pub fn install(conf: InstallConfig) {
setup_navos(); setup_navos();
install_pkgs(&pkg::DESKTOP_PKG); install_pkgs(&pkg::DESKTOP_PKG);
print_status("Enable SDDM"); print_status("Enable SDDM");
// TODO : Setup KDE Keyboard Layout
std::os::unix::fs::symlink( std::os::unix::fs::symlink(
"/usr/lib/systemd/system/sddm.service", "/usr/lib/systemd/system/sddm.service",
"/mnt/etc/systemd/system/display-manager.service", "/mnt/etc/systemd/system/display-manager.service",

View file

@ -82,7 +82,10 @@ fn main() {
match args.subcommand() { match args.subcommand() {
Some(("create-iso", iso_args)) => { Some(("create-iso", iso_args)) => {
let without_gui = iso_args.get_flag("without_gui"); let without_gui = iso_args.get_flag("without_gui");
create_iso(without_gui); let kb_layout_default = "en".to_string();
let kb_layout: &String = iso_args.get_one("LAYOUT").unwrap_or(&kb_layout_default);
let kb_variant: Option<&str> = iso_args.get_one("LAYOUT").map(|x: &String| x.as_str());
create_iso(without_gui, &kb_layout, kb_variant);
std::process::exit(0); std::process::exit(0);
} }
Some(("create-tar", _)) => { Some(("create-tar", _)) => {
@ -115,6 +118,11 @@ fn main() {
unimplemented!() unimplemented!()
} }
Some(("install", install_args)) => { Some(("install", install_args)) => {
if !is_root() {
eprintln!("Error: You need root to install");
std::process::exit(1);
}
let config_file: &String = install_args.get_one("config").unwrap(); let config_file: &String = install_args.get_one("config").unwrap();
let config_content = std::fs::read_to_string(config_file); let config_content = std::fs::read_to_string(config_file);