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 { let result = match initramfs_type {
InitramfsType::Debian => run_command("update-initramfs", &["-u"]), InitramfsType::Debian => run_command("update-initramfs", &["-u"]),
InitramfsType::Mkinitcpio => run_command("mkinitcpio", &["-P"]), InitramfsType::Mkinitcpio => run_command("mkinitcpio", &["-P"]),
InitramfsType::Dracut => run_command("dracut", &["--regenerate-all", "--force"]),
}; };
result.map(|()| initramfs_type) result.map(|()| initramfs_type)
} }
@ -111,6 +112,13 @@ fn detect_initramfs_type(os_release: &OsRelease) -> Option<InitramfsType> {
); );
None 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 { } else {
None None
} }

View File

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