Compare commits

..
3 Commits
Author SHA256 Message Date
kira eee7fd17d6 More work on install stage, testing locales stuff 2026-11-21 21:23:58 +01:00
kira 9d68343219 Locale stage code cleanup 2026-11-20 22:30:49 +01:00
kira d494dbe3c8 Dependencies update 2026-11-20 17:36:01 +01:00
4 changed files with 337 additions and 518 deletions

No files matched your search

Generated
+279 -428
View File
File diff suppressed because it is too large. Load diff
+39 -6
View File
@@ -141,7 +141,6 @@ const PKG_LIST_KDE_DESKTOP: [&str; 45] = [
"strawberry",
"mpv",
"ttf-unifont",
];
// const PKG_LIST_AWESOME_DESKTOP: [&str; 5] = [
@@ -247,10 +246,44 @@ fn init_disk(part_layout: &PartLayout, mnt_dir: &str) -> Result<(), ExecCommandE
Ok(())
}
fn config_stuff() -> Result<(), ExecCommandError> {
fn config_stuff(k_config: KiraConfig) -> Result<(), ExecCommandError> {
use std::fs::OpenOptions;
use std::io::Write;
const LOCALES_GEN_FILE_NAME: &str = "/etc/locale.gen";
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
let mut locale_file = OpenOptions::new()
.create(false)
.append(true)
.open(LOCALES_GEN_FILE_NAME)?;
writeln!(locale_file, "\n# Next lines is autogenerated by kira-installer")?;
// write lang
writeln!(locale_file, "{}", &lang_line)?;
// write formats
if lang_line != formats_line {
writeln!(locale_file, "{}", &formats_line)?;
}
// 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_") {
writeln!(locale_file, "en_US.UTF-8 UTF-8")?;
}
}
kira_system::exec_cmd_chroot(MNT_DIR, "locale-gen", &vec![])?;
//Simpler said.. it adds missing values for XKBLAYOUT=XX
//and XKBMODEL=XXXX to /etc/vconsole.conf
//kira_system::exec_cmd_chroot(chroot_dir, cmd, args)
Ok(())
@@ -353,10 +386,10 @@ async fn install_kde_desk_async(mnt_dir: String) -> Result<(), ExecCommandError>
blocking::unblock(move || kira_system::basestrap(&mnt_dir, &PKG_LIST_KDE_DESKTOP)).await
}
async fn config_stuff_async() -> Result<(), ExecCommandError> {
async fn config_stuff_async(k_config: KiraConfig) -> Result<(), ExecCommandError> {
use blocking;
log::info!("Configuring installed system...");
blocking::unblock(move || config_stuff()).await
blocking::unblock(move || config_stuff(k_config)).await
}
fn do_install(
@@ -366,7 +399,7 @@ fn do_install(
100,
|mut output: Sender<Result<(f32, String), ExecCommandError>>| async move {
//sleep(Duration::from_millis(10)).await;
let disk_layout = k_config.res_partition.unwrap().part_layout.clone();
let disk_layout = k_config.res_partition.as_ref().unwrap().part_layout.clone();
// creating gpt partition table
let res = init_disk_async(disk_layout.clone(), MNT_DIR.into()).await;
@@ -429,7 +462,7 @@ fn do_install(
}
// configuring system
let res = config_stuff_async().await;
let res = config_stuff_async(k_config.clone()).await;
let res_err = res.is_err();
output
.send(res.map(|_| (60.0f32, "Next step".into())))
+15 -80
View File
@@ -29,17 +29,12 @@ use rust_i18n::t;
use std::collections::HashMap;
const LOCALES_GEN_FILE_NAME: &str = "/etc/locale.gen";
const LOCALES_GEN_START_LINE: usize = 17;
// fn default_locale() -> (String, String) {
// ("C.UTF-8".to_string(), "UTF-8".to_string())
// }
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct LocaleData {
code: String,
charset: String,
description: Option<String>,
pub code: String,
pub charset: String,
pub description: Option<String>,
}
impl std::fmt::Display for LocaleData {
@@ -60,6 +55,18 @@ impl LocaleData {
description: Some("C locale".into()),
}
}
// creates text to be appended to locale.gen file
// in case of C locale outputs empty string
pub fn locale_gen_line(&self) -> String {
if self.code == "C.UTF-8" {
String::new()
}
else {
format!("{} {}", &self.code, &self.charset)
}
}
}
/// gets locales list from system "/etc/locale.gen" file
@@ -107,27 +114,9 @@ fn get_locales_blocking(filter_charset: Option<&str>) -> Result<Vec<LocaleData>,
charset: charset,
description: description,
});
// let subvol_name = &captured[1];
// let date_time = captured[2].to_string();
}
}
//if let Some(captured) = re.captures(&dir_name)
// let mut res: Vec<(String, String)> = file_content
// .split('\n')
// .skip(LOCALES_GEN_START_LINE)
// .filter_map(|l| {
// let trimmed = l.trim_start_matches('#').trim();
// if trimmed.len() > 0 {
// trimmed.split_once(' ')
// } else {
// None
// }
// })
// .map(|(loc, charset)| (loc.to_string(), charset.to_string()))
// .filter(|(_, chrs)| chrs == "UTF-8") // yeld only UTF-8 locales
// .collect();
res.push(LocaleData::default());
Ok(res)
@@ -154,42 +143,6 @@ fn get_loc_descr_blocking() -> Result<HashMap<String, String>, ExecCommandError>
}
}
// match Command::new("grep")
// .args(["-r", "title ", "/usr/share/i18n/locales/"])
// .output()
// {
// Ok(cmd_output) => {
// if cmd_output.status.success() {
// match String::from_utf8(cmd_output.stdout) {
// Ok(raw_str_list) => Ok(raw_str_list
// .split("\n")
// .filter_map(|s| s.trim().split_once(":title"))
// .filter_map(|(code_part, description_part)| {
// code_part.rsplit_once("/").and_then(|(_, loc_code)| {
// Some((
// loc_code.trim().to_string(),
// description_part.trim().trim_matches('\"').to_string(),
// ))
// })
// })
// .collect()),
// Err(ex) => Err(format!(
// "Exception while converting locales description to UTF8 {}",
// ex
// )),
// }
// } else {
// Err(format!(
// "Error getting locales description list: {}",
// String::from_utf8(cmd_output.stderr).unwrap_or("UNKNOWN".into())
// ))
// }
// }
// Err(ex) => Err(format!(
// "Exception while trying to get locales description {}",
// ex
// )),
// }
Ok(res)
}
@@ -225,25 +178,7 @@ impl LocaleStage {
.as_ref()
.and_then(|rw| Some(rw.loc_code.clone()));
// let raw_loc_codes = get_locales_codes_list_blocking().unwrap();
// let raw_loc_descr = get_locales_description_blocking().unwrap();
let locales: Vec<LocaleData> = get_locales_blocking(Some("UTF-8")).unwrap();
// .iter()
// .filter_map(|(code, _)| {
// code.split_once('.')
// .and_then(|(key_code, _)| Some((key_code, code)))
// })
// .filter_map(|(key_code, code)| {
// raw_loc_descr
// .get(key_code)
// .and_then(|descr| Some((code.clone(), descr.clone())))
// })
// .map(|(code, descr)| LocaleData {
// code: code,
// description: descr,
// })
// .collect();
// if we get lang code from wellcome stage, try to fing match with system locales
let lang_match = if let Some(lang) = maybe_lang
+4 -4
View File
@@ -20,7 +20,7 @@
*/
use iced::{Alignment, Task, widget};
use iced_moving_picture::widget::apng;
use iced_moving_picture::widget::moving_picture;
use log;
use rust_i18n::t;
@@ -52,7 +52,7 @@ pub struct NetworkStage {
internet_active: bool,
state: State,
use_net_settings: bool,
spinner_frames: apng::Frames,
spinner_frames: moving_picture::Frames,
logo_handle: widget::image::Handle,
status_message: String,
k_config: KiraConfig,
@@ -102,7 +102,7 @@ async fn check_connected() -> CheckResult {
impl NetworkStage {
pub fn new(k_config: KiraConfig) -> Self {
let spinner_frames =
apng::Frames::from_bytes(crate::kira_theming::get_spiner_bytes()).unwrap();
moving_picture::Frames::from_bytes(crate::kira_theming::get_spiner_bytes(), moving_picture::Kind::Apng).unwrap();
let logo_handle = widget::image::Handle::from_bytes(crate::kira_theming::get_logo_bytes());
@@ -188,7 +188,7 @@ impl NetworkStage {
let spinner_container = match self.state {
State::Cheking => widget::container(
apng(&self.spinner_frames)
moving_picture(&self.spinner_frames)
.width(iced::Pixels(128.0).into())
.height(iced::Pixels(128.0).into()),
),