x86 march check complete

This commit is contained in:
Ward from fusion-voyager-3 2024-06-19 22:03:15 +03:00
parent 62505286b2
commit 42d34c9c17
5 changed files with 47 additions and 35 deletions

View File

@ -1,11 +1,9 @@
use std::{cell::RefCell, env, rc::Rc, sync::OnceLock};
use adw::*;
use adw::{prelude::*, subclass::prelude::*, *};
use glib::{clone, subclass::Signal, Properties};
use gtk::{glib, Orientation::Horizontal};
use adw::*;
// ANCHOR: custom_button
// Object holding the state
@ -40,8 +38,7 @@ impl ObjectImpl for KernelPackageRow {
// `SYNC_CREATE` ensures that the label will be immediately set
let obj = self.obj();
let basic_expander_row_package_label = gtk::Label::builder()
.build();
let basic_expander_row_package_label = gtk::Label::builder().build();
obj.add_suffix(&basic_expander_row_package_label);

View File

@ -1,4 +1,3 @@
use std::process::Stdio;
use crate::content::get_running_kernel_info;
use crate::{kernel_package_row, KernelBranch, RunningKernelInfo};
use adw::prelude::*;
@ -13,6 +12,7 @@ use std::fs::*;
use std::io::BufRead;
use std::io::BufReader;
use std::process::Command;
use std::process::Stdio;
use std::rc::Rc;
use std::time::*;
@ -83,7 +83,7 @@ pub fn kernel_pkg_page(
&selected_kernel_branch_clone0.db,
&window,
&rows_size_group,
&searchbar
&searchbar,
);
let packages_viewport = gtk::ScrolledWindow::builder()
@ -136,13 +136,13 @@ fn add_package_rows(
data: &str,
window: &adw::ApplicationWindow,
rows_size_group: &gtk::SizeGroup,
searchbar: &gtk::SearchEntry
searchbar: &gtk::SearchEntry,
) {
let cpu_feature_level: u64 = match get_cpu_feature_level().as_str() {
let cpu_feature_level: u32 = match get_cpu_feature_level().as_str() {
"x86-64-v4" => 4,
"x86-64-v3" => 3,
"x86-64-v2" => 2,
_ => 1
_ => 1,
};
let res: serde_json::Value = serde_json::from_str(&data).expect("Unable to parse");
if let serde_json::Value::Array(kernels) = &res["kernels"] {
@ -155,14 +155,18 @@ fn add_package_rows(
.unwrap()
.to_string();
let kernel_min_x86_march = kernel["min_x86_march"]
.as_u64()
.as_str()
.to_owned()
.unwrap()
let kernel_package_version = match Command::new("/usr/lib/fedora-kernel-manager/scripts/get_version.sh")
.parse::<u32>()
.unwrap();
let kernel_package_version =
match Command::new("/usr/lib/fedora-kernel-manager/scripts/get_version.sh")
.args([&kernel_package])
.output() {
.output()
{
Ok(t) => String::from_utf8(t.stdout).unwrap(),
_ => "Error".to_owned()
_ => "Error".to_owned(),
};
let (log_loop_sender, log_loop_receiver) = async_channel::unbounded();
@ -185,9 +189,13 @@ fn add_package_rows(
.output()
.unwrap();
if command_installed_status.status.success() {
kernel_status_loop_sender.send_blocking(true).expect("channel needs to be open")
kernel_status_loop_sender
.send_blocking(true)
.expect("channel needs to be open")
} else {
kernel_status_loop_sender.send_blocking(false).expect("channel needs to be open")
kernel_status_loop_sender
.send_blocking(false)
.expect("channel needs to be open")
}
std::thread::sleep(Duration::from_secs(6));
});
@ -381,10 +389,10 @@ fn add_package_rows(
}
});
}));
//
//if kernel_needs_v3 = false || kernel_needs_v3 = true && cpu_feature_level = "x86-64-v3"
if cpu_feature_level >= kernel_min_x86_march {
boxedlist.append(&kernel_expander_row);
}
}
};
searchbar.connect_search_changed(clone!(@weak searchbar, @weak boxedlist => move |_| {
@ -446,9 +454,16 @@ fn get_cpu_feature_level() -> String {
.spawn()
.unwrap();
let output = grep_command.wait_with_output().expect("Output failed");
let result = match String::from_utf8(output.stdout).expect("stringing failed").lines().next() {
Some(t) => t.trim_end_matches("(supported, searched)").trim().to_string(),
_ => "x86_64-v1".to_string()
let result = match String::from_utf8(output.stdout)
.expect("stringing failed")
.lines()
.next()
{
Some(t) => t
.trim_end_matches("(supported, searched)")
.trim()
.to_string(),
_ => "x86_64-v1".to_string(),
};
result
}

View File

@ -1,8 +1,8 @@
mod build_ui;
mod content;
mod kernel_package_row;
mod kernel_pkg;
mod sched_ext;
mod kernel_package_row;
use adw::prelude::*;
use gtk::*;