Compare commits

..
2 Commits
Author SHA256 Message Date
kira 5597b56538 More work on install stage, locales/keyboard 2026-11-22 23:47:44 +01:00
kira ecc87066ad Fix for exec_cmd_chroot function 2026-11-21 22:55:53 +01:00
4 changed files with 63 additions and 26 deletions

No files matched your search

+1
View File
@@ -189,6 +189,7 @@ pub fn exec_cmd_chroot(
args: &Vec<&str>, args: &Vec<&str>,
) -> Result<(), ExecCommandError> { ) -> Result<(), ExecCommandError> {
let mut cmd_args: Vec<&str> = Vec::new(); let mut cmd_args: Vec<&str> = Vec::new();
cmd_args.push(chroot_dir);
cmd_args.push(cmd); cmd_args.push(cmd);
cmd_args.extend(args); cmd_args.extend(args);
exec_command("artix-chroot", &cmd_args) exec_command("artix-chroot", &cmd_args)
+56 -20
View File
@@ -18,7 +18,7 @@
Actual installation script. Actual installation script.
*/ */
use std::path::Path; use std::{fs, path::Path};
use crate::{ use crate::{
kira_disk_layout::{self, BlkDev, FSType, PartInfo, PartLayout, PartRole}, kira_disk_layout::{self, BlkDev, FSType, PartInfo, PartLayout, PartRole},
@@ -43,6 +43,8 @@ const MNT_DIR: &str = "/mnt/inst_root";
const ROOT_PARTLABEL_DEV: &str = "/dev/disk/by-partlabel/bee-root"; const ROOT_PARTLABEL_DEV: &str = "/dev/disk/by-partlabel/bee-root";
const EFI_PARTLABLE_DEV: &str = "/dev/disk/by-partlabel/bee-efi"; const EFI_PARTLABLE_DEV: &str = "/dev/disk/by-partlabel/bee-efi";
const SWAP_PARTLABLE_DEV: &str = "/dev/disk/by-partlabel/bee-swap"; const SWAP_PARTLABLE_DEV: &str = "/dev/disk/by-partlabel/bee-swap";
const CONSOLE_FONT: &str = "ter-v24n";
/// ///
/// List of packages for desktop (elogind-dinit no need for headles system) /// List of packages for desktop (elogind-dinit no need for headles system)
/// ///
@@ -246,41 +248,75 @@ fn init_disk(part_layout: &PartLayout, mnt_dir: &str) -> Result<(), ExecCommandE
Ok(()) Ok(())
} }
fn config_stuff(k_config: KiraConfig) -> Result<(), ExecCommandError> { ///
/// Writes locales from loc_lines to locale.gen file passed in loc_gen_file_path
/// Checks if locales from loc_lines defined in locale.gen
///
fn locale_gen_write(
loc_gen_file_path: &str,
loc_lines: &Vec<String>,
) -> Result<(), ExecCommandError> {
use std::fs::OpenOptions; use std::fs::OpenOptions;
use std::io::Write; use std::io::Write;
const LOCALES_GEN_FILE_NAME: &str = "/etc/locale.gen"; // need this to check for locales existance
let loc_gen_content = fs::read_to_string(loc_gen_file_path)?;
log::info!("Generating fstab...");
kira_system::fstabgen(MNT_DIR)?;
log::info!("Configuring locales...");
let loc_data = k_config.res_locale.as_ref().unwrap();
{
let lang_line = loc_data.lang_locale.locale_gen_line();
let formats_line = loc_data.formats_locale.locale_gen_line();
// Open locale.gen file in append mode // Open locale.gen file in append mode
let mut locale_file = OpenOptions::new() let mut locale_file = OpenOptions::new()
.create(false) .create(false)
.append(true) .append(true)
.open(LOCALES_GEN_FILE_NAME)?; .open(loc_gen_file_path)?;
writeln!(locale_file, "\n# Next lines is autogenerated by kira-installer")?; writeln!(
// write lang locale_file,
writeln!(locale_file, "{}", &lang_line)?; "\n# Next lines is autogenerated by Kira Installer"
// write formats )?;
if lang_line != formats_line { for loc in loc_lines {
writeln!(locale_file, "{}", &formats_line)?; // check if locale defined
if loc_gen_content.contains(loc) {
writeln!(locale_file, "{}", loc)?;
log::info!("Added ({}) locale.", loc);
} else {
// if not defined write comment on this matter
log::info!("Locale ({}) is not defined in locale.gen file.", loc);
writeln!(locale_file, "# Missing: {}", loc)?;
} }
}
Ok(())
}
fn config_stuff(k_config: KiraConfig) -> Result<(), ExecCommandError> {
use std::fs::OpenOptions;
use std::io::Write;
let loc_gen_fn = format!("{}/etc/locale.gen", MNT_DIR);
log::info!("Generating fstab...");
kira_system::fstabgen(MNT_DIR)?;
log::info!("Configuring locales...");
{
let loc_data = k_config.res_locale.as_ref().unwrap();
let lang_line = loc_data.lang_locale.locale_gen_line();
let formats_line = loc_data.formats_locale.locale_gen_line();
let mut loc_lines: Vec<String> = Vec::new();
// if selected locale is not en, we will add en_US.UTF-8 UTF-8 to locales.gen // if selected locale is not en, we will add en_US.UTF-8 UTF-8 to locales.gen
if !lang_line.starts_with("en_") && !formats_line.starts_with("en_") { if !lang_line.starts_with("en_") && !formats_line.starts_with("en_") {
writeln!(locale_file, "en_US.UTF-8 UTF-8")?; loc_lines.push("en_US.UTF-8 UTF-8".into());
} }
// write formats locale if it is different from lang locale
if lang_line != formats_line {
loc_lines.push(formats_line);
}
loc_lines.push(lang_line);
locale_gen_write(&loc_gen_fn, &loc_lines)?;
} }
kira_system::exec_cmd_chroot(MNT_DIR, "locale-gen", &vec![])?; kira_system::exec_cmd_chroot(MNT_DIR, "locale-gen", &vec![])?;
log::info!("Kayboard conf: {}", k_config.res_keyboard.as_ref().unwrap());
//Simpler said.. it adds missing values for XKBLAYOUT=XX //Simpler said.. it adds missing values for XKBLAYOUT=XX
//and XKBMODEL=XXXX to /etc/vconsole.conf //and XKBMODEL=XXXX to /etc/vconsole.conf
+6
View File
@@ -130,6 +130,12 @@ pub struct KeyboardStageResult {
pub keyboard_layout: KeyboarLayout, pub keyboard_layout: KeyboarLayout,
} }
impl std::fmt::Display for KeyboardStageResult {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "keyboard_model: {} | keyboard_layout: {}", &self.keyboard_model, &self.keyboard_layout)
}
}
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub enum Message { pub enum Message {
SelectKeyboardModel(KeyboarModel), SelectKeyboardModel(KeyboarModel),
-6
View File
@@ -59,14 +59,8 @@ impl LocaleData {
// creates text to be appended to locale.gen file // creates text to be appended to locale.gen file
// in case of C locale outputs empty string // in case of C locale outputs empty string
pub fn locale_gen_line(&self) -> String { pub fn locale_gen_line(&self) -> String {
if self.code == "C.UTF-8" {
String::new()
}
else {
format!("{} {}", &self.code, &self.charset) format!("{} {}", &self.code, &self.charset)
} }
}
} }
/// gets locales list from system "/etc/locale.gen" file /// gets locales list from system "/etc/locale.gen" file