Skip to content

Commit

Permalink
blsforme: Respect sysroot when loading kernel specific cmdline
Browse files Browse the repository at this point in the history
This ensures nvidia parameters are still added.

Signed-off-by: Ikey Doherty <[email protected]>
  • Loading branch information
ikeycode committed Jan 4, 2025
1 parent fa9c46f commit 3cb315d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 30 deletions.
6 changes: 1 addition & 5 deletions blsforme/src/bootloader/systemd_boot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,12 @@ impl<'a, 'b> Loader<'a, 'b> {
.filter(|c| !exclusions.contains(&c.name))
.map(|c| c.snippet.clone())
.collect::<Vec<_>>();
let mut full_cmdline = base_cmdline
let full_cmdline = base_cmdline
.iter()
.chain(entry_cmdline.iter())
.cloned()
.collect::<Vec<_>>();

// kernel specific cmdline
if let Some(k_cmdline) = entry.kernel.cmdline.as_ref() {
full_cmdline.push(k_cmdline.clone());
}
let installed = self.install(&full_cmdline.join(" "), entry)?;
installed_entries.push(installed);
}
Expand Down
17 changes: 17 additions & 0 deletions blsforme/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,23 @@ impl<'a> Entry<'a> {
/// Load cmdline snippets from the system root for this entry's sysroot
pub fn load_cmdline_snippets(&mut self, config: &Configuration) -> Result<(), super::Error> {
let sysroot = self.sysroot.clone().unwrap_or(config.root.path().into());

// Load local cmdline snippets for this kernel entry
for snippet in self
.kernel
.extras
.iter()
.filter(|e| matches!(e.kind, crate::AuxiliaryKind::Cmdline))
{
if let Ok(cmdline) = cmdline_snippet(sysroot.join(&snippet.path)) {
self.cmdline.push(CmdlineEntry {
name: snippet.path.file_name().unwrap().to_string_lossy().to_string(),
snippet: cmdline,
});
}
}

// Globals
let cmdline_d = sysroot.join("usr").join("lib").join("kernel").join("cmdline.d");

if !cmdline_d.exists() {
Expand Down
26 changes: 1 addition & 25 deletions blsforme/src/kernel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::{

use serde::Deserialize;

use crate::{file_utils::cmdline_snippet, os_release::OsRelease, Error};
use crate::{os_release::OsRelease, Error};

/// Control kernel discovery mechanism
#[derive(Debug)]
Expand Down Expand Up @@ -70,8 +70,6 @@ pub struct Kernel {

/// Recorded variant type
pub variant: Option<String>,

pub cmdline: Option<String>,
}

/// Denotes the kind of auxiliary file
Expand Down Expand Up @@ -119,24 +117,6 @@ impl Schema<'_> {
}
}

fn load_cmdline(kernel: &Kernel) -> Result<String, Error> {
// Load local cmdline snippets for this kernel entry
let mut cmdline = String::new();
for snippet in kernel
.extras
.iter()
.filter(|e| matches!(e.kind, crate::AuxiliaryKind::Cmdline))
{
let snippet = cmdline_snippet(&snippet.path)?;
cmdline.push_str(&snippet);
cmdline.push(' ');
}

log::trace!("kernel-specific cmdline for {:?}: {cmdline}", kernel.image);

Ok(cmdline.trim().to_string())
}

/// Discover any legacy kernels
fn legacy_kernels(
namespace: &'static str,
Expand Down Expand Up @@ -171,7 +151,6 @@ impl Schema<'_> {
initrd: vec![],
extras: vec![],
variant: Some(variant.to_string()),
cmdline: None,
},
);
}
Expand Down Expand Up @@ -266,7 +245,6 @@ impl Schema<'_> {
kernel
.extras
.sort_by_key(|e| e.path.display().to_string().to_lowercase());
kernel.cmdline = Self::load_cmdline(kernel).ok().filter(|s| !s.is_empty());
}
Ok(kernels.into_values().collect::<Vec<_>>())
}
Expand All @@ -289,7 +267,6 @@ impl Schema<'_> {
initrd: vec![],
extras: vec![],
variant: None,
cmdline: None,
},
))
})
Expand Down Expand Up @@ -350,7 +327,6 @@ impl Schema<'_> {
kernel
.extras
.sort_by_key(|e| e.path.display().to_string().to_lowercase());
kernel.cmdline = Self::load_cmdline(kernel).ok().filter(|s| !s.is_empty());
}
}

Expand Down

0 comments on commit 3cb315d

Please sign in to comment.