SHA256
Compare commits
2
Commits
d68ee36afa
...
7e72abb528
| Author | SHA256 | Date | |
|---|---|---|---|
|
|
7e72abb528 | ||
|
|
841090d3d6 |
No files matched your search
Generated
+7
@@ -1841,6 +1841,7 @@ dependencies = [
|
|||||||
"iced_moving_picture",
|
"iced_moving_picture",
|
||||||
"log",
|
"log",
|
||||||
"rand 0.10.3",
|
"rand 0.10.3",
|
||||||
|
"regex-lite",
|
||||||
"rust-i18n",
|
"rust-i18n",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
@@ -3113,6 +3114,12 @@ dependencies = [
|
|||||||
"regex-syntax",
|
"regex-syntax",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "regex-lite"
|
||||||
|
version = "0.1.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cab834c73d247e67f4fae452806d17d3c7501756d98c8808d7c9c7aa7d18f973"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex-syntax"
|
name = "regex-syntax"
|
||||||
version = "0.8.11"
|
version = "0.8.11"
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ rust-i18n = "4"
|
|||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
time-format = "1.2"
|
time-format = "1.2"
|
||||||
|
regex-lite = "0.1"
|
||||||
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
rand = "0.10"
|
rand = "0.10"
|
||||||
|
|||||||
+1
-1
@@ -115,7 +115,7 @@ pub fn exec_command(cmd: &str, args: &Vec<&str>) -> Result<(), ExecCommandError>
|
|||||||
|
|
||||||
/// exec given sommand with arguments, returning stdout parsed to UTF-8 string
|
/// exec given sommand with arguments, returning stdout parsed to UTF-8 string
|
||||||
/// capturing stderr in case or failure
|
/// capturing stderr in case or failure
|
||||||
fn exec_command_out(cmd: &str, args: &Vec<&str>) -> Result<String, ExecCommandError> {
|
pub fn exec_command_out(cmd: &str, args: &Vec<&str>) -> Result<String, ExecCommandError> {
|
||||||
let out = Command::new(cmd).args(args).output()?;
|
let out = Command::new(cmd).args(args).output()?;
|
||||||
if out.status.success() {
|
if out.status.success() {
|
||||||
Ok(String::from_utf8(out.stdout)?)
|
Ok(String::from_utf8(out.stdout)?)
|
||||||
|
|||||||
@@ -38,9 +38,11 @@ use iced::{Color, Length, futures::channel::mpsc::Sender, widget::container};
|
|||||||
use log;
|
use log;
|
||||||
use rust_i18n::t;
|
use rust_i18n::t;
|
||||||
|
|
||||||
const EFI_BOOT_MOUNT_POINT: &str = "/beefi";
|
const EFI_BOOT_MOUNT_POINT: &str = "/mnt/inst_root/beefi";
|
||||||
const MNT_DIR: &str = "/mnt/inst_root";
|
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 SWAP_PARTLABLE_DEV: &str = "/dev/disk/by-partlabel/bee-swap";
|
||||||
///
|
///
|
||||||
/// List of packages for desktop (elogind-dinit no need for headles system)
|
/// List of packages for desktop (elogind-dinit no need for headles system)
|
||||||
///
|
///
|
||||||
@@ -93,7 +95,7 @@ const PKG_LIST_CORE_DESKTOP: [&str; 19] = [
|
|||||||
|
|
||||||
// const PKG_LIST_MEDIA_DESKTOP: [&str; 4] = ["ffmpeg", "ffmpeg4.4", "strawberry", "mpv"];
|
// const PKG_LIST_MEDIA_DESKTOP: [&str; 4] = ["ffmpeg", "ffmpeg4.4", "strawberry", "mpv"];
|
||||||
|
|
||||||
const PKG_LIST_KDE_DESKTOP: [&str; 44] = [
|
const PKG_LIST_KDE_DESKTOP: [&str; 45] = [
|
||||||
"wireless-regdb",
|
"wireless-regdb",
|
||||||
"wpa_supplicant",
|
"wpa_supplicant",
|
||||||
"wpa_supplicant-dinit",
|
"wpa_supplicant-dinit",
|
||||||
@@ -138,6 +140,8 @@ const PKG_LIST_KDE_DESKTOP: [&str; 44] = [
|
|||||||
"ffmpeg4.4",
|
"ffmpeg4.4",
|
||||||
"strawberry",
|
"strawberry",
|
||||||
"mpv",
|
"mpv",
|
||||||
|
"ttf-unifont",
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
// const PKG_LIST_AWESOME_DESKTOP: [&str; 5] = [
|
// const PKG_LIST_AWESOME_DESKTOP: [&str; 5] = [
|
||||||
@@ -149,7 +153,7 @@ const PKG_LIST_KDE_DESKTOP: [&str; 44] = [
|
|||||||
// ];
|
// ];
|
||||||
|
|
||||||
/// Creates new GPT table and partitions from PartLayout
|
/// Creates new GPT table and partitions from PartLayout
|
||||||
pub fn create_partitions(part_layout: &PartLayout) -> Result<(), ExecCommandError> {
|
fn create_partitions(part_layout: &PartLayout) -> Result<(), ExecCommandError> {
|
||||||
log::info!("Creating GPT part table...");
|
log::info!("Creating GPT part table...");
|
||||||
kira_system::parted_init_gpt_part_table(&part_layout.dev)?;
|
kira_system::parted_init_gpt_part_table(&part_layout.dev)?;
|
||||||
log::info!("Start to create partitions...");
|
log::info!("Start to create partitions...");
|
||||||
@@ -165,7 +169,7 @@ pub fn create_partitions(part_layout: &PartLayout) -> Result<(), ExecCommandErro
|
|||||||
/// Unlock it if encryption used
|
/// Unlock it if encryption used
|
||||||
/// Mount to specified dir
|
/// Mount to specified dir
|
||||||
/// creates subvolumes bzz/root bzz/home
|
/// creates subvolumes bzz/root bzz/home
|
||||||
pub fn bcachefs_init(
|
fn bcachefs_init(
|
||||||
dev_name: &str,
|
dev_name: &str,
|
||||||
mnt_dir: &str,
|
mnt_dir: &str,
|
||||||
password: Option<String>,
|
password: Option<String>,
|
||||||
@@ -182,7 +186,7 @@ pub fn bcachefs_init(
|
|||||||
std::fs::create_dir(format!("{}{}", mnt_dir, "/bzz-snaps"))?;
|
std::fs::create_dir(format!("{}{}", mnt_dir, "/bzz-snaps"))?;
|
||||||
|
|
||||||
// Creating boot directory for efi mounting
|
// Creating boot directory for efi mounting
|
||||||
std::fs::create_dir_all(format!("{}{}", mnt_dir, EFI_BOOT_MOUNT_POINT))?;
|
std::fs::create_dir_all(EFI_BOOT_MOUNT_POINT)?;
|
||||||
|
|
||||||
// create subvolumes
|
// create subvolumes
|
||||||
log::info!("Creating subvolumes...");
|
log::info!("Creating subvolumes...");
|
||||||
@@ -194,7 +198,7 @@ pub fn bcachefs_init(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init_disk(part_layout: &PartLayout, mnt_dir: &str) -> Result<(), ExecCommandError> {
|
fn init_disk(part_layout: &PartLayout, mnt_dir: &str) -> Result<(), ExecCommandError> {
|
||||||
let mnt_path = Path::new(mnt_dir);
|
let mnt_path = Path::new(mnt_dir);
|
||||||
log::info!("Cheking is MNT path exists: {}", mnt_dir);
|
log::info!("Cheking is MNT path exists: {}", mnt_dir);
|
||||||
if !mnt_path.exists() {
|
if !mnt_path.exists() {
|
||||||
@@ -309,6 +313,12 @@ pub fn mount_and_init_root(
|
|||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log::info!("Mounting EFI partition");
|
||||||
|
kira_system::mount_fs(EFI_PARTLABLE_DEV, EFI_BOOT_MOUNT_POINT)?;
|
||||||
|
|
||||||
|
log::info!("Attaching swap partition");
|
||||||
|
kira_system::swapon(SWAP_PARTLABLE_DEV)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+138
-74
@@ -19,10 +19,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
kira_system::{self, ExecCommandError},
|
||||||
kira_theming,
|
kira_theming,
|
||||||
stage::{KiraConfig, StageAction},
|
stage::{KiraConfig, StageAction},
|
||||||
};
|
};
|
||||||
use iced::{Alignment, widget};
|
use iced::{Alignment, widget};
|
||||||
|
use regex_lite::Regex;
|
||||||
use rust_i18n::t;
|
use rust_i18n::t;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
@@ -36,12 +38,17 @@ const LOCALES_GEN_START_LINE: usize = 17;
|
|||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub struct LocaleData {
|
pub struct LocaleData {
|
||||||
code: String,
|
code: String,
|
||||||
description: String,
|
charset: String,
|
||||||
|
description: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Display for LocaleData {
|
impl std::fmt::Display for LocaleData {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
write!(f, "{} ({})", self.code, self.description)
|
if let Some(descr) = &self.description {
|
||||||
|
write!(f, "{} ({})", self.code, descr)
|
||||||
|
} else {
|
||||||
|
write!(f, "{}", self.code)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,84 +56,141 @@ impl LocaleData {
|
|||||||
pub fn default() -> Self {
|
pub fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
code: "C.UTF-8".into(),
|
code: "C.UTF-8".into(),
|
||||||
description: "C locale".into(),
|
charset: "UTF-8".into(),
|
||||||
|
description: Some("C locale".into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// gets locales list from system "/etc/locale.gen" file
|
/// gets locales list from system "/etc/locale.gen" file
|
||||||
/// Filters out non UTF-8 locales
|
/// Filters result by filter_charset cahrset Some("UTF-8") to get only UTF-8 locales
|
||||||
fn get_locales_codes_list_blocking() -> std::io::Result<Vec<(String, String)>> {
|
fn get_locales_blocking(filter_charset: Option<&str>) -> Result<Vec<LocaleData>, ExecCommandError> {
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{BufReader, Read};
|
use std::io::{BufReader, Read};
|
||||||
|
|
||||||
|
//pt_PT@euro ISO-8859-15
|
||||||
|
//ru_UA.UTF-8 UTF-8
|
||||||
|
//#ru_UA KOI8-U
|
||||||
|
//
|
||||||
|
// Example ru_UA.UTF-8 UTF-8
|
||||||
|
// Groups:
|
||||||
|
// 1: code, like ru_UA.UTF-8
|
||||||
|
// 3 charser: UTF-8
|
||||||
|
let key_re = Regex::new(r"^[[:word:]@]+").unwrap();
|
||||||
|
let loc_re = Regex::new(r"^#?([[:word:].@-]+) ([0-9A-Z-]+)$").unwrap();
|
||||||
|
|
||||||
|
let loc_desc = get_loc_descr_blocking()?;
|
||||||
|
|
||||||
|
let mut res: Vec<LocaleData> = Vec::new();
|
||||||
let mut file_content = String::new();
|
let mut file_content = String::new();
|
||||||
{
|
{
|
||||||
let locgen_file = File::open(LOCALES_GEN_FILE_NAME)?;
|
let locgen_file = File::open(LOCALES_GEN_FILE_NAME)?;
|
||||||
let mut reader = BufReader::new(locgen_file);
|
let mut reader = BufReader::new(locgen_file);
|
||||||
reader.read_to_string(&mut file_content)?;
|
reader.read_to_string(&mut file_content)?;
|
||||||
}
|
}
|
||||||
|
for loc_line in file_content.lines() {
|
||||||
let mut res: Vec<(String, String)> = file_content
|
if let Some(captured) = loc_re.captures(loc_line.trim_end()) {
|
||||||
.split('\n')
|
let code = captured[1].to_string();
|
||||||
.skip(LOCALES_GEN_START_LINE)
|
let charset = captured[2].to_string();
|
||||||
.filter_map(|l| {
|
// filters charset
|
||||||
let trimmed = l.trim_start_matches('#').trim();
|
if let Some(flt) = filter_charset
|
||||||
if trimmed.len() > 0 {
|
&& charset != flt
|
||||||
trimmed.split_once(' ')
|
{
|
||||||
} else {
|
continue;
|
||||||
None
|
|
||||||
}
|
}
|
||||||
})
|
let description = key_re
|
||||||
.map(|(loc, charset)| (loc.to_string(), charset.to_string()))
|
.find(&code)
|
||||||
.filter(|(_, chrs)| chrs == "UTF-8") // yeld only UTF-8 locales
|
.and_then(|m| loc_desc.get(m.as_str()).cloned());
|
||||||
.collect();
|
|
||||||
|
|
||||||
res.push(("C.UTF-8".into(), "UTF-8".into()));
|
res.push(LocaleData {
|
||||||
|
code: code,
|
||||||
|
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)
|
Ok(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets locales description from "/usr/share/i18n/locales/" directory.
|
/// Gets locales description from "/usr/share/i18n/locales/" directory.
|
||||||
fn get_locales_description_blocking() -> Result<HashMap<String, String>, String> {
|
fn get_loc_descr_blocking() -> Result<HashMap<String, String>, ExecCommandError> {
|
||||||
use std::process::Command;
|
// use std::process::Command;
|
||||||
|
|
||||||
match Command::new("grep")
|
// /usr/share/i18n/locales/uz_UZ:title "Uzbek (latin) locale for Uzbekistan"
|
||||||
.args(["-r", "title ", "/usr/share/i18n/locales/"])
|
// /usr/share/i18n/locales/uz_UZ@cyrillic:title "Uzbek (cyrillic) locale for Uzbekistan"
|
||||||
.output()
|
// 1 group - key code
|
||||||
{
|
// 2 group - description
|
||||||
Ok(cmd_output) => {
|
let descr_re = Regex::new(r#"^/usr/share/i18n/locales/(.+):title[[:space:]]+"(.+)"$"#).unwrap();
|
||||||
if cmd_output.status.success() {
|
|
||||||
match String::from_utf8(cmd_output.stdout) {
|
let mut res: HashMap<String, String> = HashMap::new();
|
||||||
Ok(raw_str_list) => Ok(raw_str_list
|
|
||||||
.split("\n")
|
let raw_list =
|
||||||
.filter_map(|s| s.trim().split_once(":title"))
|
kira_system::exec_command_out("grep", &vec!["-r", "title ", "/usr/share/i18n/locales/"])?;
|
||||||
.filter_map(|(code_part, description_part)| {
|
|
||||||
code_part.rsplit_once("/").and_then(|(_, loc_code)| {
|
for descr_line in raw_list.lines() {
|
||||||
Some((
|
if let Some(captured) = descr_re.captures(descr_line.trim_end()) {
|
||||||
loc_code.trim().to_string(),
|
res.insert(captured[1].to_string(), captured[2].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
|
|
||||||
)),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
@@ -161,25 +225,25 @@ impl LocaleStage {
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|rw| Some(rw.loc_code.clone()));
|
.and_then(|rw| Some(rw.loc_code.clone()));
|
||||||
|
|
||||||
let raw_loc_codes = get_locales_codes_list_blocking().unwrap();
|
// let raw_loc_codes = get_locales_codes_list_blocking().unwrap();
|
||||||
let raw_loc_descr = get_locales_description_blocking().unwrap();
|
// let raw_loc_descr = get_locales_description_blocking().unwrap();
|
||||||
|
|
||||||
let locales: Vec<LocaleData> = raw_loc_codes
|
let locales: Vec<LocaleData> = get_locales_blocking(Some("UTF-8")).unwrap();
|
||||||
.iter()
|
// .iter()
|
||||||
.filter_map(|(code, _)| {
|
// .filter_map(|(code, _)| {
|
||||||
code.split_once('.')
|
// code.split_once('.')
|
||||||
.and_then(|(key_code, _)| Some((key_code, code)))
|
// .and_then(|(key_code, _)| Some((key_code, code)))
|
||||||
})
|
// })
|
||||||
.filter_map(|(key_code, code)| {
|
// .filter_map(|(key_code, code)| {
|
||||||
raw_loc_descr
|
// raw_loc_descr
|
||||||
.get(key_code)
|
// .get(key_code)
|
||||||
.and_then(|descr| Some((code.clone(), descr.clone())))
|
// .and_then(|descr| Some((code.clone(), descr.clone())))
|
||||||
})
|
// })
|
||||||
.map(|(code, descr)| LocaleData {
|
// .map(|(code, descr)| LocaleData {
|
||||||
code: code,
|
// code: code,
|
||||||
description: descr,
|
// description: descr,
|
||||||
})
|
// })
|
||||||
.collect();
|
// .collect();
|
||||||
|
|
||||||
// if we get lang code from wellcome stage, try to fing match with system locales
|
// if we get lang code from wellcome stage, try to fing match with system locales
|
||||||
let lang_match = if let Some(lang) = maybe_lang
|
let lang_match = if let Some(lang) = maybe_lang
|
||||||
|
|||||||
Reference in new issue
Block a user