mirror of
https://github.com/arabianq/rpmi.git
synced 2026-06-19 13:03:33 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1008c37163 | |||
| 6feb4c02c1 | |||
| f5b85085fb | |||
| c5b04a8970 | |||
| 8e5195d233 | |||
| cedeb89d2f | |||
| 49b879d874 | |||
| 6f043f8222 |
Generated
+692
-518
File diff suppressed because it is too large
Load Diff
+4
-4
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "egui_rpm_installer"
|
name = "egui_rpm_installer"
|
||||||
version = "1.0.0"
|
version = "1.0.1"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
authors = ["arabianq"]
|
authors = ["arabianq"]
|
||||||
description = "Simple graphical utility that installs/upgrades/removes .rpm files built with Rust and EGUI."
|
description = "Simple graphical utility that installs/upgrades/removes .rpm files built with Rust and EGUI."
|
||||||
@@ -15,16 +15,16 @@ name = "rpmi"
|
|||||||
path = "src/main.rs"
|
path = "src/main.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
egui = { version = "0.33.3", default-features = false, features = [
|
egui = { version = "0.34.3", default-features = false, features = [
|
||||||
"default_fonts",
|
"default_fonts",
|
||||||
] }
|
] }
|
||||||
eframe = { version = "0.33.3", default-features = false, features = [
|
eframe = { version = "0.34.3", default-features = false, features = [
|
||||||
"default_fonts",
|
"default_fonts",
|
||||||
"glow",
|
"glow",
|
||||||
"wayland",
|
"wayland",
|
||||||
"x11",
|
"x11",
|
||||||
] }
|
] }
|
||||||
rpm = { version = "0.18.4", default-features = false, features = [] }
|
rpm = { version = "0.25.1", default-features = false, features = [] }
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
strip = true
|
strip = true
|
||||||
|
|||||||
+36
-42
@@ -43,47 +43,45 @@ pub fn get_package_state(pkg: &rpm::Package) -> PackageState {
|
|||||||
|
|
||||||
let child_stdout = child.stdout.take().expect("Couldn't take stdout");
|
let child_stdout = child.stdout.take().expect("Couldn't take stdout");
|
||||||
|
|
||||||
for line in BufReader::new(child_stdout).lines() {
|
for line in BufReader::new(child_stdout).lines().map_while(Result::ok) {
|
||||||
if let Ok(line) = line {
|
let parts: Vec<&str> = line.split_whitespace().collect();
|
||||||
let parts: Vec<&str> = line.split_whitespace().collect();
|
|
||||||
|
|
||||||
if parts.len() != 3 {
|
if parts.len() != 3 {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let name_splitted: Vec<&str> = parts[0].split(".").collect();
|
let name_splitted: Vec<&str> = parts[0].split(".").collect();
|
||||||
let (name, arch) = (name_splitted[0], name_splitted[1]);
|
let (name, arch) = (name_splitted[0], name_splitted[1]);
|
||||||
|
|
||||||
let version_prepared = parts[1]
|
let version_prepared = parts[1]
|
||||||
.split_once(':')
|
.split_once(':')
|
||||||
.map(|(_epoch, version)| version)
|
.map(|(_epoch, version)| version)
|
||||||
.unwrap_or(parts[1]);
|
.unwrap_or(parts[1]);
|
||||||
let version_splitted: Vec<&str> = version_prepared.split("-").collect();
|
let version_splitted: Vec<&str> = version_prepared.split("-").collect();
|
||||||
let (version, release) = (version_splitted[0], version_splitted[1]);
|
let (version, release) = (version_splitted[0], version_splitted[1]);
|
||||||
|
|
||||||
if pkg_name.eq(name) && pkg_arch.eq(arch) {
|
if pkg_name.eq(name) && pkg_arch.eq(arch) {
|
||||||
child.kill().unwrap();
|
child.kill().unwrap();
|
||||||
child.wait().unwrap();
|
child.wait().unwrap();
|
||||||
|
|
||||||
let package_entry = PackageEntry {
|
let package_entry = PackageEntry {
|
||||||
name: name.to_string(),
|
name: name.to_string(),
|
||||||
arch: arch.to_string(),
|
arch: arch.to_string(),
|
||||||
version: version.to_string(),
|
version: version.to_string(),
|
||||||
release: release.to_string(),
|
release: release.to_string(),
|
||||||
};
|
};
|
||||||
|
|
||||||
if pkg_version.eq(version) && pkg_release.eq(release) {
|
if pkg_version.eq(version) && pkg_release.eq(release) {
|
||||||
return PackageState::OldVersion;
|
return PackageState::OldVersion;
|
||||||
}
|
|
||||||
return PackageState::NewVersion(package_entry);
|
|
||||||
}
|
}
|
||||||
|
return PackageState::NewVersion(package_entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
child.kill().ok();
|
child.kill().ok();
|
||||||
child.wait().ok();
|
child.wait().ok();
|
||||||
|
|
||||||
return PackageState::NewPackage;
|
PackageState::NewPackage
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dnf_start_action(
|
pub fn dnf_start_action(
|
||||||
@@ -117,19 +115,15 @@ pub fn dnf_start_action(
|
|||||||
|
|
||||||
let stdout_thread = thread::spawn(move || {
|
let stdout_thread = thread::spawn(move || {
|
||||||
let stdout_lines = BufReader::new(child_stdout).lines();
|
let stdout_lines = BufReader::new(child_stdout).lines();
|
||||||
for line in stdout_lines {
|
for line in stdout_lines.map_while(Result::ok) {
|
||||||
if let Ok(line) = line {
|
stdout_tx.send(line).ok();
|
||||||
stdout_tx.send(line).ok();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let stderr_thread = thread::spawn(move || {
|
let stderr_thread = thread::spawn(move || {
|
||||||
let stderr_lines = BufReader::new(child_stderr).lines();
|
let stderr_lines = BufReader::new(child_stderr).lines();
|
||||||
for line in stderr_lines {
|
for line in stderr_lines.map_while(Result::ok) {
|
||||||
if let Ok(line) = line {
|
stderr_tx.send(line).ok();
|
||||||
stderr_tx.send(line).ok();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -148,5 +142,5 @@ pub fn dnf_start_action(
|
|||||||
child.wait().ok();
|
child.wait().ok();
|
||||||
});
|
});
|
||||||
|
|
||||||
return (action_thread, rx);
|
(action_thread, rx)
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-12
@@ -4,7 +4,7 @@ use crate::utils::*;
|
|||||||
|
|
||||||
use eframe::{App, CreationContext, Frame, HardwareAcceleration, NativeOptions, run_native};
|
use eframe::{App, CreationContext, Frame, HardwareAcceleration, NativeOptions, run_native};
|
||||||
use egui::{
|
use egui::{
|
||||||
Align, Button, CentralPanel, Color32, Context, Direction, FontFamily, Label, Layout, RichText,
|
Align, Button, CentralPanel, Color32, Direction, FontFamily, Label, Layout, RichText,
|
||||||
ScrollArea, TextWrapMode, Ui, Vec2, ViewportBuilder,
|
ScrollArea, TextWrapMode, Ui, Vec2, ViewportBuilder,
|
||||||
text::{LayoutJob, TextFormat, TextWrapping},
|
text::{LayoutJob, TextFormat, TextWrapping},
|
||||||
};
|
};
|
||||||
@@ -57,12 +57,11 @@ impl Application {
|
|||||||
fn get_package_state(&mut self) -> JoinHandle<()> {
|
fn get_package_state(&mut self) -> JoinHandle<()> {
|
||||||
let pkg_state_shared = self.pkg_state_shared.clone();
|
let pkg_state_shared = self.pkg_state_shared.clone();
|
||||||
let pkg = self.pkg.clone();
|
let pkg = self.pkg.clone();
|
||||||
let thread = thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
let pkg_state = get_package_state(&pkg);
|
let pkg_state = get_package_state(&pkg);
|
||||||
let mut guard = pkg_state_shared.lock().unwrap();
|
let mut guard = pkg_state_shared.lock().unwrap();
|
||||||
*guard = Some(pkg_state);
|
*guard = Some(pkg_state);
|
||||||
});
|
})
|
||||||
return thread;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn start_process(&mut self) {
|
fn start_process(&mut self) {
|
||||||
@@ -105,7 +104,7 @@ impl Application {
|
|||||||
} else {
|
} else {
|
||||||
let mut value_layout_job = LayoutJob {
|
let mut value_layout_job = LayoutJob {
|
||||||
wrap: TextWrapping {
|
wrap: TextWrapping {
|
||||||
max_rows: max_rows,
|
max_rows,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
..Default::default()
|
..Default::default()
|
||||||
@@ -165,7 +164,7 @@ impl Application {
|
|||||||
add_info_entry(
|
add_info_entry(
|
||||||
ui,
|
ui,
|
||||||
"Architecture",
|
"Architecture",
|
||||||
&self.pkg.metadata.get_arch().unwrap_or("-"),
|
self.pkg.metadata.get_arch().unwrap_or("-"),
|
||||||
1,
|
1,
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
@@ -179,28 +178,28 @@ impl Application {
|
|||||||
add_info_entry(
|
add_info_entry(
|
||||||
ui,
|
ui,
|
||||||
"Summary ",
|
"Summary ",
|
||||||
&self.pkg.metadata.get_summary().unwrap_or("-"),
|
self.pkg.metadata.get_summary().unwrap_or("-"),
|
||||||
3,
|
3,
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
add_info_entry(
|
add_info_entry(
|
||||||
ui,
|
ui,
|
||||||
"URL ",
|
"URL ",
|
||||||
&self.pkg.metadata.get_url().unwrap_or("-"),
|
self.pkg.metadata.get_url().unwrap_or("-"),
|
||||||
1,
|
1,
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
add_info_entry(
|
add_info_entry(
|
||||||
ui,
|
ui,
|
||||||
"License ",
|
"License ",
|
||||||
&self.pkg.metadata.get_license().unwrap_or("-"),
|
self.pkg.metadata.get_license().unwrap_or("-"),
|
||||||
2,
|
2,
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
add_info_entry(
|
add_info_entry(
|
||||||
ui,
|
ui,
|
||||||
"Description ",
|
"Description ",
|
||||||
&self.pkg.metadata.get_description().unwrap_or("-"),
|
self.pkg.metadata.get_description().unwrap_or("-"),
|
||||||
5,
|
5,
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
@@ -283,7 +282,7 @@ impl Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl App for Application {
|
impl App for Application {
|
||||||
fn update(&mut self, ctx: &Context, _: &mut Frame) {
|
fn logic(&mut self, _ctx: &egui::Context, _frame: &mut Frame) {
|
||||||
if let Some(process_thread) = &self.process_thread
|
if let Some(process_thread) = &self.process_thread
|
||||||
&& let Some(process_rx) = &self.process_rx
|
&& let Some(process_rx) = &self.process_rx
|
||||||
{
|
{
|
||||||
@@ -300,8 +299,10 @@ impl App for Application {
|
|||||||
self.process_log.push('\n');
|
self.process_log.push('\n');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CentralPanel::default().show(ctx, |ui| {
|
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut Frame) {
|
||||||
|
CentralPanel::default().show_inside(ui, |ui| {
|
||||||
if self.pkg_state.is_none() {
|
if self.pkg_state.is_none() {
|
||||||
if self.pkg_state_loading_thread.is_none() {
|
if self.pkg_state_loading_thread.is_none() {
|
||||||
self.pkg_state_loading_thread = Some(self.get_package_state());
|
self.pkg_state_loading_thread = Some(self.get_package_state());
|
||||||
|
|||||||
Reference in New Issue
Block a user