feat: add support for regenerating initramfs on fedora

This commit is contained in:
Ilya Zlobintsev 2024-01-13 11:33:14 +02:00
parent 059b66b96d
commit 4797ea54f7
2 changed files with 9 additions and 0 deletions

View File

@ -88,6 +88,7 @@ fn regenerate_initramfs() -> anyhow::Result<InitramfsType> {
let result = match initramfs_type {
InitramfsType::Debian => run_command("update-initramfs", &["-u"]),
InitramfsType::Mkinitcpio => run_command("mkinitcpio", &["-P"]),
InitramfsType::Dracut => run_command("dracut", &["--regenerate-all", "--force"]),
};
result.map(|()| initramfs_type)
}
@ -111,6 +112,13 @@ fn detect_initramfs_type(os_release: &OsRelease) -> Option<InitramfsType> {
);
None
}
} else if os_release.id == "fedora" {
if Command::new("dracut").arg("--version").output().is_ok() {
Some(InitramfsType::Dracut)
} else {
warn!("Fedora without dracut detected, refusing to regenerate initramfs");
None
}
} else {
None
}

View File

@ -261,6 +261,7 @@ pub struct PowerState<T> {
pub enum InitramfsType {
Debian,
Mkinitcpio,
Dracut,
}
#[skip_serializing_none]