diff --git a/Cargo.lock b/Cargo.lock index 9740bb6..a57c36e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -69,6 +69,23 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04" +[[package]] +name = "annotate-snippets" +version = "0.12.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f211a51805bc641f3ad5b7664c77d2547af685cc33b4cd8d31964027a46f13f1" +dependencies = [ + "anstyle", + "memchr", + "unicode-width", +] + +[[package]] +name = "anstyle" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" + [[package]] name = "anyhow" version = "1.0.104" @@ -101,6 +118,12 @@ dependencies = [ "syn 2.0.119", ] +[[package]] +name = "arraydeque" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d902e3d592a523def97af8f317b08ce16b7ab854c1985a0c671e6f15cebc236" + [[package]] name = "arrayref" version = "0.3.9" @@ -258,13 +281,13 @@ dependencies = [ [[package]] name = "async-recursion" -version = "1.1.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" +checksum = "4f8abc12baad266b1c8cec146854c195b5864b4221d4b2ca7296a7ae82d9e451" dependencies = [ "proc-macro2", "quote", - "syn 2.0.119", + "syn 3.0.6", ] [[package]] @@ -363,6 +386,12 @@ version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3a647dce9631f152a99ec16cfc09267ae55fe280d5dc288964027d458076323" +[[package]] +name = "base64" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5" + [[package]] name = "bit-set" version = "0.8.0" @@ -512,9 +541,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.5.1" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f360145194ee8e21db5ee7f3fcd4fe52210864c75c985dae33218202c8bbe040" +checksum = "f74872d07caf508b30a21f6836e7d7016a2eaf7d9ff4f48deaa58cd8a0407630" dependencies = [ "find-msvc-tools", "jobserver", @@ -649,6 +678,12 @@ dependencies = [ "libc", ] +[[package]] +name = "core_detect" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f8f80099a98041a3d1622845c271458a2d73e688351bf3cb999266764b81d48" + [[package]] name = "core_maths" version = "0.1.1" @@ -811,6 +846,29 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "252afb9ae5eaa683babdc6a068b3f5726eb19e05070c731f9b2a23a7c3e8ed34" +[[package]] +name = "encoding_rs" +version = "0.8.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e985e0451871ad22fb8d2b6b076e2028a502a0d3950998c2c5c0a4f9b5d9679" +dependencies = [ + "cfg-if", + "core_detect", + "multiversion_no_op", + "rustversion", + "scopeguard", + "simdutf8", +] + +[[package]] +name = "encoding_rs_io" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fba3fe847045ecff794b9c138293a80db914678c453ad63fbf0c6a9eb6e00b22" +dependencies = [ + "encoding_rs", +] + [[package]] name = "endi" version = "1.1.1" @@ -1006,9 +1064,9 @@ dependencies = [ [[package]] name = "font-types" -version = "0.12.5" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8eb065f3251655b3c90e22e5e363f310fc5332fb3402e37bbc94752283248f6" +checksum = "6c92d9081c7ab3bd83ef1eecdfad090f3d966e3ce74106779664114cfe1a6274" dependencies = [ "bytemuck", ] @@ -1269,6 +1327,16 @@ dependencies = [ "walkdir", ] +[[package]] +name = "granit-parser" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e20f99e46474f56bd905c56e817ebddcf377a611f94c53ac4649e4d3fa3c0cd0" +dependencies = [ + "arraydeque", + "smallvec", +] + [[package]] name = "guillotiere" version = "0.6.2" @@ -1789,12 +1857,6 @@ dependencies = [ "smallvec", ] -[[package]] -name = "lazy_static" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" - [[package]] name = "lebe" version = "0.5.3" @@ -1803,9 +1865,9 @@ checksum = "7a79a3332a6609480d7d0c9eab957bca6b455b91bb84e66d19f5ff66294b85b8" [[package]] name = "libc" -version = "0.2.189" +version = "0.2.190" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2" +checksum = "ce5d3ddc6d3fa000eb1536d85e147bfe31aacaba692ed6a876f95cb7c855be78" [[package]] name = "libfuzzer-sys" @@ -1972,6 +2034,12 @@ dependencies = [ "pxfm", ] +[[package]] +name = "multiversion_no_op" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "743fb55ba31b18fb1ecef6bdc9aa2743314978ac084044301a7eee33fb99a20d" + [[package]] name = "mundy" version = "0.2.3" @@ -2073,6 +2141,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "nohash-hasher" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" + [[package]] name = "nom" version = "8.0.0" @@ -2631,9 +2705,9 @@ checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" [[package]] name = "pin-utils" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +checksum = "13bee6c73da26345c729282832b60b0363cf3dd9f4bfd81d8551b7a1c889a113" [[package]] name = "piper" @@ -2979,7 +3053,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "046a7d674daf459825b32f5062056d6882db0d2f5a479fbd76ccfc870ac18709" dependencies = [ "bytemuck", - "font-types 0.12.5", + "font-types 0.12.6", "once_cell", ] @@ -3065,12 +3139,11 @@ checksum = "6c20b6793b5c2fa6553b250154b78d6d0db37e72700ae35fad9387a46f487c97" [[package]] name = "rust-i18n" -version = "3.1.5" +version = "4.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fda2551fdfaf6cc5ee283adc15e157047b92ae6535cf80f6d4962d05717dc332" +checksum = "8502e73e6461c738659455c5d2cf95bc132760a6f203c717e66ee72b78906d7f" dependencies = [ "globwalk", - "once_cell", "regex", "rust-i18n-macro", "rust-i18n-support", @@ -3079,39 +3152,34 @@ dependencies = [ [[package]] name = "rust-i18n-macro" -version = "3.1.5" +version = "4.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22baf7d7f56656d23ebe24f6bb57a5d40d2bce2a5f1c503e692b5b2fa450f965" +checksum = "d54a28dd9d46108d56b9f0c85b220908844233e561c03087890325104f90f2c6" dependencies = [ "glob", - "once_cell", "proc-macro2", "quote", "rust-i18n-support", "serde", "serde_json", - "serde_yaml", "syn 2.0.119", ] [[package]] name = "rust-i18n-support" -version = "3.1.5" +version = "4.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "940ed4f52bba4c0152056d771e563b7133ad9607d4384af016a134b58d758f19" +checksum = "e806c2a9701cbd6043992cd935c30cb1fdb128fa15e7b506f3b46f97045737c0" dependencies = [ "arc-swap", "base62", + "foldhash", "globwalk", "itertools 0.11.0", - "lazy_static", "normpath", - "once_cell", - "proc-macro2", - "regex", "serde", + "serde-saphyr", "serde_json", - "serde_yaml", "siphasher", "toml", "triomphe", @@ -3170,12 +3238,6 @@ version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" -[[package]] -name = "ryu" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" - [[package]] name = "same-file" version = "1.0.6" @@ -3213,6 +3275,23 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-saphyr" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8050abb251097357e24aff63ba2c52a6309ecb7d23a5474023df960a02694d8" +dependencies = [ + "annotate-snippets", + "base64", + "encoding_rs_io", + "granit-parser", + "nohash-hasher", + "num-traits", + "serde_core", + "smallvec", + "zmij", +] + [[package]] name = "serde_core" version = "1.0.229" @@ -3266,19 +3345,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_yaml" -version = "0.9.34+deprecated" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" -dependencies = [ - "indexmap", - "itoa", - "ryu", - "serde", - "unsafe-libyaml", -] - [[package]] name = "shlex" version = "2.0.1" @@ -3622,9 +3688,9 @@ checksum = "fd3ca314f692efd6c868f8408f53fe444634a845f96c028b97d35f6a1f79f0ee" [[package]] name = "tokio" -version = "1.53.1" +version = "1.53.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "202caea871b69668250d242070849eb495be178ed697a3e98aebce5bc81a0bed" +checksum = "e95f91fcc7a621e8b030f6aa23c71fe9838ae2fb4d8118b75602a328f5144044" dependencies = [ "pin-project-lite", ] @@ -3798,17 +3864,11 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" -[[package]] -name = "unsafe-libyaml" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" - [[package]] name = "uuid" -version = "1.26.1" +version = "1.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ef6dac1e96601b4fb3acccccff2139741fcb757cb9a36089bf5be91cfb285ce" +checksum = "97277d36b9c3ace13e58fa6e753f8b0bbbf302a18dd193240d70f9e29681059a" dependencies = [ "js-sys", "serde_core", diff --git a/Cargo.toml b/Cargo.toml index 927fee0..f0ec132 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ iced = { version = "0.14", default-features = false, features = ["crisp", "linux #iced = { git = "https://github.com/iced-rs/iced", branch = "vello_cpu", default-features = false, features = ["crisp", "linux-theme-detection", "vello-cpu", "x11", "smol", "image"]} iced_moving_picture = "0" log = "0.4" -rust-i18n = "3" +rust-i18n = "4" serde = { version = "1", features = ["derive"] } serde_json = "1" time-format = "1.2" diff --git a/src/kira_disk_layout.rs b/src/kira_disk_layout.rs index f6f48f2..912d3aa 100644 --- a/src/kira_disk_layout.rs +++ b/src/kira_disk_layout.rs @@ -270,6 +270,10 @@ impl PartInfo { }) } + /// + /// Returns partition full path by partlabel "/dev/disk/by-partlabel/{partlabel}" + /// Returns None if partition do not have partlabel + /// pub fn partlabel_dev(&self) -> Option { self.gpt_label .as_ref() @@ -400,6 +404,15 @@ impl PartLayout { } } + pub fn get_part(&self, part_role: PartRole) -> Option { + for part in &self.part_list { + if let Some(role) = &part.role && role.eq(&part_role) { + return Some(part.clone()); + } + } + None + } + pub fn read_from_disk(dev: &BlkDev) -> Result { let part_list = get_dev_part_blocking(&dev.name)?; let parts_size = part_list diff --git a/src/stages/install/mod.rs b/src/stages/install/mod.rs index 7faa0ae..0dd8db9 100644 --- a/src/stages/install/mod.rs +++ b/src/stages/install/mod.rs @@ -21,7 +21,7 @@ use std::path::Path; use crate::{ - kira_disk_layout::{self, BlkDev, FSType, PartLayout, PartRole}, + kira_disk_layout::{self, BlkDev, FSType, PartInfo, PartLayout, PartRole}, kira_size::KiraSize, kira_system::{self, ExecCommandError}, kira_theming, @@ -87,9 +87,8 @@ pub fn bcachefs_init( Ok(()) } + pub fn init_disk(part_layout: &PartLayout, mnt_dir: &str) -> Result<(), ExecCommandError> { - - let mnt_path = Path::new(mnt_dir); log::info!("Cheking is MNT path exists: {}", mnt_dir); if !mnt_path.exists() { @@ -105,6 +104,7 @@ pub fn init_disk(part_layout: &PartLayout, mnt_dir: &str) -> Result<(), ExecComm match part.role { Some(PartRole::EFI) => { if let Some(part_l) = part.partlabel_dev() { + log::info!("Formating EFI partition."); kira_system::mkfs_esp(&part_l)?; } } @@ -112,10 +112,11 @@ pub fn init_disk(part_layout: &PartLayout, mnt_dir: &str) -> Result<(), ExecComm if let Some(part_l) = part.partlabel_dev() { if let FSType::BCACHEFS(bc_par) = &part.fs_type { log::info!("Formating root pertition."); - kira_system::bcachefs_format(&part_l, bc_par.password.clone(), bc_par.password.clone())?; - // init root - log::info!("Mount and init root partition."); - bcachefs_init(ROOT_PARTLABEL_DEV, mnt_dir, bc_par.password.clone())?; + kira_system::bcachefs_format( + &part_l, + bc_par.comp_alg.clone(), + bc_par.password.clone(), + )?; } else { return Err(ExecCommandError::Other( "ROOT partition is not BCACHEFS type!".into(), @@ -125,6 +126,7 @@ pub fn init_disk(part_layout: &PartLayout, mnt_dir: &str) -> Result<(), ExecComm } Some(PartRole::SWAP) => { if let Some(part_l) = part.partlabel_dev() { + log::info!("Formating SWAP partition."); kira_system::mkswap(&part_l)?; } } @@ -161,7 +163,7 @@ pub struct InstallStage { pub enum Message { UserConfirms, UserDenies, - Sucess, + Success, Cancel, Finish, UpdateProgress(Result<(f32, String), String>), @@ -174,11 +176,40 @@ pub enum Update { Task(Task), } +pub fn mount_and_init_root( + part_layout: &PartLayout, + mnt_dir: &str, +) -> Result<(), ExecCommandError> { + // init root + let root_part = part_layout.get_part(PartRole::ROOT).expect("Root partition must be present!"); + log::info!("Mount and init root partition."); + if let FSType::BCACHEFS(bcache_prop) = root_part.fs_type { + bcachefs_init(ROOT_PARTLABEL_DEV, mnt_dir, bcache_prop.password.clone())?; + } + else { + return Err(ExecCommandError::Other(format!("Unexpected root partition type: {}", root_part.fs_type))); + } + + Ok(()) + + +} + async fn init_disk_async(part_layout: PartLayout, mnt_dir: String) -> Result<(), ExecCommandError> { use blocking; blocking::unblock(move || init_disk(&part_layout, &mnt_dir)).await } +async fn mount_and_init_root_async(part_layout: PartLayout, mnt_dir: String) -> Result<(), ExecCommandError> { + use blocking; + blocking::unblock(move || mount_and_init_root(&part_layout, &mnt_dir)).await +} + +// async fn install_base(mnt_dir: String) -> Result<(), ExecCommandError> { +// use blocking; +// blocking::unblock(move || init_disk(&part_layout, &mnt_dir)).await +// } + fn do_install( k_config: KiraConfig, ) -> impl futures::Stream> { @@ -189,7 +220,7 @@ fn do_install( let disk_layout = k_config.res_partition.unwrap().part_layout.clone(); // creating gpt partition table - let res = init_disk_async(disk_layout, MNT_DIR.into()).await; + let res = init_disk_async(disk_layout.clone(), MNT_DIR.into()).await; let res_err = res.is_err(); output .send(res.map(|_| (1.1f32, "Formatting bcachefs".into()))) @@ -200,27 +231,47 @@ fn do_install( return; } + // Mount and init root + let res = mount_and_init_root_async(disk_layout, MNT_DIR.into()).await; + let res_err = res.is_err(); + output + .send(res.map(|_| (5.1f32, "Installing base".into()))) + .await + .unwrap(); + + if res_err { + return; + } + // Check if send fails (receiver dropped/cancelled) // if output.send(res).await.is_err() { // return; // Exit early if UI is gone // } - + // Optional: Send completion or error state here // output.send(Message::WorkFailed).await.ok(); }, ) } -fn check_kconfig(k_config: &KiraConfig) -> Result<(), String> { - if k_config.res_welcome.is_none(){ Err("Missing wellcome stage result!".into())} - else if k_config.res_license == false { Err("License is NOT accepted!".into())} - else if k_config.res_locale.is_none(){ Err("Missing locale stage result!".into())} - else if k_config.res_network.is_none(){ Err("Missing network stage result!".into())} - else if k_config.res_keyboard.is_none(){ Err("Missing keyboard stage result!".into())} - else if k_config.res_timezone.is_none(){ Err("Missing timezone stage result!".into())} - else if k_config.res_partition.is_none(){ Err("Missing partition stage result!".into())} - else if k_config.res_security.is_none(){ Err("Missing security stage result!".into())} - else { +fn check_kconfig(k_config: &KiraConfig) -> Result<(), String> { + if k_config.res_welcome.is_none() { + Err("Missing wellcome stage result!".into()) + } else if k_config.res_license == false { + Err("License is NOT accepted!".into()) + } else if k_config.res_locale.is_none() { + Err("Missing locale stage result!".into()) + } else if k_config.res_network.is_none() { + Err("Missing network stage result!".into()) + } else if k_config.res_keyboard.is_none() { + Err("Missing keyboard stage result!".into()) + } else if k_config.res_timezone.is_none() { + Err("Missing timezone stage result!".into()) + } else if k_config.res_partition.is_none() { + Err("Missing partition stage result!".into()) + } else if k_config.res_security.is_none() { + Err("Missing security stage result!".into()) + } else { Ok(()) } } @@ -247,7 +298,6 @@ impl InstallStage { match message { Message::UserDenies => Update::StgAct(StageAction::Back), Message::UserConfirms => { - log::info!("Cheking config..."); match check_kconfig(&self.k_config) { Ok(()) => log::info!("Config looks good."), @@ -257,7 +307,6 @@ impl InstallStage { return Update::StgAct(StageAction::None); } } - // starting installation process here log::info!("Starting disk partitioning."); @@ -289,7 +338,7 @@ impl InstallStage { Update::StgAct(StageAction::Abort) } Message::Cancel => Update::StgAct(StageAction::Abort), - Message::Sucess => Update::StgAct(StageAction::None), + Message::Success => Update::StgAct(StageAction::None), Message::Finish => Update::StgAct(StageAction::None), } }