Skip to content

Commit 3cb315d

Browse files
committed
blsforme: Respect sysroot when loading kernel specific cmdline
This ensures nvidia parameters are still added. Signed-off-by: Ikey Doherty <[email protected]>
1 parent fa9c46f commit 3cb315d

File tree

3 files changed

+19
-30
lines changed

3 files changed

+19
-30
lines changed

blsforme/src/bootloader/systemd_boot/mod.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,12 @@ impl<'a, 'b> Loader<'a, 'b> {
120120
.filter(|c| !exclusions.contains(&c.name))
121121
.map(|c| c.snippet.clone())
122122
.collect::<Vec<_>>();
123-
let mut full_cmdline = base_cmdline
123+
let full_cmdline = base_cmdline
124124
.iter()
125125
.chain(entry_cmdline.iter())
126126
.cloned()
127127
.collect::<Vec<_>>();
128128

129-
// kernel specific cmdline
130-
if let Some(k_cmdline) = entry.kernel.cmdline.as_ref() {
131-
full_cmdline.push(k_cmdline.clone());
132-
}
133129
let installed = self.install(&full_cmdline.join(" "), entry)?;
134130
installed_entries.push(installed);
135131
}

blsforme/src/entry.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,23 @@ impl<'a> Entry<'a> {
4444
/// Load cmdline snippets from the system root for this entry's sysroot
4545
pub fn load_cmdline_snippets(&mut self, config: &Configuration) -> Result<(), super::Error> {
4646
let sysroot = self.sysroot.clone().unwrap_or(config.root.path().into());
47+
48+
// Load local cmdline snippets for this kernel entry
49+
for snippet in self
50+
.kernel
51+
.extras
52+
.iter()
53+
.filter(|e| matches!(e.kind, crate::AuxiliaryKind::Cmdline))
54+
{
55+
if let Ok(cmdline) = cmdline_snippet(sysroot.join(&snippet.path)) {
56+
self.cmdline.push(CmdlineEntry {
57+
name: snippet.path.file_name().unwrap().to_string_lossy().to_string(),
58+
snippet: cmdline,
59+
});
60+
}
61+
}
62+
63+
// Globals
4764
let cmdline_d = sysroot.join("usr").join("lib").join("kernel").join("cmdline.d");
4865

4966
if !cmdline_d.exists() {

blsforme/src/kernel.rs

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::{
1111

1212
use serde::Deserialize;
1313

14-
use crate::{file_utils::cmdline_snippet, os_release::OsRelease, Error};
14+
use crate::{os_release::OsRelease, Error};
1515

1616
/// Control kernel discovery mechanism
1717
#[derive(Debug)]
@@ -70,8 +70,6 @@ pub struct Kernel {
7070

7171
/// Recorded variant type
7272
pub variant: Option<String>,
73-
74-
pub cmdline: Option<String>,
7573
}
7674

7775
/// Denotes the kind of auxiliary file
@@ -119,24 +117,6 @@ impl Schema<'_> {
119117
}
120118
}
121119

122-
fn load_cmdline(kernel: &Kernel) -> Result<String, Error> {
123-
// Load local cmdline snippets for this kernel entry
124-
let mut cmdline = String::new();
125-
for snippet in kernel
126-
.extras
127-
.iter()
128-
.filter(|e| matches!(e.kind, crate::AuxiliaryKind::Cmdline))
129-
{
130-
let snippet = cmdline_snippet(&snippet.path)?;
131-
cmdline.push_str(&snippet);
132-
cmdline.push(' ');
133-
}
134-
135-
log::trace!("kernel-specific cmdline for {:?}: {cmdline}", kernel.image);
136-
137-
Ok(cmdline.trim().to_string())
138-
}
139-
140120
/// Discover any legacy kernels
141121
fn legacy_kernels(
142122
namespace: &'static str,
@@ -171,7 +151,6 @@ impl Schema<'_> {
171151
initrd: vec![],
172152
extras: vec![],
173153
variant: Some(variant.to_string()),
174-
cmdline: None,
175154
},
176155
);
177156
}
@@ -266,7 +245,6 @@ impl Schema<'_> {
266245
kernel
267246
.extras
268247
.sort_by_key(|e| e.path.display().to_string().to_lowercase());
269-
kernel.cmdline = Self::load_cmdline(kernel).ok().filter(|s| !s.is_empty());
270248
}
271249
Ok(kernels.into_values().collect::<Vec<_>>())
272250
}
@@ -289,7 +267,6 @@ impl Schema<'_> {
289267
initrd: vec![],
290268
extras: vec![],
291269
variant: None,
292-
cmdline: None,
293270
},
294271
))
295272
})
@@ -350,7 +327,6 @@ impl Schema<'_> {
350327
kernel
351328
.extras
352329
.sort_by_key(|e| e.path.display().to_string().to_lowercase());
353-
kernel.cmdline = Self::load_cmdline(kernel).ok().filter(|s| !s.is_empty());
354330
}
355331
}
356332

0 commit comments

Comments
 (0)