use dnf for description + add cachyos-addons + enable multipackage

This commit is contained in:
Ward from fusion-voyager-3 2024-06-21 16:57:48 +03:00
parent c314f9ee55
commit 8456aa4e4b
9 changed files with 121 additions and 82 deletions

View File

@ -3,15 +3,33 @@
"kernels": [
{
"name": "CachyOS Default Kernel",
"package": "kernel-cachyos",
"description": "CachyOS Kernel with default scheduler.",
"main_package": "kernel-cachyos",
"packages": "kernel-cachyos kernel-cachyos-devel-matched",
"min_x86_march": "3"
},
{
"name": "CachyOS LTS Kernel",
"package": "kernel-cachyos-lts",
"description": "CachyOS Long Term Support Kernel.",
"main_package": "kernel-cachyos-lts",
"packages": "kernel-cachyos kernel-cachyos-devel-matched",
"min_x86_march": "2"
},
{
"name": "UKSMD Daemon",
"main_package": "uksmd",
"packages": "uksmd",
"min_x86_march": "1"
},
{
"name": "CachyOS-Settings",
"main_package": "cachyos-settings",
"packages": "cachyos-settings",
"min_x86_march": "1"
},
{
"name": "Ananicy-CPP",
"main_package": "ananicy-cpp",
"packages": "ananicy-cpp",
"min_x86_march": "1"
}
]
}

Binary file not shown.

View File

@ -0,0 +1,11 @@
#! /bin/bash
if [[ $1 == "version" ]]
then
#apt-cache show $2 | grep Version: | cut -d":" -f2 | head -n1
dnf info $2 | grep Version | cut -d":" -f2 | head -n1
elif [[ $1 == "description" ]]
then
#apt-cache show $2 | grep 'Description*' | cut -d":" -f2 | head -n1
dnf info $2 | sed -n '/Description/,/^$/p' | awk 'NR==1,/^$/ {if (/^$/ && printed) exit; if (NF) printed=1; if (NR==1) sub(/Description *: */, ""); else sub(/^ *: */, ""); print}'
fi

View File

@ -1,3 +0,0 @@
#! /bin/bash
dnf info $1 | grep Version | cut -d":" -f2 | head -n1

View File

@ -1,7 +1,7 @@
use crate::APP_GITHUB;
use crate::VERSION;
use crate::APP_ID;
use crate::APP_ICON;
use crate::APP_ID;
use crate::VERSION;
use crate::{content, kernel_pkg, sched_ext, KernelBranch};
use adw::prelude::*;
use adw::*;
@ -69,7 +69,11 @@ pub fn build_ui(app: &adw::Application) {
}));
let window_headerbar = adw::HeaderBar::builder()
.title_widget(&adw::WindowTitle::builder().title("Fedora Kernel Manager").build())
.title_widget(
&adw::WindowTitle::builder()
.title("Fedora Kernel Manager")
.build(),
)
.build();
let content_stack = gtk::Stack::builder()
@ -94,7 +98,7 @@ pub fn build_ui(app: &adw::Application) {
&selected_kernel_branch2,
&db_load_complete,
&window,
&window_banner
&window_banner,
),
Some("content_page"),
);

View File

@ -1,4 +1,4 @@
use crate::{kernel_pkg, KernelBranch, RunningKernelInfo, sched_ext};
use crate::{kernel_pkg, sched_ext, KernelBranch, RunningKernelInfo};
use adw::prelude::*;
use adw::ExpanderRow;
use async_channel::Receiver;
@ -90,7 +90,6 @@ pub fn content(
.subtitle("Kernel Branch")
.build();
kernel_branch_expander_row.add_row(&kernel_branch_expandable(
&kernel_branch_expander_row,
&window_banner,
@ -100,18 +99,6 @@ pub fn content(
get_kernel_branches_receiver.clone(),
));
// match .recv_blocking() {
// Ok(t) => {
//
// ));
// }
// _ => {
// }
//
let kernel_branch_expander_row_boxedlist = gtk::ListBox::builder()
.selection_mode(SelectionMode::None)
.hexpand(true)
@ -167,8 +154,9 @@ pub fn content(
.build();
config_kernel_button.add_css_class("circular");
if ! is_scx_kernel() {
config_kernel_button.set_tooltip_text(Some("Currently running kernel doesn't support Sched-EXT"));
if !is_scx_kernel() {
config_kernel_button
.set_tooltip_text(Some("Currently running kernel doesn't support Sched-EXT"));
}
config_kernel_button.connect_clicked(clone!(@weak content_stack, @weak window => move |_| {
@ -385,28 +373,28 @@ pub fn create_kernel_badge(
fn get_kernel_branches() -> Result<Vec<KernelBranch>, reqwest::Error> {
let mut kernel_branches_array: Vec<KernelBranch> = Vec::new();
let data = fs::read_to_string(
"/usr/lib/fedora-kernel-manager/kernel_branches.json",
)
let data = fs::read_to_string("/usr/lib/fedora-kernel-manager/kernel_branches.json")
.expect("Unable to read file");
let res: serde_json::Value = serde_json::from_str(&data).expect("Unable to parse");
if let serde_json::Value::Array(branches) = &res["branches"] {
for branch in branches {
let branch_name = branch["name"].as_str().to_owned().unwrap().to_string();
let branch_db_url = branch["db_url"].as_str().to_owned().unwrap().to_string();
let branch_init_script = branch["init_script"].as_str().to_owned().unwrap().to_string();
println!(
"Downloading & Parsing package DB for {}.",
&branch_name
);
let branch_db = reqwest::blocking::get(
branch["db_url"].as_str().to_owned().unwrap().to_string(),
)?.text().unwrap();
let branch_init_script = branch["init_script"]
.as_str()
.to_owned()
.unwrap()
.to_string();
println!("Downloading & Parsing package DB for {}.", &branch_name);
let branch_db =
reqwest::blocking::get(branch["db_url"].as_str().to_owned().unwrap().to_string())?
.text()
.unwrap();
let branch = KernelBranch {
name: branch_name,
db_url: branch_db_url,
init_script: branch_init_script,
db: branch_db
db: branch_db,
};
println!("Download Complete!");
println!("Running {} init script.", &branch.name);

View File

@ -148,21 +148,31 @@ fn add_package_rows(
if let serde_json::Value::Array(kernels) = &res["kernels"] {
for kernel in kernels {
let kernel_name = kernel["name"].as_str().to_owned().unwrap().to_string();
let kernel_package = kernel["package"].as_str().to_owned().unwrap().to_string();
let kernel_description = kernel["description"]
let kernel_main_package = kernel["main_package"]
.as_str()
.to_owned()
.unwrap()
.to_string();
let kernel_packages = kernel["packages"].as_str().to_owned().unwrap().to_string();
let kernel_min_x86_march = kernel["min_x86_march"]
.as_str()
.to_owned()
.unwrap()
.parse::<u32>()
.unwrap();
let kernel_package_version =
match Command::new("/usr/lib/fedora-kernel-manager/scripts/get_version.sh")
.args([&kernel_package])
let kernel_package_version = match Command::new(
"/usr/lib/fedora-kernel-manager/scripts/generate_package_info.sh",
)
.args(["description", &kernel_main_package])
.output()
{
Ok(t) => String::from_utf8(t.stdout).unwrap(),
_ => "Error".to_owned(),
};
let kernel_description = match Command::new(
"/usr/lib/fedora-kernel-manager/scripts/generate_package_info.sh",
)
.args(["description", &kernel_main_package])
.output()
{
Ok(t) => String::from_utf8(t.stdout).unwrap(),
@ -181,11 +191,11 @@ fn add_package_rows(
let kernel_status_loop_sender: async_channel::Sender<bool> =
kernel_status_loop_sender.clone();
let kernel_package_clone0 = kernel_package.clone();
let kernel_main_package_clone0 = kernel_main_package.clone();
std::thread::spawn(move || loop {
let command_installed_status = Command::new("rpm")
.args(["-q", &kernel_package_clone0])
.args(["-q", &kernel_main_package_clone0])
.output()
.unwrap();
if command_installed_status.status.success() {
@ -200,10 +210,10 @@ fn add_package_rows(
std::thread::sleep(Duration::from_secs(6));
});
let kernel_package_clone0 = kernel_package.clone();
let kernel_main_package_clone0 = kernel_main_package.clone();
let kernel_expander_row = kernel_package_row::KernelPackageRow::new();
kernel_expander_row.set_package(kernel_package_clone0);
kernel_expander_row.set_package(kernel_main_package_clone0);
let kernel_status_icon = gtk::Image::builder()
.icon_name("emblem-default")
.pixel_size(24)
@ -329,7 +339,7 @@ fn add_package_rows(
}
}));
//
kernel_install_button.connect_clicked(clone!(@weak kernel_install_log_terminal,@weak kernel_install_log_terminal_buffer, @weak kernel_install_dialog, @strong log_loop_sender, @strong log_status_loop_sender, @strong kernel_package => move |_| {
kernel_install_button.connect_clicked(clone!(@weak kernel_install_log_terminal,@weak kernel_install_log_terminal_buffer, @weak kernel_install_dialog, @strong log_loop_sender, @strong log_status_loop_sender, @strong kernel_packages => move |_| {
kernel_install_log_terminal_buffer.delete(&mut kernel_install_log_terminal_buffer.bounds().0, &mut kernel_install_log_terminal_buffer.bounds().1);
kernel_install_dialog.set_response_enabled("kernel_install_dialog_ok", false);
kernel_install_dialog.set_response_enabled("kernel_install_dialog_reboot", false);
@ -344,9 +354,9 @@ fn add_package_rows(
});
let log_status_loop_sender_clone = log_status_loop_sender.clone();
let log_loop_sender_clone= log_loop_sender.clone();
let kernel_package_clone = kernel_package.clone();
let kernel_packages_clone = kernel_packages.clone();
std::thread::spawn(move || {
let command = kernel_modify(log_loop_sender_clone, &kernel_package_clone);
let command = kernel_modify(log_loop_sender_clone, &kernel_packages_clone);
match command {
Ok(_) => {
println!("Status: kernel modify Successful");
@ -359,7 +369,7 @@ fn add_package_rows(
}
});
}));
kernel_remove_button.connect_clicked(clone!(@weak kernel_install_log_terminal,@weak kernel_install_log_terminal_buffer, @weak kernel_install_dialog, @strong log_loop_sender, @strong log_status_loop_sender, @strong kernel_package => move |_| {
kernel_remove_button.connect_clicked(clone!(@weak kernel_install_log_terminal,@weak kernel_install_log_terminal_buffer, @weak kernel_install_dialog, @strong log_loop_sender, @strong log_status_loop_sender, @strong kernel_packages => move |_| {
kernel_install_log_terminal_buffer.delete(&mut kernel_install_log_terminal_buffer.bounds().0, &mut kernel_install_log_terminal_buffer.bounds().1);
kernel_install_dialog.set_response_enabled("kernel_install_dialog_ok", false);
kernel_install_dialog.set_response_enabled("kernel_install_dialog_reboot", false);
@ -374,9 +384,9 @@ fn add_package_rows(
});
let log_status_loop_sender_clone = log_status_loop_sender.clone();
let log_loop_sender_clone= log_loop_sender.clone();
let kernel_package_clone = kernel_package.clone();
let kernel_packages_clone = kernel_packages.clone();
std::thread::spawn(move || {
let command = kernel_modify(log_loop_sender_clone, &kernel_package_clone);
let command = kernel_modify(log_loop_sender_clone, &kernel_packages_clone);
match command {
Ok(_) => {
println!("Status: kernel modify Successful");

View File

@ -26,7 +26,7 @@ struct KernelBranch {
name: String,
db_url: String,
db: String,
init_script: String
init_script: String,
}
fn main() -> glib::ExitCode {

View File

@ -1,19 +1,19 @@
use crate::content::get_running_kernel_info;
use crate::{KernelBranch, RunningKernelInfo};
use adw::prelude::*;
use duct::cmd;
use glib::*;
use gtk::prelude::*;
use gtk::AccessibleRole::Command;
use gtk::*;
use std::{fs, io, thread};
use std::cell::RefCell;
use std::fs::*;
use std::process::Stdio;
use std::rc::Rc;
use std::time::Duration;
use duct::cmd;
use gtk::AccessibleRole::Command;
use std::{fs, io, thread};
pub fn sched_ext_page(content_stack: &gtk::Stack, window: &adw::ApplicationWindow,) -> gtk::Box {
pub fn sched_ext_page(content_stack: &gtk::Stack, window: &adw::ApplicationWindow) -> gtk::Box {
let main_box = gtk::Box::builder()
.hexpand(true)
.vexpand(true)
@ -70,16 +70,16 @@ pub fn sched_ext_page(content_stack: &gtk::Stack, window: &adw::ApplicationWindo
.transient_for(window)
.hide_on_close(true)
.build();
cmd_status_dialog.add_response(
"cmd_status_dialog_ok",
"Ok",
);
cmd_status_dialog.add_response("cmd_status_dialog_ok", "Ok");
let scx_sched_expander_row = adw::ExpanderRow::builder()
.subtitle("Select Sched-EXT Scheduler")
.build();
scx_sched_expander_row.add_row(&scx_sched_expandable(&scx_sched_expander_row, &selected_scx_sched));
scx_sched_expander_row.add_row(&scx_sched_expandable(
&scx_sched_expander_row,
&selected_scx_sched,
));
let scx_sched_expander_row_boxedlist = gtk::ListBox::builder()
.selection_mode(SelectionMode::None)
@ -205,8 +205,10 @@ fn create_current_sched_badge(
));
}
fn scx_sched_expandable(expander_row: &adw::ExpanderRow,
selected_scx_sched: &Rc<RefCell<String>>) -> gtk::ListBox {
fn scx_sched_expandable(
expander_row: &adw::ExpanderRow,
selected_scx_sched: &Rc<RefCell<String>>,
) -> gtk::ListBox {
let searchbar = gtk::SearchEntry::builder().search_delay(500).build();
searchbar.add_css_class("round-border-only-top");
@ -225,9 +227,7 @@ fn scx_sched_expandable(expander_row: &adw::ExpanderRow,
.label("No branch selected")
.build();
let data = fs::read_to_string(
"/usr/lib/fedora-kernel-manager/scx_scheds.json",
)
let data = fs::read_to_string("/usr/lib/fedora-kernel-manager/scx_scheds.json")
.expect("Unable to read file");
let res: serde_json::Value = serde_json::from_str(&data).expect("Unable to parse");
if let serde_json::Value::Array(scheds) = &res["scx_schedulers"] {
@ -249,7 +249,7 @@ fn scx_sched_expandable(expander_row: &adw::ExpanderRow,
clone!(@weak sched_checkbutton, @weak expander_row, @strong selected_scx_sched => move |_| {
if sched_checkbutton.is_active() == true {
expander_row.set_title(&branch_row.title());
*selected_scx_sched.borrow_mut() = sched.to_string();;
*selected_scx_sched.borrow_mut() = sched.to_string();
}
}),
);
@ -302,12 +302,23 @@ fn get_current_scx_scheduler() -> String {
scx_sched
}
fn change_scx_scheduler(scx_sched: &str,
fn change_scx_scheduler(
scx_sched: &str,
badge_box: &gtk::Box,
kernel_badges_size_group: &gtk::SizeGroup,
kernel_badges_size_group0: &gtk::SizeGroup,
kernel_badges_size_group1: &gtk::SizeGroup,) -> Result<(), io::Error> {
cmd!("pkexec", "bash", "-c", format!("/usr/lib/fedora-kernel-manager/scripts/scripts/change_scx.sh {}", scx_sched)).run()?;
kernel_badges_size_group1: &gtk::SizeGroup,
) -> Result<(), io::Error> {
cmd!(
"pkexec",
"bash",
"-c",
format!(
"/usr/lib/fedora-kernel-manager/scripts/scripts/change_scx.sh {}",
scx_sched
)
)
.run()?;
create_current_sched_badge(
&badge_box,
&get_running_kernel_info(),