8 Commits

Author SHA1 Message Date
db43560be5 read repo_name when opening repos
All checks were successful
Gentoo Utils / build-oci-image (pull_request) Successful in 9s
Gentoo Utils / build (pull_request) Successful in 39s
2025-12-12 01:59:57 +00:00
4544507c00 default to Eapi 0 if no eapi file exists 2025-12-12 01:57:11 +00:00
13ccf1ed25 add docs to profile module 2025-12-12 01:57:11 +00:00
dafdc05dff read deprecated file in profiles 2025-12-12 01:57:11 +00:00
70c8437830 read eapi file in profiles 2025-12-12 01:57:11 +00:00
f3718d143a add profile related source files to sources variable 2025-12-12 01:57:11 +00:00
12d362983d impl profile evaluation 2025-12-12 01:57:11 +00:00
e67e20ef29 give fuzzer related targets unique names
All checks were successful
Gentoo Utils / build-oci-image (push) Successful in 12s
Gentoo Utils / build (push) Successful in 33s
2025-12-12 01:56:38 +00:00
9 changed files with 29 additions and 13 deletions

View File

@@ -20,7 +20,7 @@ fn main() -> Result<(), Box<dyn Error>> {
fs::create_dir_all(&corpus_dir)?; fs::create_dir_all(&corpus_dir)?;
let repo = Repo::new("/var/db/repos/gentoo"); let repo = Repo::new("/var/db/repos/gentoo").expect("failed to open repo");
let mut atoms = Vec::new(); let mut atoms = Vec::new();
for category in repo.categories()? { for category in repo.categories()? {

View File

@@ -1,12 +1,12 @@
gencorpus = executable( gencorpus = executable(
'gencorpus', 'atom_parser_gencorpus',
'gencorpus.rs', 'gencorpus.rs',
dependencies: [mon], dependencies: [mon],
link_with: [gentoo_utils], link_with: [gentoo_utils],
) )
corpus = custom_target( corpus = custom_target(
'corpus', 'atom_parser_corpus',
output: 'corpus', output: 'corpus',
command: [gencorpus, 'corpus'], command: [gencorpus, 'corpus'],
) )

View File

@@ -17,7 +17,7 @@ fn main() -> Result<(), Box<dyn Error>> {
fs::create_dir_all(&corpus_dir)?; fs::create_dir_all(&corpus_dir)?;
let repo = Repo::new("/var/db/repos/gentoo"); let repo = Repo::new("/var/db/repos/gentoo").expect("failed to open repo");
let mut versions = Vec::new(); let mut versions = Vec::new();
for category in repo.categories()? { for category in repo.categories()? {

View File

@@ -1,12 +1,12 @@
gencorpus = executable( gencorpus = executable(
'gencorpus', 'atom_vercmp_gencorpus',
'gencorpus.rs', 'gencorpus.rs',
dependencies: [mon], dependencies: [mon],
link_with: [gentoo_utils], link_with: [gentoo_utils],
) )
corpus = custom_target( corpus = custom_target(
'corpus', 'atom_vercmp_corpus',
output: 'corpus', output: 'corpus',
command: [gencorpus, 'corpus'], command: [gencorpus, 'corpus'],
) )

View File

@@ -69,7 +69,8 @@ pub mod atom;
/// ``` /// ```
/// use gentoo_utils::repo::Repo; /// use gentoo_utils::repo::Repo;
/// ///
/// let repo = Repo::new("/var/db/repos/gentoo"); /// let repo = Repo::new("/var/db/repos/gentoo")
/// .expect("failed to open repo");
/// ///
/// for result in repo.categories().expect("failed to read categories") { /// for result in repo.categories().expect("failed to read categories") {
/// let category = result.expect("failed to read category"); /// let category = result.expect("failed to read category");

View File

@@ -23,6 +23,8 @@ pub mod profile;
#[derive(Debug, thiserror::Error)] #[derive(Debug, thiserror::Error)]
pub enum Error { pub enum Error {
#[error("invalid repo: {0}")]
Invalid(String),
#[error("io error: {0}")] #[error("io error: {0}")]
Io(PathBuf, io::Error), Io(PathBuf, io::Error),
#[error("error while reading directory: {0:?}: {1}")] #[error("error while reading directory: {0:?}: {1}")]
@@ -39,6 +41,8 @@ pub enum Error {
pub struct Repo { pub struct Repo {
#[get(kind = "deref")] #[get(kind = "deref")]
path: PathBuf, path: PathBuf,
#[get(kind = "deref")]
name: String,
} }
#[derive(Debug, Clone, Get)] #[derive(Debug, Clone, Get)]
@@ -55,10 +59,20 @@ pub struct Categories(PathBuf, fs::ReadDir);
pub struct Ebuilds(PathBuf, fs::ReadDir); pub struct Ebuilds(PathBuf, fs::ReadDir);
impl Repo { impl Repo {
pub fn new<P: AsRef<Path>>(path: P) -> Self { pub fn new<P: AsRef<Path>>(path: P) -> Result<Self, Error> {
Self { let name_path = path.as_ref().join("profiles/repo_name");
let name = match fs::read_to_string(&name_path) {
Ok(repo_name) => repo_name,
Err(e) if matches!(e.kind(), io::ErrorKind::NotFound) => {
return Err(Error::Invalid("missing repo_name".to_string()));
}
Err(e) => return Err(Error::Io(name_path, e)),
};
Ok(Self {
path: path.as_ref().to_path_buf(), path: path.as_ref().to_path_buf(),
} name,
})
} }
pub fn categories(&self) -> Result<Categories, Error> { pub fn categories(&self) -> Result<Categories, Error> {

View File

@@ -2,7 +2,8 @@
//! ```rust //! ```rust
//! use gentoo_utils::repo::Repo; //! use gentoo_utils::repo::Repo;
//! //!
//! let repo = Repo::new("/var/db/repos/gentoo"); //! let repo = Repo::new("/var/db/repos/gentoo")
//! .expect("failed to open repo");
//! let profile = repo.evaluate_profile("default/linux/23.0") //! let profile = repo.evaluate_profile("default/linux/23.0")
//! .expect("failed to evaluate profile"); //! .expect("failed to evaluate profile");
//! //!

View File

@@ -474,7 +474,7 @@ fn main() {
"prefix/sunos/solaris/5.11/x64", "prefix/sunos/solaris/5.11/x64",
]; ];
let repo = Repo::new("/var/db/repos/gentoo"); let repo = Repo::new("/var/db/repos/gentoo").expect("failed to open repo");
for profile in profiles { for profile in profiles {
repo.evaluate_profile(profile) repo.evaluate_profile(profile)

View File

@@ -3,7 +3,7 @@ use std::error::Error;
use gentoo_utils::repo::Repo; use gentoo_utils::repo::Repo;
fn main() -> Result<(), Box<dyn Error>> { fn main() -> Result<(), Box<dyn Error>> {
let repo = Repo::new("/var/db/repos/gentoo"); let repo = Repo::new("/var/db/repos/gentoo").unwrap();
for result in repo.categories()? { for result in repo.categories()? {
let cat = result?; let cat = result?;