SHA256
Compare commits
2
Commits
| Author | SHA256 | Date | |
|---|---|---|---|
|
|
740bbdb4d8 | ||
|
|
7c57193bf1 |
No files matched your search
@@ -314,14 +314,63 @@ fn config_stuff(k_config: KiraConfig) -> Result<(), ExecCommandError> {
|
|||||||
|
|
||||||
locale_gen_write(&loc_gen_fn, &loc_lines)?;
|
locale_gen_write(&loc_gen_fn, &loc_lines)?;
|
||||||
}
|
}
|
||||||
|
// Running locale-gen
|
||||||
kira_system::exec_cmd_chroot(MNT_DIR, "locale-gen", &vec![])?;
|
kira_system::exec_cmd_chroot(MNT_DIR, "locale-gen", &vec![])?;
|
||||||
|
|
||||||
|
log::info!("Konfiguring keyboard...");
|
||||||
log::info!("Kayboard conf: {}", k_config.res_keyboard.as_ref().unwrap());
|
log::info!("Kayboard conf: {}", k_config.res_keyboard.as_ref().unwrap());
|
||||||
|
|
||||||
//Simpler said.. it adds missing values for XKBLAYOUT=XX
|
// dinit reads /etc/vconsole.conf
|
||||||
//and XKBMODEL=XXXX to /etc/vconsole.conf
|
// but
|
||||||
|
// config /etc/conf.d/keymaps as a backup
|
||||||
|
log::info!("Writing /etc/conf.d/keymaps");
|
||||||
|
let kbd_conf = k_config.res_keyboard.as_ref().unwrap();
|
||||||
|
let console_keymap = kbd_conf.crazy_bonker_console_keymap();
|
||||||
|
fs::write(
|
||||||
|
"/etc/conf.d/keymaps",
|
||||||
|
format!(
|
||||||
|
"# Autogeneradet by Kira Installer\nkeymap={}",
|
||||||
|
console_keymap
|
||||||
|
),
|
||||||
|
)?;
|
||||||
|
|
||||||
|
log::info!("Writing /etc/vconsole.conf");
|
||||||
|
let vconsole_content = format!(
|
||||||
|
"Autogeneradet by Kira Installer \
|
||||||
|
FONT={} \
|
||||||
|
KEYMAP={} \
|
||||||
|
XKBMODEL={} \
|
||||||
|
XKBLAYOUT={} \
|
||||||
|
XKBVARIANT={}\n",
|
||||||
|
CONSOLE_FONT,
|
||||||
|
&console_keymap,
|
||||||
|
kbd_conf.xkb_model(),
|
||||||
|
kbd_conf.xkb_layout(),
|
||||||
|
kbd_conf.xkb_variant()
|
||||||
|
);
|
||||||
|
fs::write("/etc/vconsole.conf", vconsole_content)?;
|
||||||
|
|
||||||
//kira_system::exec_cmd_chroot(chroot_dir, cmd, args)
|
//kira_system::exec_cmd_chroot(chroot_dir, cmd, args)
|
||||||
|
|
||||||
|
//locale-gen
|
||||||
|
//Configure the system clock
|
||||||
|
|
||||||
|
// Set the time zone:
|
||||||
|
// ln -sf /usr/share/zoneinfo/Region/City /etc/localtime
|
||||||
|
// Run hwclock to generate /etc/adjtime:
|
||||||
|
// hwclock --systohc
|
||||||
|
log::info!("Configuring timezone...");
|
||||||
|
let time_conf = k_config.res_timezone.as_ref().unwrap();
|
||||||
|
let tz_file_name = time_conf.time_zone.tz_file_name();
|
||||||
|
kira_system::exec_cmd_chroot(
|
||||||
|
MNT_DIR,
|
||||||
|
"ln",
|
||||||
|
&vec!["-sf", tz_file_name.as_ref(), "/etc/localtime"],
|
||||||
|
)?;
|
||||||
|
// Run hwclock to generate /etc/adjtime:
|
||||||
|
// hwclock --systohc
|
||||||
|
kira_system::exec_cmd_chroot(MNT_DIR, "hwclock", &vec!["--systohc"])?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -130,9 +130,59 @@ pub struct KeyboardStageResult {
|
|||||||
pub keyboard_layout: KeyboarLayout,
|
pub keyboard_layout: KeyboarLayout,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl KeyboardStageResult {
|
||||||
|
///
|
||||||
|
/// doing crazy guess of console keymap
|
||||||
|
///
|
||||||
|
pub fn crazy_bonker_console_keymap(&self) -> String {
|
||||||
|
const LAT_MAP: [&str; 13] = [
|
||||||
|
"us", "fr", "it", "es", "pt", "pl", "cz", "no", "se", "fi", "dk", "nl", "hu",
|
||||||
|
];
|
||||||
|
const DE_MAP: &str = "de-latin1-nodeadkeys";
|
||||||
|
const DEAFULT_MAP: &str = "us";
|
||||||
|
|
||||||
|
let layout = self.keyboard_layout.layout.layout.as_str();
|
||||||
|
let model = self.keyboard_model.model.as_str();
|
||||||
|
if layout == "de" {
|
||||||
|
DE_MAP.to_string()
|
||||||
|
} else if LAT_MAP.contains(&layout) {
|
||||||
|
layout.to_string()
|
||||||
|
}
|
||||||
|
// if xkb_layout is non-Latin
|
||||||
|
else if model == "pc105" {
|
||||||
|
DE_MAP.to_string()
|
||||||
|
} else {
|
||||||
|
DEAFULT_MAP.to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn xkb_model(&self) -> String {
|
||||||
|
self.keyboard_model.model.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn xkb_layout(&self) -> String {
|
||||||
|
self.keyboard_layout.layout.layout.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Returns string variant or eppty string if variant is "default"
|
||||||
|
///
|
||||||
|
pub fn xkb_variant(&self) -> String {
|
||||||
|
if self.keyboard_layout.variant.variant == "default" {
|
||||||
|
"".into()
|
||||||
|
} else {
|
||||||
|
self.keyboard_layout.variant.variant.clone()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl std::fmt::Display for KeyboardStageResult {
|
impl std::fmt::Display for KeyboardStageResult {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
write!(f, "keyboard_model: {} | keyboard_layout: {}", &self.keyboard_model, &self.keyboard_layout)
|
write!(
|
||||||
|
f,
|
||||||
|
"keyboard_model: {} | keyboard_layout: {}",
|
||||||
|
&self.keyboard_model, &self.keyboard_layout
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ use crate::stage::{KiraConfig, StageAction};
|
|||||||
use iced::{Alignment, Length, widget};
|
use iced::{Alignment, Length, widget};
|
||||||
use log;
|
use log;
|
||||||
use rust_i18n::t;
|
use rust_i18n::t;
|
||||||
use std::{collections::HashMap, fs, path::Path};
|
use std::{collections::HashMap, path::Path};
|
||||||
|
|
||||||
use crate::kira_scroll_list;
|
use crate::kira_scroll_list;
|
||||||
use crate::kira_system;
|
use crate::kira_system;
|
||||||
@@ -42,6 +42,14 @@ impl TimeZoneData {
|
|||||||
zone: zone.trim_start_matches('/').into(),
|
zone: zone.trim_start_matches('/').into(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Returns full path to timezone file
|
||||||
|
/// Example: "/usr/share/zoneinfo/Region/City"
|
||||||
|
///
|
||||||
|
pub fn tz_file_name(&self) -> String {
|
||||||
|
format!("/usr/share/zoneinfo/{}/{}", &self.region, &self.zone)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Display for TimeZoneData {
|
impl std::fmt::Display for TimeZoneData {
|
||||||
|
|||||||
Reference in new issue
Block a user