2025-11-02 23:28:31 -05:00
|
|
|
use crate::entries::EntryDeclaration;
|
2025-11-03 02:04:21 -05:00
|
|
|
use alloc::string::{String, ToString};
|
2025-11-02 23:28:31 -05:00
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
|
|
|
|
|
/// The default path to the BLS directory.
|
|
|
|
|
const BLS_TEMPLATE_PATH: &str = "\\loader";
|
|
|
|
|
|
|
|
|
|
/// The configuration of the BLS generator.
|
|
|
|
|
/// The BLS uses the Bootloader Specification to produce
|
|
|
|
|
/// entries from an input template.
|
2026-10-03 15:16:05 -07:00
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
2025-11-02 23:28:31 -05:00
|
|
|
pub struct BlsConfiguration {
|
|
|
|
|
/// The entry to use for as a template.
|
|
|
|
|
pub entry: EntryDeclaration,
|
|
|
|
|
/// The path to the BLS directory.
|
|
|
|
|
#[serde(default = "default_bls_path")]
|
|
|
|
|
pub path: String,
|
2026-10-03 15:16:05 -07:00
|
|
|
/// Whether generated entries keep the name of the BLS entry file as-is.
|
|
|
|
|
/// When enabled, the generator name is not prepended, so the entry names match
|
|
|
|
|
/// the BLS entry ids used by tools like `bootctl set-default`. Variants still append
|
|
|
|
|
/// their choice names, so entries of a generator with variants never match the ids
|
|
|
|
|
/// exactly, and are best selected with a pattern like `<id>-*`. Two BLS generators
|
|
|
|
|
/// that read the same BLS directory will produce entries with the same names, so
|
|
|
|
|
/// generators that reuse a BLS directory should disable this.
|
|
|
|
|
#[serde(default = "default_pin_names", rename = "pin-names")]
|
|
|
|
|
pub pin_names: bool,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// The default configuration, which matches an empty BLS generator section.
|
|
|
|
|
impl Default for BlsConfiguration {
|
|
|
|
|
fn default() -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
entry: Default::default(),
|
|
|
|
|
path: default_bls_path(),
|
|
|
|
|
pin_names: default_pin_names(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn default_pin_names() -> bool {
|
|
|
|
|
true
|
2025-11-02 23:28:31 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn default_bls_path() -> String {
|
|
|
|
|
BLS_TEMPLATE_PATH.to_string()
|
|
|
|
|
}
|