summaryrefslogtreecommitdiff
path: root/src/repo/mod.rs
diff options
context:
space:
mode:
authorJohn Turner <jturner.usa@gmail.com>2025-12-13 04:49:28 +0000
committerJohn Turner <jturner.usa@gmail.com>2025-12-14 01:37:49 +0000
commit870800c98504f48dd74c97bd2d03209fe3eea99f (patch)
tree91a68e4a5757d57fb74e11f34b32526b69890b01 /src/repo/mod.rs
parent985f0332762fbe5b57ed6527f156899b7afe2a87 (diff)
downloadgentoo-utils-870800c98504f48dd74c97bd2d03209fe3eea99f.tar.gz
read global package.mask
Diffstat (limited to 'src/repo/mod.rs')
-rw-r--r--src/repo/mod.rs28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/repo/mod.rs b/src/repo/mod.rs
index 165f96a..5db8a6f 100644
--- a/src/repo/mod.rs
+++ b/src/repo/mod.rs
@@ -13,7 +13,7 @@ use crate::{
atom::{self, Atom},
repo::{
ebuild::{Depend, Eapi, Ebuild, Eclass, License, SrcUri},
- profile::Profile,
+ profile::{LineBasedFileExpr, Profile},
},
useflag::IUseFlag,
};
@@ -43,6 +43,8 @@ pub struct Repo {
path: PathBuf,
#[get(kind = "deref")]
name: String,
+ #[get(kind = "deref")]
+ package_mask: Vec<Atom>,
}
#[derive(Debug, Clone, Get)]
@@ -69,9 +71,19 @@ impl Repo {
Err(e) => return Err(Error::Io(name_path, e)),
};
+ let package_mask_path = path.as_ref().join("profiles/package.mask");
+ let package_mask =
+ match fs::read_to_string(&package_mask_path).map(|s| read_package_mask(&s)) {
+ Ok(Ok(package_mask)) => package_mask,
+ Ok(Err(e)) => return Err(e),
+ Err(e) if matches!(e.kind(), io::ErrorKind::NotFound) => Vec::new(),
+ Err(e) => return Err(Error::Io(package_mask_path, e)),
+ };
+
Ok(Self {
path: path.as_ref().to_path_buf(),
name,
+ package_mask,
})
}
@@ -340,6 +352,20 @@ fn read_idepend(input: &str) -> Option<Result<Vec<Depend<Atom>>, Error>> {
Some(parse_depends(line))
}
+fn read_package_mask(input: &str) -> Result<Vec<Atom>, Error> {
+ Ok(profile::LineBasedFileExpr::<Atom>::parser()
+ .separated_by_with_opt_trailing(ascii_whitespace1())
+ .many()
+ .parse_finished(InputIter::new(input))
+ .map_err(|it| Error::Parser(it.rest().to_string()))?
+ .into_iter()
+ .filter_map(|expr| match expr {
+ LineBasedFileExpr::Comment => None,
+ LineBasedFileExpr::Expr(atom) => Some(atom),
+ })
+ .collect())
+}
+
fn parse_depends(line: &str) -> Result<Vec<Depend<Atom>>, Error> {
Depend::<Atom>::parser()
.separated_by(ascii_whitespace1())