aboutsummaryrefslogtreecommitdiff
path: root/src/gentoo
diff options
context:
space:
mode:
authorpablu <me@pablu.de>2026-05-08 15:32:12 +0200
committerpablu <me@pablu.de>2026-05-08 15:32:12 +0200
commitb6487e2009cb2191ef70fc6feefb38a0b6db1543 (patch)
treee316d8b314ec1388372e159fb60dbf0bece2469b /src/gentoo
parent8a1f6b186bde43323003c440910d43e0db8a7bc3 (diff)
some dashboard stuff
Diffstat (limited to 'src/gentoo')
-rw-r--r--src/gentoo/package.rs3
-rw-r--r--src/gentoo/portage.rs15
2 files changed, 17 insertions, 1 deletions
diff --git a/src/gentoo/package.rs b/src/gentoo/package.rs
index 1d7b3f3..3ead2a4 100644
--- a/src/gentoo/package.rs
+++ b/src/gentoo/package.rs
@@ -11,6 +11,7 @@ pub struct Package {
pub description: Option<String>,
pub homepage: Option<Vec<String>>,
pub license: Option<String>,
+ pub size: usize,
}
#[allow(dead_code)]
@@ -19,6 +20,7 @@ impl Package {
name: String,
version: String,
repository: String,
+ size: usize,
homepage: Option<Vec<String>>,
license: Option<String>,
description: Option<String>,
@@ -34,6 +36,7 @@ impl Package {
description: description,
homepage: homepage,
license: license,
+ size,
}
}
}
diff --git a/src/gentoo/portage.rs b/src/gentoo/portage.rs
index a28ed19..28d05da 100644
--- a/src/gentoo/portage.rs
+++ b/src/gentoo/portage.rs
@@ -7,6 +7,7 @@ use crate::gentoo::{Package, UseFlag};
#[derive(Debug)]
pub struct Portage {
pub installed_packages: Vec<Package>,
+ pub world_packages: Vec<String>,
}
fn split_pkg(input: &str) -> (&str, Option<&str>) {
@@ -70,9 +71,16 @@ impl Portage {
pub fn new() -> Self {
Self {
installed_packages: vec![],
+ world_packages: vec![],
}
}
+ pub fn load_world_packages(&mut self) -> io::Result<()> {
+ let world = fs::read_to_string("/var/lib/portage/world")?;
+ self.world_packages = world.split_whitespace().map(|s| s.to_string()).collect();
+ Ok(())
+ }
+
pub fn load_installed_packages(&mut self) -> io::Result<()> {
let categories = fs::read_dir("/var/db/pkg")?;
@@ -113,7 +121,6 @@ impl Portage {
})
.collect();
- // let category = fs::read_to_string(pkg.path().join("CATEGORY"))?;
let repository = fs::read_to_string(pkg.path().join("repository"))?
.trim()
.to_string();
@@ -136,6 +143,11 @@ impl Portage {
Err(_) => None,
};
+ let size: usize = match fs::read_to_string(pkg.path().join("SIZE")) {
+ Ok(size) => size.trim().parse().unwrap_or(0),
+ Err(_) => 0,
+ };
+
let repo_path = PathBuf::from("/var/db/repos/")
.join(&repository)
.join(cat_name.to_str().unwrap())
@@ -148,6 +160,7 @@ impl Portage {
format!("{}/{}", cat_name.to_str().unwrap(), pkg_name),
pkg_version.unwrap().into(),
repository,
+ size,
homepage,
license,
description,