From 8b7e357c0e2b62595c17b15ad0e9b467f8f90bbc Mon Sep 17 00:00:00 2001 From: JMARyA Date: Sat, 18 Jan 2025 19:12:11 +0100 Subject: [PATCH] add more package info --- src/pkg/package.rs | 60 +++++++++++++++++++++++++++++++++++++++++- src/routes/ui.rs | 65 +++++++++++++++++++++++++++++++++++++++------- 2 files changed, 115 insertions(+), 10 deletions(-) diff --git a/src/pkg/package.rs b/src/pkg/package.rs index d61a4a6..61e91e3 100644 --- a/src/pkg/package.rs +++ b/src/pkg/package.rs @@ -205,6 +205,64 @@ impl Package { .collect() } + pub fn kernel_modules(&self) -> Vec { + let files = self.file_list(); + files + .into_iter() + .filter(|x| x.starts_with("usr/lib/modules")) + .map(|x| { + x.trim_start_matches("usr/lib/modules/") + .trim_end_matches(".zst") + .to_string() + }) + .collect() + } + + pub fn firmware(&self) -> Vec { + let files = self.file_list(); + files + .into_iter() + .filter(|x| x.starts_with("usr/lib/firmware")) + .map(|x| { + x.trim_start_matches("usr/lib/firmware/") + .trim_end_matches(".zst") + .to_string() + }) + .collect() + } + + pub fn keyrings(&self) -> Vec { + let files = self.file_list(); + files + .into_iter() + .filter(|x| x.starts_with("usr/share/pacman/keyrings")) + .map(|x| { + x.trim_start_matches("usr/share/pacman/keyrings/") + .to_string() + }) + .collect() + } + + pub fn shared_objects(&self) -> Vec { + list_tar_file(&self.base_path().join(self.file_name())) + .unwrap_or_default() + .into_iter() + .filter(|x| { + let file_name = x.split("/").last().unwrap(); + file_name.contains(".so.") || file_name.ends_with(".so") + }) + .collect() + } + + pub fn icons(&self) -> Vec { + let files = self.file_list(); + files + .into_iter() + .filter(|x| x.starts_with("usr/share/icons")) + .map(|x| x.trim_start_matches("usr/share/icons/").to_string()) + .collect() + } + pub fn etc_entries(&self) -> Vec { let files = self.file_list(); files.into_iter().filter(|x| x.starts_with("etc")).collect() @@ -217,7 +275,7 @@ impl Package { .into_iter() .filter(|x| { let ext = x.split(".").last().unwrap(); - ext == "service" || ext == "timer" || ext == "mount" + ext == "service" || ext == "timer" || ext == "mount" || ext == "socket" }) .collect() } diff --git a/src/routes/ui.rs b/src/routes/ui.rs index 5a71a8e..48aa564 100644 --- a/src/routes/ui.rs +++ b/src/routes/ui.rs @@ -38,6 +38,11 @@ pub async fn pkg_ui( let binaries = pkg.binaries(); let man_entries = pkg.man_entries(); let etc_entries = pkg.etc_entries(); + let kernel_modules = pkg.kernel_modules(); + let firmware = pkg.firmware(); + let keyrings = pkg.keyrings(); + let shared_objects = pkg.shared_objects(); + let icons = pkg.icons(); let mut pkginfo = pkg.pkginfo(); let content = Div().vanish() @@ -218,7 +223,47 @@ pub async fn pkg_ui( ListElements(&binaries) ) ) + ) .push_if(!kernel_modules.is_empty(), + || InfoCard( + Div().vanish() + .push(CardTitle("Kernel Modules")) + .push( + ListElements(&kernel_modules) + ) ) + ).push_if(!shared_objects.is_empty(), + || InfoCard( + Div().vanish() + .push(CardTitle("Shared Objects (Libraries)")) + .push( + ListElements(&shared_objects) + ) + ) + ).push_if(!firmware.is_empty(), + || InfoCard( + Div().vanish() + .push(CardTitle("Firmware")) + .push( + ListElements(&firmware) + ) + ) + ).push_if(!keyrings.is_empty(), + || InfoCard( + Div().vanish() + .push(CardTitle("Pacman Keyrings")) + .push( + ListElements(&keyrings) + ) + ) + ).push_if(!icons.is_empty(), + || InfoCard( + Div().vanish() + .push(CardTitle("Icons")) + .push( + ListElements(&icons) + ) + ) + ) .push_if(!man_entries.is_empty(), || InfoCard( Div().vanish() @@ -316,14 +361,11 @@ pub async fn repo_ui( .push_if(config.is_mirrored_repo(&repo.name), || { Background( Blue::_500, - Rounded( - Margin( - Padding(Text("Mirrored").sm().medium().white()) - .x(ScreenValue::_3) - .y(ScreenValue::_1), - ) - .left(ScreenValue::_4), - ) + Rounded(Margin( + Padding(Text("Mirrored").sm().medium().white()) + .x(ScreenValue::_3) + .y(ScreenValue::_1), + )) .size(Size::Full), ) }) @@ -345,10 +387,15 @@ pub async fn repo_ui( .group() .gap(ScreenValue::_2), ) - .left(ScreenValue::_4) .top(ScreenValue::_2)), + ) + .push( + Text(&format!("{} packages", packages.len())) + .sm() + .color(&Gray::_100), ), ) + .gap(ScreenValue::_3) .wrap(Wrap::Wrap) .full_center() .group(),