Skip to content

Commit 1d99e07

Browse files
committed
👷 installer: properly log installer script output
properly log installer script output instead of inheriting parent streams
1 parent 8f5531d commit 1d99e07

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

‎src/main.rs‎

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use data_types::*;
1717
use utils::*;
1818

1919
use std::collections::HashMap;
20+
use std::io::{BufRead, BufReader};
2021
use std::path::Path;
2122
use std::sync::{Arc, Mutex};
2223
use std::{fs, str};
@@ -30,8 +31,8 @@ use gtk::{gdk, glib, Builder, HeaderBar, Window};
3031
use i18n_embed::DesktopLanguageRequester;
3132
use once_cell::sync::Lazy;
3233
use serde_json::json;
33-
use subprocess::Exec;
34-
use tracing::{debug, error};
34+
use subprocess::{Exec, Redirection};
35+
use tracing::{debug, error, info};
3536
use unic_langid::LanguageIdentifier;
3637

3738
const RESPREFIX: &str = "/org/cachyos/hello";
@@ -160,12 +161,33 @@ fn quick_message(message: String) {
160161
let checks = [connectivity_check, edition_compat_check, outdated_version_check];
161162
if !checks.iter().all(|x| x(message.clone())) {
162163
// if any check failed, return
164+
info!("Some ISO check failed!");
163165
install_btn.set_sensitive(true);
164166
return;
165167
}
166168

167-
let cmd = "/usr/local/bin/calamares-online.sh".to_owned();
168-
Exec::cmd(cmd).join().unwrap();
169+
// Spawning child process
170+
info!("ISO checks passed! Starting Installer..");
171+
let mut child = Exec::cmd("/usr/local/bin/calamares-online.sh")
172+
.stdout(Redirection::Pipe)
173+
.stderr(Redirection::Merge)
174+
.popen()
175+
.expect("Failed to spawn installer");
176+
177+
let child_out = child.stdout.take().unwrap();
178+
let child_read = BufReader::new(child_out);
179+
180+
// Read the output line by line until EOF
181+
for line_result in child_read.lines() {
182+
match line_result {
183+
Ok(line) => info!("{line}"),
184+
Err(e) => error!("Error reading output: {e}"),
185+
}
186+
}
187+
188+
let status = child.wait().expect("Failed to waiting for child");
189+
info!("Installer finished with status: {:?}", status);
190+
169191
install_btn.set_sensitive(true);
170192
});
171193
}

0 commit comments

Comments
 (0)