mirror of
https://github.com/edera-dev/sprout.git
synced 2025-12-19 15:50:18 +00:00
implement support for filesystem extractor mechanism
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
use crate::actions::ActionDeclaration;
|
||||
use crate::drivers::DriverDeclaration;
|
||||
use crate::extractors::ExtractorDeclaration;
|
||||
use crate::generators::GeneratorDeclaration;
|
||||
use crate::utils;
|
||||
use anyhow::Context;
|
||||
use anyhow::Result;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::BTreeMap;
|
||||
use std::ops::Deref;
|
||||
use uefi::proto::device_path::LoadedImageDevicePath;
|
||||
|
||||
#[derive(Serialize, Deserialize, Default, Clone)]
|
||||
pub struct RootConfiguration {
|
||||
@@ -16,6 +19,8 @@ pub struct RootConfiguration {
|
||||
#[serde(default)]
|
||||
pub drivers: BTreeMap<String, DriverDeclaration>,
|
||||
#[serde(default)]
|
||||
pub extractors: BTreeMap<String, ExtractorDeclaration>,
|
||||
#[serde(default)]
|
||||
pub actions: BTreeMap<String, ActionDeclaration>,
|
||||
#[serde(default)]
|
||||
pub entries: BTreeMap<String, EntryDeclaration>,
|
||||
@@ -49,8 +54,13 @@ pub struct PhaseConfiguration {
|
||||
}
|
||||
|
||||
pub fn load() -> Result<RootConfiguration> {
|
||||
let content =
|
||||
utils::read_file_contents("sprout.toml").context("unable to read sprout.toml file")?;
|
||||
let current_image_device_path_protocol =
|
||||
uefi::boot::open_protocol_exclusive::<LoadedImageDevicePath>(uefi::boot::image_handle())
|
||||
.context("failed to get loaded image device path")?;
|
||||
let path = current_image_device_path_protocol.deref().to_boxed();
|
||||
|
||||
let content = utils::read_file_contents(&path, "sprout.toml")
|
||||
.context("unable to read sprout.toml file")?;
|
||||
let config: RootConfiguration =
|
||||
toml::from_slice(&content).context("unable to parse sprout.toml file")?;
|
||||
Ok(config)
|
||||
|
||||
Reference in New Issue
Block a user