6 Commits

Author SHA1 Message Date
90feca00b6 default to Eapi 0 if no eapi file exists
All checks were successful
Gentoo Utils / build-oci-image (pull_request) Successful in 9s
Gentoo Utils / build (pull_request) Successful in 36s
2025-12-11 23:50:12 +00:00
71e413b986 add docs to profile module 2025-12-11 23:49:16 +00:00
12d70664a4 read deprecated file in profiles 2025-12-11 23:49:16 +00:00
607da348af read eapi file in profiles 2025-12-11 23:49:16 +00:00
25ebcd10da add profile related source files to sources variable 2025-12-11 23:49:16 +00:00
f86b1dbf84 impl profile evaluation 2025-12-11 23:49:16 +00:00
9 changed files with 13 additions and 29 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").expect("failed to open repo"); let repo = Repo::new("/var/db/repos/gentoo");
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(
'atom_parser_gencorpus', 'gencorpus',
'gencorpus.rs', 'gencorpus.rs',
dependencies: [mon], dependencies: [mon],
link_with: [gentoo_utils], link_with: [gentoo_utils],
) )
corpus = custom_target( corpus = custom_target(
'atom_parser_corpus', '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").expect("failed to open repo"); let repo = Repo::new("/var/db/repos/gentoo");
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(
'atom_vercmp_gencorpus', 'gencorpus',
'gencorpus.rs', 'gencorpus.rs',
dependencies: [mon], dependencies: [mon],
link_with: [gentoo_utils], link_with: [gentoo_utils],
) )
corpus = custom_target( corpus = custom_target(
'atom_vercmp_corpus', 'corpus',
output: 'corpus', output: 'corpus',
command: [gencorpus, 'corpus'], command: [gencorpus, 'corpus'],
) )

View File

@@ -69,8 +69,7 @@ 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,8 +23,6 @@ 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}")]
@@ -41,8 +39,6 @@ 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)]
@@ -59,20 +55,10 @@ 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) -> Result<Self, Error> { pub fn new<P: AsRef<Path>>(path: P) -> Self {
let name_path = path.as_ref().join("profiles/repo_name"); Self {
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,8 +2,7 @@
//! ```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").expect("failed to open repo"); let repo = Repo::new("/var/db/repos/gentoo");
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").unwrap(); let repo = Repo::new("/var/db/repos/gentoo");
for result in repo.categories()? { for result in repo.categories()? {
let cat = result?; let cat = result?;