Skip to content

Commit 3c9a480

Browse files
committed
feat: add stages for long running postinstall sections
1 parent 0ca887e commit 3c9a480

File tree

3 files changed

+58
-46
lines changed

3 files changed

+58
-46
lines changed

src/backend/postinstall/dracut.rs

+26-22
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use crate::stage;
2+
13
use super::{Context, PostInstallModule};
24
use color_eyre::{eyre::bail, Result};
35
use serde::{Deserialize, Serialize};
@@ -8,29 +10,31 @@ pub struct Dracut;
810

911
impl PostInstallModule for Dracut {
1012
fn run(&self, _context: &Context) -> Result<()> {
11-
// We assume the installation wouldn't be used on another system (false only if you install
12-
// on something like a USB stick anyway)
13-
// → reduce size of initramfs aggressively for faster boot times
14-
//
15-
// on my system this reduces the size from 170M down to 43M.
16-
// — mado
17-
let dracut_cmd_status = Command::new("dracut")
18-
.args([
19-
"--force",
20-
"--parallel",
21-
"--regenerate-all",
22-
"--hostonly",
23-
"--strip",
24-
"--aggressive-strip",
25-
])
26-
.status()?;
13+
stage!("Regenerating initramfs" {
14+
// We assume the installation wouldn't be used on another system (false only if you install
15+
// on something like a USB stick anyway)
16+
// → reduce size of initramfs aggressively for faster boot times
17+
//
18+
// on my system this reduces the size from 170M down to 43M.
19+
// — mado
20+
let dracut_cmd_status = Command::new("dracut")
21+
.args([
22+
"--force",
23+
"--parallel",
24+
"--regenerate-all",
25+
"--hostonly",
26+
"--strip",
27+
"--aggressive-strip",
28+
])
29+
.status()?;
2730

28-
if !dracut_cmd_status.success() {
29-
bail!(
30-
"dracut failed with exit code {:?}",
31-
dracut_cmd_status.code()
32-
);
33-
}
31+
if !dracut_cmd_status.success() {
32+
bail!(
33+
"dracut failed with exit code {:?}",
34+
dracut_cmd_status.code()
35+
);
36+
}
37+
});
3438

3539
Ok(())
3640
}

src/backend/postinstall/reinstall_kernel.rs

+17-13
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ use itertools::Itertools;
33
use serde::{Deserialize, Serialize};
44
use std::process::Command;
55

6+
use crate::stage;
7+
68
use super::{Context, PostInstallModule};
79

810
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
@@ -21,19 +23,21 @@ impl PostInstallModule for ReinstallKernel {
2123

2224
// install kernel
2325

24-
let kernel_install_cmd_status = Command::new("kernel-install")
25-
.arg("add")
26-
.arg(kver)
27-
.arg(format!("/lib/modules/{kver}/vmlinuz"))
28-
.arg("--verbose")
29-
.status()?;
30-
31-
if !kernel_install_cmd_status.success() {
32-
bail!(
33-
"kernel-install failed with exit code {:?}",
34-
kernel_install_cmd_status.code()
35-
);
36-
}
26+
stage!("Reinstalling kernels" {
27+
let kernel_install_cmd_status = Command::new("kernel-install")
28+
.arg("add")
29+
.arg(kver)
30+
.arg(format!("/lib/modules/{kver}/vmlinuz"))
31+
.arg("--verbose")
32+
.status()?;
33+
34+
if !kernel_install_cmd_status.success() {
35+
bail!(
36+
"kernel-install failed with exit code {:?}",
37+
kernel_install_cmd_status.code()
38+
);
39+
}
40+
});
3741

3842
Ok(())
3943
}

src/backend/postinstall/selinux.rs

+15-11
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,29 @@ use color_eyre::{eyre::bail, Result};
22
use serde::{Deserialize, Serialize};
33
use std::process::Command;
44

5+
use crate::stage;
6+
57
use super::{Context, PostInstallModule};
68

79
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
810
pub struct SELinux;
911

1012
impl PostInstallModule for SELinux {
1113
fn run(&self, _context: &Context) -> Result<()> {
12-
let setfiles_cmd_status = Command::new("setfiles")
13-
.args(["-e", "/proc", "-e", "/sys"])
14-
.arg("/etc/selinux/targeted/contexts/files/file_contexts")
15-
.arg("/")
16-
.status()?;
14+
stage!("Setting SELinux labels" {
15+
let setfiles_cmd_status = Command::new("setfiles")
16+
.args(["-e", "/proc", "-e", "/sys"])
17+
.arg("/etc/selinux/targeted/contexts/files/file_contexts")
18+
.arg("/")
19+
.status()?;
1720

18-
if !setfiles_cmd_status.success() {
19-
bail!(
20-
"dracut failed with exit code {:?}",
21-
setfiles_cmd_status.code()
22-
);
23-
}
21+
if !setfiles_cmd_status.success() {
22+
bail!(
23+
"dracut failed with exit code {:?}",
24+
setfiles_cmd_status.code()
25+
);
26+
}
27+
});
2428

2529
Ok(())
2630
}

0 commit comments

Comments
 (0)