diff options
| author | John Turner <jturner.usa@gmail.com> | 2025-12-11 01:55:26 +0000 |
|---|---|---|
| committer | John Turner <jturner.usa@gmail.com> | 2025-12-14 01:37:49 +0000 |
| commit | 7c18c9db14fd187de0b0668c3b7a8499d49b54ac (patch) | |
| tree | 6d539ab534a982d13b61af5cddd384b0366bb40a | |
| parent | 17a27cfdad301803a5b1d51690e6aecc7ad51c2e (diff) | |
| download | gentoo-utils-7c18c9db14fd187de0b0668c3b7a8499d49b54ac.tar.gz | |
read eapi file in profiles
| -rw-r--r-- | src/repo/profile/mod.rs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/repo/profile/mod.rs b/src/repo/profile/mod.rs index 3edd170..edbc880 100644 --- a/src/repo/profile/mod.rs +++ b/src/repo/profile/mod.rs @@ -8,7 +8,7 @@ use std::{ use get::Get; use itertools::Itertools; -use crate::{atom::Atom, useflag::UseFlag}; +use crate::{Parseable, atom::Atom, repo::ebuild::Eapi, useflag::UseFlag}; mod make_defaults; mod package; @@ -43,12 +43,15 @@ pub enum Error { PackageUse(#[from] package_use::Error), #[error("error evaluating use settings: {0}")] Use(#[from] useflags::Error), + #[error("parser error: {0}")] + Parser(String), } #[derive(Debug, Clone, Get)] pub struct Profile { #[get(kind = "deref")] path: PathBuf, + eapi: Option<Eapi>, #[get(kind = "deref")] parents: Vec<Profile>, make_defaults: HashMap<String, String>, @@ -87,6 +90,16 @@ impl Profile { Err(e) => return Err(Error::Io(parents_path, e)), }; + let eapi_path = path.as_ref().join("eapi"); + let eapi = match fs::read_to_string(&eapi_path) + .map(|s| Eapi::parse(s.trim()).map_err(str::to_string)) + { + Ok(Ok(eapi)) => Some(eapi), + Ok(Err(rest)) => return Err(Error::Parser(rest)), + Err(e) if matches!(e.kind(), io::ErrorKind::NotFound) => None, + Err(e) => return Err(Error::Io(eapi_path, e)), + }; + let make_defaults = make_defaults::evaluate(&parents, &path)?; let packages = packages::evaluate(&parents, &path)?; @@ -110,6 +123,7 @@ impl Profile { Ok(Self { path: path.as_ref().to_path_buf(), parents, + eapi, make_defaults, packages, package_mask, |
