]> git.proxmox.com Git - pve-installer.git/commitdiff
tui: install_progress: split out low-level installer spawing into own function
authorChristoph Heiss <c.heiss@proxmox.com>
Fri, 10 Nov 2023 14:17:21 +0000 (15:17 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Sat, 11 Nov 2023 13:08:41 +0000 (14:08 +0100)
No functional changes.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
proxmox-installer-common/src/setup.rs
proxmox-tui-installer/src/views/install_progress.rs

index 28a58f34343c1d51aef286a5b6453a2d8fe71718..70bdc3c218a6a1079b4df2ebf6196d90c0014397 100644 (file)
@@ -3,9 +3,10 @@ use std::{
     collections::HashMap,
     fmt,
     fs::File,
-    io::BufReader,
+    io::{self, BufReader},
     net::IpAddr,
     path::{Path, PathBuf},
+    process::{self, Command, Stdio},
 };
 
 use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
@@ -367,3 +368,22 @@ impl Interface {
         format!("{} {}", self.state.render(), self.name)
     }
 }
+
+pub fn spawn_low_level_installer(test_mode: bool) -> io::Result<process::Child> {
+    let (path, args, envs): (&str, &[&str], Vec<(&str, &str)>) = if test_mode {
+        (
+            "./proxmox-low-level-installer",
+            &["-t", "start-session-test"],
+            vec![("PERL5LIB", ".")],
+        )
+    } else {
+        ("proxmox-low-level-installer", &["start-session"], vec![])
+    };
+
+    Command::new(path)
+        .args(args)
+        .envs(envs)
+        .stdin(Stdio::piped())
+        .stdout(Stdio::piped())
+        .spawn()
+}
index ccf53adf4b11618185839fde0d4857a087a42b6a..a70b6cbbb0114b6bebf320d66eba91442cbe99bd 100644 (file)
@@ -14,6 +14,7 @@ use cursive::{
 };
 
 use crate::{abort_install_button, setup::InstallConfig, yes_no_dialog, InstallerState};
+use proxmox_installer_common::setup::spawn_low_level_installer;
 
 pub struct InstallProgressView {
     view: PaddedView<LinearLayout>,
@@ -59,28 +60,7 @@ impl InstallProgressView {
         state: InstallerState,
         progress_text: TextContent,
     ) {
-        let child = {
-            use std::process::{Command, Stdio};
-
-            let (path, args, envs): (&str, &[&str], Vec<(&str, &str)>) = if state.in_test_mode {
-                (
-                    "./proxmox-low-level-installer",
-                    &["-t", "start-session-test"],
-                    vec![("PERL5LIB", ".")],
-                )
-            } else {
-                ("proxmox-low-level-installer", &["start-session"], vec![])
-            };
-
-            Command::new(path)
-                .args(args)
-                .envs(envs)
-                .stdin(Stdio::piped())
-                .stdout(Stdio::piped())
-                .spawn()
-        };
-
-        let mut child = match child {
+        let mut child = match spawn_low_level_installer(state.in_test_mode) {
             Ok(child) => child,
             Err(err) => {
                 let _ = cb_sink.send(Box::new(move |siv| {