From 1399c56135209f20940fb72acdca92056a993777650e71fbcce908e8a70cf185 Mon Sep 17 00:00:00 2001 From: kira Date: Wed, 18 Nov 2026 14:53:12 +0100 Subject: [PATCH] More work on install stage --- src/files/etc/pacman.conf | 2 +- src/kira_system.rs | 63 +++++++++++++++++-- src/stages/install/mod.rs | 125 +++++++++++++++++++++++++++++++++++--- 3 files changed, 176 insertions(+), 14 deletions(-) diff --git a/src/files/etc/pacman.conf b/src/files/etc/pacman.conf index ac5af69..6e3ac0d 100644 --- a/src/files/etc/pacman.conf +++ b/src/files/etc/pacman.conf @@ -72,7 +72,7 @@ LocalFileSigLevel = Optional # kira linux base repository [kira-base] SigLevel = Required TrustedOnly -Server = https://repos.kira-linux.org/kira-base/x86_64 +Include = /etc/pacman.d/kira-mirrorlist # The gremlins repositories are disabled by default. To enable, uncomment the # repo name header and Include lines. You can add preferred servers immediately diff --git a/src/kira_system.rs b/src/kira_system.rs index e348269..2eea1e7 100644 --- a/src/kira_system.rs +++ b/src/kira_system.rs @@ -124,6 +124,62 @@ fn exec_command_out(cmd: &str, args: &Vec<&str>) -> Result) -> Result<(), ExecCommandError> { + use std::io::{BufRead, BufReader}; + use std::process::{Command, Stdio}; + use std::thread; + + log::debug!("Executing command {} {:?}", cmd, args); + + // Configure the command to pipe stdout + let mut child = Command::new(cmd) + .args(args) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn()?; + + // Take ownership of the stdout handle + let stdout = child + .stdout + .take() + .ok_or("Failed to capture stdout".to_string())?; + let mut stderr = child + .stderr + .take() + .ok_or("Failed to capture stderr".to_string())?; + + let stderr_handle = thread::spawn(move || { + let mut buf = Vec::new(); + use std::io::Read; + let _ = stderr.read_to_end(&mut buf); + buf + }); + + // Wrap in BufReader for efficient line-by-line reading + let reader = BufReader::new(stdout); + + // Iterate and log each line in real time + for line in reader.lines() { + match line { + Ok(text) => log::info!("{}: {}", cmd, text), + Err(e) => log::error!("Read error: {}", e), + } + } + + // Wait for the process to finish to prevent zombies and check status + let status = child.wait()?; + let stderr_output = stderr_handle.join().unwrap(); + + if status.success() { + Ok(()) + } else { + Err(CommandFailed::new(cmd, args, stderr_output).into()) + } +} + /// sync system time with chrony /// dinitctl start chrony pub fn dinit_sync_time_chrony() -> Result<(), ExecCommandError> { @@ -133,7 +189,7 @@ pub fn dinit_sync_time_chrony() -> Result<(), ExecCommandError> { /// Install base system /// basestrap /mnt base base-devel dinit elogind-dinit pub fn basestrap_dinit(root_dir: &str) -> Result<(), ExecCommandError> { - exec_command( + exec_command_log( "basestrap", &vec![root_dir, "base", "base-devel", "dinit", "elogind-dinit"], ) @@ -142,10 +198,7 @@ pub fn basestrap_dinit(root_dir: &str) -> Result<(), ExecCommandError> { pub fn basestrap(root_dir: &str, pkg_list: &[&str]) -> Result<(), ExecCommandError> { let mut args: Vec<&str> = vec![root_dir]; args.extend(pkg_list); - exec_command( - "basestrap", - &args, - ) + exec_command_log("basestrap", &args) } /// Executes parted command with given arguments diff --git a/src/stages/install/mod.rs b/src/stages/install/mod.rs index 99138ba..d14db4e 100644 --- a/src/stages/install/mod.rs +++ b/src/stages/install/mod.rs @@ -44,17 +44,108 @@ const ROOT_PARTLABEL_DEV: &str = "/dev/disk/by-partlabel/bee-root"; /// /// List of packages for desktop (elogind-dinit no need for headles system) /// -const PKG_LIST_DESKTOP: [&str; 8] = [ +const PKG_LIST_CORE_DESKTOP: [&str; 18] = [ "elogind-dinit", "linux-kira-lts", "linux-firmware", + "less", + "sudo", + "nano", + "diffutils", "bcachefs-tools", "xfsprogs", "exfatprogs", "f2fs-tools", + "dosfstools", + "efibootmgr", + "nvme-cli", "hive-up", + "kira-blk-settings", + "kira-linux-keyring", + "kira-mirrorlist", ]; +// const PKG_LIST_MORE_DESKTOP: [&str; 11] = [ +// "wireless-regdb", +// "wpa_supplicant", +// "wpa_supplicant-dinit", +// "networkmanager", +// "networkmanager-dinit", +// "chrony", //internet time +// "chrony-dinit", //internet time +// "smartmontools", +// "cryptsetup", +// "btop", +// "fish", +// ]; + +// const PKG_LIST_SOUND_DESKTOP: [&str; 8] = [ +// "pipewire", +// "pipewire-dinit", +// "pipewire-alsa", +// "pipewire-audio", +// "pipewire-jack", +// "pipewire-pulse", +// "wireplumber", +// "wireplumber-dinit", +// ]; + +// const PKG_LIST_MEDIA_DESKTOP: [&str; 4] = ["ffmpeg", "ffmpeg4.4", "strawberry", "mpv"]; + +const PKG_LIST_KDE_DESKTOP: [&str; 45] = [ + "wireless-regdb", + "wpa_supplicant", + "wpa_supplicant-dinit", + "networkmanager", //networkmanager + "networkmanager-dinit", + "chrony", //internet time + "chrony-dinit", //internet time + "smartmontools", + "cryptsetup", + "btop", + "fish", + "pipewire", //sound + "pipewire-dinit", + "pipewire-alsa", + "pipewire-audio", + "pipewire-jack", + "pipewire-pulse", + "wireplumber", + "wireplumber-dinit", + "mesa", + "libva", + "libva-utils", + "power-profiles-daemon", + "power-profiles-daemon-dinit", + "plasma-desktop", + "plasma-workspace", + "xdg-desktop-portal-kde", + "kwallet-pam", + "kwayland-integration", + "libappindicator", + "okular", + "partitionmanager", + "plasma-browser-integration", + "plasma-desktop", + "plasma-disks", + "plasma-keyboard", + "plasma-login-manager", + "plasma-nm", + "plasma-pa", + "plasma-systemmonitor", + "plasma-workspace", + "ffmpeg", "ffmpeg4.4", "strawberry", "mpv", + +]; + +// const PKG_LIST_AWESOME_DESKTOP: [&str; 5] = [ +// "mesa", +// "libva", +// "libva-utils", +// "awesome", +// "wiremix", // pipewire sound control +// ]; + /// Creates new GPT table and partitions from PartLayout pub fn create_partitions(part_layout: &PartLayout) -> Result<(), ExecCommandError> { log::info!("Creating GPT part table..."); @@ -229,10 +320,16 @@ async fn install_base_async(mnt_dir: String) -> Result<(), ExecCommandError> { blocking::unblock(move || kira_system::basestrap_dinit(&mnt_dir)).await } -async fn install_system_async(mnt_dir: String) -> Result<(), ExecCommandError> { +async fn install_core_desk_async(mnt_dir: String) -> Result<(), ExecCommandError> { use blocking; - log::info!("Installing base system..."); - blocking::unblock(move || kira_system::basestrap(&mnt_dir, &PKG_LIST_DESKTOP)).await + log::info!("Installing core desktop packages..."); + blocking::unblock(move || kira_system::basestrap(&mnt_dir, &PKG_LIST_CORE_DESKTOP)).await +} + +async fn install_kde_desk_async(mnt_dir: String) -> Result<(), ExecCommandError> { + use blocking; + log::info!("Installing KDE desktop packages..."); + blocking::unblock(move || kira_system::basestrap(&mnt_dir, &PKG_LIST_KDE_DESKTOP)).await } fn do_install( @@ -272,7 +369,7 @@ fn do_install( let res = install_base_async(MNT_DIR.into()).await; let res_err = res.is_err(); output - .send(res.map(|_| (10.0f32, "Installing system".into()))) + .send(res.map(|_| (10.0f32, "Installing core system".into()))) .await .unwrap(); @@ -280,11 +377,23 @@ fn do_install( return; } - // installing system - let res = install_system_async(MNT_DIR.into()).await; + // installing core system + let res = install_core_desk_async(MNT_DIR.into()).await; let res_err = res.is_err(); output - .send(res.map(|_| (20.0f32, "Some other stuff".into()))) + .send(res.map(|_| (20.0f32, "Installing KDE desktop envirometn".into()))) + .await + .unwrap(); + + if res_err { + return; + } + + // installing KDE + let res = install_kde_desk_async(MNT_DIR.into()).await; + let res_err = res.is_err(); + output + .send(res.map(|_| (50.0f32, "Configuring system".into()))) .await .unwrap();