feat(autoconfigure): generate names using a unique hash

This commit is contained in:
2025-10-27 18:21:28 -04:00
parent 3bbe6561ef
commit e7f5be30dd
6 changed files with 151 additions and 6 deletions

View File

@@ -4,6 +4,7 @@ use crate::config::RootConfiguration;
use crate::entries::EntryDeclaration;
use crate::generators::GeneratorDeclaration;
use crate::generators::bls::BlsConfiguration;
use crate::utils;
use anyhow::{Context, Result};
use uefi::cstr16;
use uefi::fs::{FileSystem, Path};
@@ -33,6 +34,9 @@ pub fn scan(
// Add a trailing slash to the root to ensure the path is valid.
root.push('/');
// Generate a unique hash of the root path.
let root_unique_hash = utils::unique_hash(&root);
// Whether we have a loader.conf file.
let has_loader_conf = filesystem
.try_exists(bls_loader_conf_path)
@@ -54,7 +58,7 @@ pub fn scan(
}
// Generate a unique name for the BLS chainload action.
let chainload_action_name = format!("{}{}", BLS_CHAINLOAD_ACTION_PREFIX, root);
let chainload_action_name = format!("{}{}", BLS_CHAINLOAD_ACTION_PREFIX, root_unique_hash,);
// BLS is now detected, generate a configuration for it.
let generator = BlsConfiguration {
@@ -68,7 +72,7 @@ pub fn scan(
// Generate a unique name for the BLS generator and insert the generator into the configuration.
config.generators.insert(
format!("autoconfigure-bls-{}", root),
format!("autoconfigure-bls-{}", root_unique_hash),
GeneratorDeclaration {
bls: Some(generator),
..Default::default()