From 25f39c857da591c665865b77483b79495caf5e00 Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Wed, 12 Aug 2026 00:02:26 +0000 Subject: Replace legacy profile parser with typed image spec --- src/lib.rs | 64 ++++---------------------------------------------------------- 1 file changed, 4 insertions(+), 60 deletions(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index b7bf8c2..a62cbde 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,61 +1,5 @@ -use std::fs; -use std::path::{Path, PathBuf}; +pub mod model; +pub mod plan; -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct Profile { - pub packages: Vec, - pub regex_packages: Vec, -} - -impl Profile { - pub fn load(path: &Path) -> Result { - let profile = fs::read_to_string(path).map_err(|error| error.to_string())?; - let parent = path.parent().ok_or("profile path has no parent")?; - let mut packages = Vec::new(); - let mut regex_packages = Vec::new(); - - for line in profile.lines() { - let line = line.trim(); - if line.is_empty() || line.starts_with('#') { - continue; - } - if let Some(values) = line.strip_prefix("base:") { - extend_words(&mut packages, values); - } else if let Some(relative) = line.strip_prefix("include:") { - let list = parent.join(relative.trim()); - let contents = fs::read_to_string(&list) - .map_err(|error| format!("{}: {error}", list.display()))?; - for entry in contents.lines().map(str::trim) { - if entry.is_empty() || entry.starts_with('#') { - continue; - } - let package = entry.split('@').next().unwrap_or(entry).trim(); - if !package.is_empty() { - packages.push(package.to_owned()); - } - } - } else if let Some(value) = line.strip_prefix("regex:") { - regex_packages.push(value.trim().to_owned()); - } else { - return Err(format!("unsupported profile statement: {line}")); - } - } - packages.sort(); - packages.dedup(); - regex_packages.sort(); - regex_packages.dedup(); - Ok(Self { packages, regex_packages }) - } - - pub fn install_arguments(&self) -> Vec { - self.regex_packages.iter().chain(self.packages.iter()).cloned().collect() - } -} - -fn extend_words(target: &mut Vec, values: &str) { - target.extend(values.split_whitespace().map(str::to_owned)); -} - -pub fn artifact_path(project: &Path) -> PathBuf { - project.join("out/alt-controller-rootfs.tar") -} +pub use model::{Architecture, BootSpec, ImageSpec, OutputFormat, PackageSelector, PackageSpec, Target}; +pub use plan::BuildPlan; -- cgit v1.2.3