add more helpful message in case of append_initrd_secrets script failure

This commit is contained in:
Julien Malka 2023-11-03 22:29:11 +01:00
parent f707a9be9f
commit f06680ea68
1 changed files with 5 additions and 3 deletions

View File

@ -223,7 +223,7 @@ impl Installer {
) )
.context("Failed to copy the initrd to the temporary directory.")?; .context("Failed to copy the initrd to the temporary directory.")?;
if let Some(initrd_secrets_script) = &bootspec.initrd_secrets { if let Some(initrd_secrets_script) = &bootspec.initrd_secrets {
append_initrd_secrets(initrd_secrets_script, &initrd_location)?; append_initrd_secrets(initrd_secrets_script, &initrd_location, generation.version)?;
} }
let initrd_target = self let initrd_target = self
.install_nixos_ca(&initrd_location, &format!("initrd-{}", kernel_version)) .install_nixos_ca(&initrd_location, &format!("initrd-{}", kernel_version))
@ -438,6 +438,7 @@ fn force_install(from: &Path, to: &Path) -> Result<()> {
pub fn append_initrd_secrets( pub fn append_initrd_secrets(
append_initrd_secrets_path: &Path, append_initrd_secrets_path: &Path,
initrd_path: &PathBuf, initrd_path: &PathBuf,
generation_version: u64,
) -> Result<()> { ) -> Result<()> {
let status = Command::new(append_initrd_secrets_path) let status = Command::new(append_initrd_secrets_path)
.args(vec![initrd_path]) .args(vec![initrd_path])
@ -445,8 +446,9 @@ pub fn append_initrd_secrets(
.context("Failed to append initrd secrets")?; .context("Failed to append initrd secrets")?;
if !status.success() { if !status.success() {
return Err(anyhow::anyhow!( return Err(anyhow::anyhow!(
"Failed to append initrd secrets with args `{:?}`", "Failed to append initrd secrets for generation {} with args `{:?}`",
vec![append_initrd_secrets_path, initrd_path] generation_version,
vec![append_initrd_secrets_path, initrd_path],
)); ));
} }