drop Kernel Branch system
This commit is contained in:
parent
b448d94b9e
commit
84003cb89e
3
Makefile
3
Makefile
@ -17,7 +17,6 @@ install_no_build:
|
|||||||
cp -rvf data/scripts $(DESTDIR)/usr/lib/pika/kernel-manager/
|
cp -rvf data/scripts $(DESTDIR)/usr/lib/pika/kernel-manager/
|
||||||
chmod 755 $(DESTDIR)/usr/lib/pika/kernel-manager/scripts/*.sh
|
chmod 755 $(DESTDIR)/usr/lib/pika/kernel-manager/scripts/*.sh
|
||||||
cp -rvf data/locales $(DESTDIR)/usr/lib/pika/kernel-manager/
|
cp -rvf data/locales $(DESTDIR)/usr/lib/pika/kernel-manager/
|
||||||
cp -rvf data/kernel_branches $(DESTDIR)/usr/lib/pika/kernel-manager/
|
|
||||||
cp -vf data/scx_scheds.json $(DESTDIR)/usr/lib/pika/kernel-manager/
|
cp -vf data/scx_scheds.json $(DESTDIR)/usr/lib/pika/kernel-manager/
|
||||||
mkdir -p $(DESTDIR)/usr/share/applications
|
mkdir -p $(DESTDIR)/usr/share/applications
|
||||||
mkdir -p $(DESTDIR)/usr/share/icons/hicolor/scalable/apps
|
mkdir -p $(DESTDIR)/usr/share/icons/hicolor/scalable/apps
|
||||||
@ -33,7 +32,6 @@ install_no_build_debug:
|
|||||||
cp -rvf data/scripts $(DESTDIR)/usr/lib/pika/kernel-manager/
|
cp -rvf data/scripts $(DESTDIR)/usr/lib/pika/kernel-manager/
|
||||||
chmod 755 $(DESTDIR)/usr/lib/pika/kernel-manager/scripts/*.sh
|
chmod 755 $(DESTDIR)/usr/lib/pika/kernel-manager/scripts/*.sh
|
||||||
cp -rvf data/locales $(DESTDIR)/usr/lib/pika/kernel-manager/
|
cp -rvf data/locales $(DESTDIR)/usr/lib/pika/kernel-manager/
|
||||||
cp -rvf data/kernel_branches $(DESTDIR)/usr/lib/pika/kernel-manager/
|
|
||||||
cp -vf data/scx_scheds.json $(DESTDIR)/usr/lib/pika/kernel-manager/
|
cp -vf data/scx_scheds.json $(DESTDIR)/usr/lib/pika/kernel-manager/
|
||||||
mkdir -p $(DESTDIR)/usr/share/applications
|
mkdir -p $(DESTDIR)/usr/share/applications
|
||||||
mkdir -p $(DESTDIR)/usr/share/icons/hicolor/scalable/apps
|
mkdir -p $(DESTDIR)/usr/share/icons/hicolor/scalable/apps
|
||||||
@ -51,7 +49,6 @@ install:
|
|||||||
cp -rvf data/scripts $(DESTDIR)/usr/lib/pika/kernel-manager/
|
cp -rvf data/scripts $(DESTDIR)/usr/lib/pika/kernel-manager/
|
||||||
chmod 755 $(DESTDIR)/usr/lib/pika/kernel-manager/scripts/*.sh
|
chmod 755 $(DESTDIR)/usr/lib/pika/kernel-manager/scripts/*.sh
|
||||||
cp -rvf data/locales $(DESTDIR)/usr/lib/pika/kernel-manager/
|
cp -rvf data/locales $(DESTDIR)/usr/lib/pika/kernel-manager/
|
||||||
cp -rvf data/kernel_branches $(DESTDIR)/usr/lib/pika/kernel-manager/
|
|
||||||
cp -vf data/scx_scheds.json $(DESTDIR)/usr/lib/pika/kernel-manager/
|
cp -vf data/scx_scheds.json $(DESTDIR)/usr/lib/pika/kernel-manager/
|
||||||
mkdir -p $(DESTDIR)/usr/share/applications
|
mkdir -p $(DESTDIR)/usr/share/applications
|
||||||
mkdir -p $(DESTDIR)/usr/share/icons/hicolor/scalable/apps
|
mkdir -p $(DESTDIR)/usr/share/icons/hicolor/scalable/apps
|
||||||
|
10
kernel-db.json
Normal file
10
kernel-db.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"latest_kernel_version": "6.10.5",
|
||||||
|
"kernels": [
|
||||||
|
{
|
||||||
|
"name": "PikaOS Kernel 6.10.5",
|
||||||
|
"main_package": "linux-image-6.10.5-pikaos",
|
||||||
|
"packages": "linux-image-6.10.5-pikaos linux-headers-6.10.5-pikaos"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -2,7 +2,7 @@ use crate::APP_GITHUB;
|
|||||||
use crate::APP_ICON;
|
use crate::APP_ICON;
|
||||||
use crate::APP_ID;
|
use crate::APP_ID;
|
||||||
use crate::VERSION;
|
use crate::VERSION;
|
||||||
use crate::{content, KernelBranch};
|
use crate::content;
|
||||||
use adw::prelude::*;
|
use adw::prelude::*;
|
||||||
use adw::*;
|
use adw::*;
|
||||||
use glib::{clone, MainContext};
|
use glib::{clone, MainContext};
|
||||||
@ -17,12 +17,6 @@ pub fn build_ui(app: &adw::Application) {
|
|||||||
glib::set_application_name(&t!("application_name").to_string());
|
glib::set_application_name(&t!("application_name").to_string());
|
||||||
|
|
||||||
let internet_connected = Rc::new(RefCell::new(false));
|
let internet_connected = Rc::new(RefCell::new(false));
|
||||||
let selected_kernel_branch: Rc<RefCell<KernelBranch>> = Rc::new(RefCell::new(KernelBranch {
|
|
||||||
name: "?".to_owned(),
|
|
||||||
db_url: "?".to_owned(),
|
|
||||||
db: "?".to_owned(),
|
|
||||||
init_script: "?".to_owned(),
|
|
||||||
}));
|
|
||||||
let db_load_complete = Rc::new(RefCell::new(false));
|
let db_load_complete = Rc::new(RefCell::new(false));
|
||||||
|
|
||||||
let (internet_loop_sender, internet_loop_receiver) = async_channel::unbounded();
|
let (internet_loop_sender, internet_loop_receiver) = async_channel::unbounded();
|
||||||
@ -44,8 +38,6 @@ pub fn build_ui(app: &adw::Application) {
|
|||||||
|
|
||||||
let internet_connected_status = internet_connected.clone();
|
let internet_connected_status = internet_connected.clone();
|
||||||
|
|
||||||
let selected_kernel_branch2 = selected_kernel_branch.clone();
|
|
||||||
|
|
||||||
let internet_loop_context = MainContext::default();
|
let internet_loop_context = MainContext::default();
|
||||||
// The main loop executes the asynchronous block
|
// The main loop executes the asynchronous block
|
||||||
internet_loop_context.spawn_local(clone!(@weak window_banner => async move {
|
internet_loop_context.spawn_local(clone!(@weak window_banner => async move {
|
||||||
@ -93,7 +85,6 @@ pub fn build_ui(app: &adw::Application) {
|
|||||||
content_stack.add_named(
|
content_stack.add_named(
|
||||||
&content::content(
|
&content::content(
|
||||||
&content_stack,
|
&content_stack,
|
||||||
&selected_kernel_branch2,
|
|
||||||
&db_load_complete,
|
&db_load_complete,
|
||||||
&window,
|
&window,
|
||||||
&window_banner,
|
&window_banner,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use crate::{kernel_pkg, sched_ext, KernelBranch, RunningKernelInfo};
|
use crate::{kernel_pkg, sched_ext, RunningKernelInfo, KERNEL_DB_JSON_URL};
|
||||||
use adw::prelude::*;
|
use adw::prelude::*;
|
||||||
use async_channel::Receiver;
|
use async_channel::Receiver;
|
||||||
use duct::cmd;
|
use duct::cmd;
|
||||||
@ -15,7 +15,6 @@ use Vec;
|
|||||||
|
|
||||||
pub fn content(
|
pub fn content(
|
||||||
content_stack: >k::Stack,
|
content_stack: >k::Stack,
|
||||||
selected_kernel_branch: &Rc<RefCell<KernelBranch>>,
|
|
||||||
db_load_complete: &Rc<RefCell<bool>>,
|
db_load_complete: &Rc<RefCell<bool>>,
|
||||||
window: &adw::ApplicationWindow,
|
window: &adw::ApplicationWindow,
|
||||||
window_banner: &adw::Banner,
|
window_banner: &adw::Banner,
|
||||||
@ -23,9 +22,11 @@ pub fn content(
|
|||||||
let (get_kernel_branches_sender, get_kernel_branches_receiver) = async_channel::unbounded();
|
let (get_kernel_branches_sender, get_kernel_branches_receiver) = async_channel::unbounded();
|
||||||
let get_kernel_branches_sender = get_kernel_branches_sender.clone();
|
let get_kernel_branches_sender = get_kernel_branches_sender.clone();
|
||||||
|
|
||||||
|
let kernel_db_refcell: Rc<RefCell<String>> = Rc::new(RefCell::new(Default::default()));
|
||||||
|
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
get_kernel_branches_sender
|
get_kernel_branches_sender
|
||||||
.send_blocking(get_kernel_branches())
|
.send_blocking(get_kernel_db())
|
||||||
.expect("channel needs to be open.");
|
.expect("channel needs to be open.");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -86,29 +87,6 @@ pub fn content(
|
|||||||
.vexpand(true)
|
.vexpand(true)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let kernel_branch_expander_row = adw::ExpanderRow::builder()
|
|
||||||
.subtitle(t!("kernel_branch_expander_row_subtitle"))
|
|
||||||
.build();
|
|
||||||
|
|
||||||
kernel_branch_expander_row.add_row(&kernel_branch_expandable(
|
|
||||||
&kernel_branch_expander_row,
|
|
||||||
&window_banner,
|
|
||||||
&loading_box,
|
|
||||||
selected_kernel_branch,
|
|
||||||
db_load_complete,
|
|
||||||
get_kernel_branches_receiver.clone(),
|
|
||||||
));
|
|
||||||
|
|
||||||
let kernel_branch_expander_row_boxedlist = gtk::ListBox::builder()
|
|
||||||
.selection_mode(SelectionMode::None)
|
|
||||||
.hexpand(true)
|
|
||||||
.halign(Align::Center)
|
|
||||||
.margin_start(10)
|
|
||||||
.margin_end(10)
|
|
||||||
.margin_bottom(20)
|
|
||||||
.margin_top(20)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
let button_box = gtk::Box::builder()
|
let button_box = gtk::Box::builder()
|
||||||
.orientation(Orientation::Horizontal)
|
.orientation(Orientation::Horizontal)
|
||||||
.margin_start(10)
|
.margin_start(10)
|
||||||
@ -132,8 +110,8 @@ pub fn content(
|
|||||||
browse_kernels_button.add_css_class("circular");
|
browse_kernels_button.add_css_class("circular");
|
||||||
|
|
||||||
browse_kernels_button.connect_clicked(
|
browse_kernels_button.connect_clicked(
|
||||||
clone!(@weak window, @weak content_stack, @strong selected_kernel_branch => move |_| {
|
clone!(@weak window, @weak content_stack, @strong kernel_db_refcell => move |_| {
|
||||||
kernel_pkg::kernel_pkg_page(&content_stack, &window, &selected_kernel_branch);
|
kernel_pkg::kernel_pkg_page(&content_stack, &window, kernel_db_refcell.borrow().to_string());
|
||||||
content_stack.set_visible_child_name("kernel_pkg_page")
|
content_stack.set_visible_child_name("kernel_pkg_page")
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
@ -174,15 +152,34 @@ pub fn content(
|
|||||||
button_box.append(&browse_kernels_button);
|
button_box.append(&browse_kernels_button);
|
||||||
button_box.append(&config_kernel_button);
|
button_box.append(&config_kernel_button);
|
||||||
|
|
||||||
kernel_branch_expander_row_boxedlist.add_css_class("boxed-list");
|
|
||||||
kernel_branch_expander_row_boxedlist.append(&kernel_branch_expander_row);
|
|
||||||
|
|
||||||
content_box.append(&loading_box);
|
content_box.append(&loading_box);
|
||||||
content_box.append(&kernel_badge_box);
|
content_box.append(&kernel_badge_box);
|
||||||
content_box.append(&tux_icon);
|
content_box.append(&tux_icon);
|
||||||
content_box.append(&kernel_branch_expander_row_boxedlist);
|
|
||||||
content_box.append(&button_box);
|
content_box.append(&button_box);
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
let get_kernel_branches_loop_context = MainContext::default();
|
||||||
|
// The main loop executes the asynchronous block
|
||||||
|
get_kernel_branches_loop_context.spawn_local(clone!(@strong loading_box, @strong window_banner, @strong kernel_db_refcell, @strong db_load_complete => async move {
|
||||||
|
while let Ok(data) = get_kernel_branches_receiver.recv().await {
|
||||||
|
match data {
|
||||||
|
Ok(t) => {
|
||||||
|
(*kernel_db_refcell.borrow_mut()) = t;
|
||||||
|
*db_load_complete.borrow_mut() = true;
|
||||||
|
println!("{} {}", "Pika Kernels",t!("db_load_complete"))
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
window_banner.set_title(&t!("banner_text_url_error").to_string());
|
||||||
|
window_banner.set_revealed(true);
|
||||||
|
loading_box.set_visible(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
let (load_badge_async_sender, load_badge_async_receiver) = async_channel::unbounded();
|
let (load_badge_async_sender, load_badge_async_receiver) = async_channel::unbounded();
|
||||||
let load_badge_async_sender = load_badge_async_sender.clone();
|
let load_badge_async_sender = load_badge_async_sender.clone();
|
||||||
// The long running operation runs now in a separate thread
|
// The long running operation runs now in a separate thread
|
||||||
@ -195,11 +192,11 @@ pub fn content(
|
|||||||
|
|
||||||
let load_badge_async_context = MainContext::default();
|
let load_badge_async_context = MainContext::default();
|
||||||
// The main loop executes the asynchronous block
|
// The main loop executes the asynchronous block
|
||||||
load_badge_async_context.spawn_local(clone!(@weak content_box, @weak loading_box, @weak kernel_badge_box, @strong selected_kernel_branch, @strong db_load_complete => async move {
|
load_badge_async_context.spawn_local(clone!(@weak content_box, @weak loading_box, @weak kernel_badge_box, @strong kernel_db_refcell, @strong db_load_complete => async move {
|
||||||
while let Ok(_state) = load_badge_async_receiver.recv().await {
|
while let Ok(_state) = load_badge_async_receiver.recv().await {
|
||||||
if *db_load_complete.borrow() == true {
|
if *db_load_complete.borrow() == true {
|
||||||
let running_kernel_info = get_running_kernel_info();
|
let running_kernel_info = get_running_kernel_info();
|
||||||
create_kernel_badges(&kernel_badge_box, &running_kernel_info, &selected_kernel_branch);
|
create_kernel_badges(&kernel_badge_box, &running_kernel_info, &kernel_db_refcell.borrow());
|
||||||
create_current_sched_badge(&sched_ext_badge_box, &running_kernel_info);
|
create_current_sched_badge(&sched_ext_badge_box, &running_kernel_info);
|
||||||
loading_box.set_visible(false);
|
loading_box.set_visible(false);
|
||||||
content_box.set_sensitive(true)
|
content_box.set_sensitive(true)
|
||||||
@ -210,122 +207,6 @@ pub fn content(
|
|||||||
content_box
|
content_box
|
||||||
}
|
}
|
||||||
|
|
||||||
fn kernel_branch_expandable(
|
|
||||||
expander_row: &adw::ExpanderRow,
|
|
||||||
window_banner: &adw::Banner,
|
|
||||||
loading_box: >k::Box,
|
|
||||||
selected_kernel_branch: &Rc<RefCell<KernelBranch>>,
|
|
||||||
db_load_complete: &Rc<RefCell<bool>>,
|
|
||||||
get_kernel_branches_receiver: Receiver<Result<Vec<KernelBranch>, reqwest::Error>>,
|
|
||||||
) -> gtk::ListBox {
|
|
||||||
let searchbar = gtk::SearchEntry::builder().search_delay(500).build();
|
|
||||||
searchbar.add_css_class("round-border-only-top");
|
|
||||||
|
|
||||||
let boxedlist = gtk::ListBox::builder()
|
|
||||||
.selection_mode(SelectionMode::None)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
boxedlist.append(&searchbar);
|
|
||||||
|
|
||||||
let branch_container = gtk::ListBox::builder()
|
|
||||||
.selection_mode(SelectionMode::None)
|
|
||||||
.build();
|
|
||||||
branch_container.add_css_class("boxed-list");
|
|
||||||
|
|
||||||
let null_checkbutton = gtk::CheckButton::builder()
|
|
||||||
.label(t!("null_checkbutton_label"))
|
|
||||||
.build();
|
|
||||||
|
|
||||||
let get_kernel_branches_loop_context = MainContext::default();
|
|
||||||
// The main loop executes the asynchronous block
|
|
||||||
get_kernel_branches_loop_context.spawn_local(clone!(@weak expander_row, @weak branch_container, @strong selected_kernel_branch, @weak loading_box, @weak window_banner, @strong db_load_complete => async move {
|
|
||||||
while let Ok(data) = get_kernel_branches_receiver.recv().await {
|
|
||||||
match data {
|
|
||||||
Ok(t) => {
|
|
||||||
for branch in t {
|
|
||||||
let branch_clone0 = branch.clone();
|
|
||||||
let branch_clone1 = branch.clone();
|
|
||||||
let branch_checkbutton = gtk::CheckButton::builder()
|
|
||||||
.valign(Align::Center)
|
|
||||||
.can_focus(false)
|
|
||||||
.active(false)
|
|
||||||
.build();
|
|
||||||
let branch_row = adw::ActionRow::builder()
|
|
||||||
.activatable_widget(&branch_checkbutton)
|
|
||||||
.title(branch.name)
|
|
||||||
.build();
|
|
||||||
branch_row.add_prefix(&branch_checkbutton);
|
|
||||||
branch_checkbutton.set_group(Some(&null_checkbutton));
|
|
||||||
branch_container.append(&branch_row);
|
|
||||||
let selected_kernel_branch_clone0 = selected_kernel_branch.clone();
|
|
||||||
branch_checkbutton.connect_toggled(
|
|
||||||
clone!(@weak branch_checkbutton, @weak expander_row, @strong branch_clone0 => move |_| {
|
|
||||||
if branch_checkbutton.is_active() == true {
|
|
||||||
expander_row.set_title(&branch_row.title());
|
|
||||||
save_branch_config(&branch_row.title().to_string());
|
|
||||||
*selected_kernel_branch_clone0.borrow_mut()=branch_clone0.clone()
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
match get_my_home().unwrap().unwrap().join(".config/pika-kernel-manager/branch").exists() {
|
|
||||||
true if fs::read_to_string(get_my_home().unwrap().unwrap().join(".config/pika-kernel-manager/branch")).unwrap().trim().eq(branch_clone1.name.trim()) =>
|
|
||||||
{
|
|
||||||
branch_checkbutton.set_active(true)
|
|
||||||
}
|
|
||||||
false =>
|
|
||||||
{
|
|
||||||
branch_container.first_child().unwrap().property::<gtk::CheckButton>("activatable_widget").set_property("active", true)
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
};
|
|
||||||
|
|
||||||
*db_load_complete.borrow_mut() = true;
|
|
||||||
println!("{} {}", branch_clone0.name,t!("db_load_complete"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
window_banner.set_title(&t!("banner_text_url_error").to_string());
|
|
||||||
window_banner.set_revealed(true);
|
|
||||||
loading_box.set_visible(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
let branch_container_viewport = gtk::ScrolledWindow::builder()
|
|
||||||
.child(&branch_container)
|
|
||||||
.hscrollbar_policy(PolicyType::Never)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
branch_container.add_css_class("round-border-only-bottom");
|
|
||||||
|
|
||||||
boxedlist.append(&branch_container_viewport);
|
|
||||||
|
|
||||||
searchbar.connect_search_changed(clone!(@weak searchbar, @weak branch_container => move |_| {
|
|
||||||
let mut counter = branch_container.first_child();
|
|
||||||
while let Some(row) = counter {
|
|
||||||
if row.widget_name() == "AdwActionRow" {
|
|
||||||
if !searchbar.text().is_empty() {
|
|
||||||
if row.property::<String>("subtitle").to_lowercase().contains(&searchbar.text().to_string().to_lowercase()) || row.property::<String>("title").to_lowercase().contains(&searchbar.text().to_string().to_lowercase()) {
|
|
||||||
//row.grab_focus();
|
|
||||||
//row.add_css_class("highlight-widget");
|
|
||||||
row.set_property("visible", true);
|
|
||||||
searchbar.grab_focus();
|
|
||||||
} else {
|
|
||||||
row.set_property("visible", false);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
row.set_property("visible", true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
counter = row.next_sibling();
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
boxedlist
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn create_kernel_badge(
|
pub fn create_kernel_badge(
|
||||||
label0_text: &str,
|
label0_text: &str,
|
||||||
label1_text: &str,
|
label1_text: &str,
|
||||||
@ -386,41 +267,16 @@ pub fn create_kernel_badge(
|
|||||||
boxedlist
|
boxedlist
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_kernel_branches() -> Result<Vec<KernelBranch>, reqwest::Error> {
|
fn get_kernel_db() -> Result<String, reqwest::Error> {
|
||||||
let mut kernel_branches_array: Vec<KernelBranch> = Vec::new();
|
let branch_name = "Pika Kernels";
|
||||||
let kernel_branch_files_dir = fs::read_dir("/usr/lib/pika/kernel-manager/kernel_branches").expect("No Kernel json files found");
|
println!("{} {}.",t!("db_downloading"), &branch_name);
|
||||||
for kernel_branch_file in kernel_branch_files_dir {
|
let branch_db =
|
||||||
let kernel_branch_file_path = kernel_branch_file.expect("couldn't change dir entry to path").path();
|
reqwest::blocking::get(KERNEL_DB_JSON_URL)?
|
||||||
let kernel_branch_data = fs::read_to_string(kernel_branch_file_path).expect("some json is invalid");
|
.text()
|
||||||
let branch: serde_json::Value = serde_json::from_str(&kernel_branch_data).expect("some json is invalid");
|
.unwrap();
|
||||||
let branch_name = branch["name"].as_str().to_owned().unwrap().to_string();
|
println!("{} {}", &branch_name, t!("db_download_complete"));
|
||||||
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!("{} {}.",t!("db_downloading"), &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,
|
|
||||||
};
|
|
||||||
println!("{} {}", &branch.name, t!("db_download_complete"));
|
|
||||||
println!("{} {} {}", t!("db_init_script_run_p1"), &branch.name, t!("db_init_script_run_p2"));
|
|
||||||
match cmd!("bash", "-c", &branch.init_script).run() {
|
|
||||||
Ok(_) => println!("{} {}", &branch.name, t!("db_init_script_successful")),
|
|
||||||
_ => println!("{} {}", &branch.name, t!("db_init_script_failed")),
|
|
||||||
};
|
|
||||||
kernel_branches_array.push(branch)
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(kernel_branches_array)
|
Ok(branch_db)
|
||||||
}
|
}
|
||||||
pub fn get_running_kernel_info() -> RunningKernelInfo {
|
pub fn get_running_kernel_info() -> RunningKernelInfo {
|
||||||
let kernel = match Command::new("uname")
|
let kernel = match Command::new("uname")
|
||||||
@ -494,16 +350,14 @@ fn bore_check() -> bool {
|
|||||||
fn create_kernel_badges(
|
fn create_kernel_badges(
|
||||||
badge_box: >k::Box,
|
badge_box: >k::Box,
|
||||||
running_kernel_info: &RunningKernelInfo,
|
running_kernel_info: &RunningKernelInfo,
|
||||||
selected_kernel_branch: &Rc<RefCell<KernelBranch>>,
|
kernel_db: &str
|
||||||
) {
|
) {
|
||||||
let selected_kernel_branch_clone = selected_kernel_branch.borrow().clone();
|
|
||||||
|
|
||||||
let kernel_badges_size_group = gtk::SizeGroup::new(SizeGroupMode::Both);
|
let kernel_badges_size_group = gtk::SizeGroup::new(SizeGroupMode::Both);
|
||||||
let kernel_badges_size_group0 = gtk::SizeGroup::new(SizeGroupMode::Both);
|
let kernel_badges_size_group0 = gtk::SizeGroup::new(SizeGroupMode::Both);
|
||||||
let kernel_badges_size_group1 = gtk::SizeGroup::new(SizeGroupMode::Both);
|
let kernel_badges_size_group1 = gtk::SizeGroup::new(SizeGroupMode::Both);
|
||||||
|
|
||||||
let json: serde_json::Value =
|
let json: serde_json::Value =
|
||||||
serde_json::from_str(&selected_kernel_branch_clone.db).expect("Unable to parse");
|
serde_json::from_str(&kernel_db).expect("Unable to parse");
|
||||||
|
|
||||||
let kernel_version_deter = match json["latest_kernel_version_deter_pkg"].as_str() {
|
let kernel_version_deter = match json["latest_kernel_version_deter_pkg"].as_str() {
|
||||||
Some(t) => t,
|
Some(t) => t,
|
||||||
@ -530,14 +384,6 @@ fn create_kernel_badges(
|
|||||||
badge_box.remove(&widget);
|
badge_box.remove(&widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
badge_box.append(&create_kernel_badge(
|
|
||||||
&t!("kernel_badge_branch_label").to_string(),
|
|
||||||
&selected_kernel_branch_clone.name,
|
|
||||||
"background-accent-bg",
|
|
||||||
&kernel_badges_size_group,
|
|
||||||
&kernel_badges_size_group0,
|
|
||||||
&kernel_badges_size_group1,
|
|
||||||
));
|
|
||||||
badge_box.append(&create_kernel_badge(
|
badge_box.append(&create_kernel_badge(
|
||||||
&t!("kernel_badge_latest_version_label").to_string(),
|
&t!("kernel_badge_latest_version_label").to_string(),
|
||||||
&kernel_version,
|
&kernel_version,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use crate::{kernel_package_row, KernelBranch, KernelPackage};
|
use crate::{kernel_package_row, KernelPackage};
|
||||||
use adw::prelude::*;
|
use adw::prelude::*;
|
||||||
use duct::cmd;
|
use duct::cmd;
|
||||||
use glib::*;
|
use glib::*;
|
||||||
@ -15,10 +15,8 @@ use std::time::*;
|
|||||||
pub fn kernel_pkg_page(
|
pub fn kernel_pkg_page(
|
||||||
content_stack: >k::Stack,
|
content_stack: >k::Stack,
|
||||||
window: &adw::ApplicationWindow,
|
window: &adw::ApplicationWindow,
|
||||||
selected_kernel_branch: &Rc<RefCell<KernelBranch>>,
|
kernel_db: String,
|
||||||
) {
|
) {
|
||||||
let selected_kernel_branch_clone0 = selected_kernel_branch.borrow().clone();
|
|
||||||
|
|
||||||
let parse_loading_dialog = adw::MessageDialog::builder()
|
let parse_loading_dialog = adw::MessageDialog::builder()
|
||||||
.transient_for(window)
|
.transient_for(window)
|
||||||
.extra_child(>k::Spinner::builder()
|
.extra_child(>k::Spinner::builder()
|
||||||
@ -41,7 +39,7 @@ pub fn kernel_pkg_page(
|
|||||||
.orientation(Orientation::Vertical)
|
.orientation(Orientation::Vertical)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let main_label = gtk::Label::builder()
|
/*let main_label = gtk::Label::builder()
|
||||||
.label(format!(
|
.label(format!(
|
||||||
"{} {}", t!("kernel_main_label_label"),
|
"{} {}", t!("kernel_main_label_label"),
|
||||||
&selected_kernel_branch_clone0.name
|
&selected_kernel_branch_clone0.name
|
||||||
@ -54,7 +52,7 @@ pub fn kernel_pkg_page(
|
|||||||
.margin_top(20)
|
.margin_top(20)
|
||||||
.build();
|
.build();
|
||||||
main_label.add_css_class("symbolic-accent-bg");
|
main_label.add_css_class("symbolic-accent-bg");
|
||||||
main_label.add_css_class("size-20-font");
|
main_label.add_css_class("size-20-font");*/
|
||||||
|
|
||||||
let main_icon = gtk::Image::builder()
|
let main_icon = gtk::Image::builder()
|
||||||
.pixel_size(48)
|
.pixel_size(48)
|
||||||
@ -71,7 +69,7 @@ pub fn kernel_pkg_page(
|
|||||||
|
|
||||||
let main_label_box = gtk::Box::new(Orientation::Horizontal, 0);
|
let main_label_box = gtk::Box::new(Orientation::Horizontal, 0);
|
||||||
main_label_box.append(&main_icon);
|
main_label_box.append(&main_icon);
|
||||||
main_label_box.append(&main_label);
|
//main_label_box.append(&main_label);
|
||||||
|
|
||||||
let searchbar = gtk::SearchEntry::builder()
|
let searchbar = gtk::SearchEntry::builder()
|
||||||
.search_delay(500)
|
.search_delay(500)
|
||||||
@ -99,7 +97,7 @@ pub fn kernel_pkg_page(
|
|||||||
|
|
||||||
add_package_rows(
|
add_package_rows(
|
||||||
&packages_boxedlist,
|
&packages_boxedlist,
|
||||||
selected_kernel_branch_clone0.db,
|
kernel_db,
|
||||||
&window,
|
&window,
|
||||||
&rows_size_group,
|
&rows_size_group,
|
||||||
&searchbar,
|
&searchbar,
|
||||||
@ -183,12 +181,6 @@ fn add_package_rows(
|
|||||||
.unwrap()
|
.unwrap()
|
||||||
.to_string();
|
.to_string();
|
||||||
let kernel_packages = kernel["packages"].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(
|
let kernel_package_version = match Command::new(
|
||||||
"/usr/lib/pika/kernel-manager/scripts/generate_package_info.sh",
|
"/usr/lib/pika/kernel-manager/scripts/generate_package_info.sh",
|
||||||
)
|
)
|
||||||
@ -212,7 +204,6 @@ fn add_package_rows(
|
|||||||
name: kernel_name,
|
name: kernel_name,
|
||||||
main_package: kernel_main_package,
|
main_package: kernel_main_package,
|
||||||
packages: kernel_packages,
|
packages: kernel_packages,
|
||||||
min_x86_march: kernel_min_x86_march,
|
|
||||||
package_version: kernel_package_version,
|
package_version: kernel_package_version,
|
||||||
description: kernel_description
|
description: kernel_description
|
||||||
};
|
};
|
||||||
@ -228,7 +219,6 @@ fn add_package_rows(
|
|||||||
let kernel_name = kernel_pkg_status.name;
|
let kernel_name = kernel_pkg_status.name;
|
||||||
let kernel_main_package = kernel_pkg_status.main_package;
|
let kernel_main_package = kernel_pkg_status.main_package;
|
||||||
let kernel_packages = kernel_pkg_status.packages;
|
let kernel_packages = kernel_pkg_status.packages;
|
||||||
let kernel_min_x86_march = kernel_pkg_status.min_x86_march;
|
|
||||||
let kernel_package_version = kernel_pkg_status.package_version;
|
let kernel_package_version = kernel_pkg_status.package_version;
|
||||||
let kernel_description = textwrap::fill(&kernel_pkg_status.description, 40);
|
let kernel_description = textwrap::fill(&kernel_pkg_status.description, 40);
|
||||||
|
|
||||||
@ -456,9 +446,7 @@ fn add_package_rows(
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
if cpu_feature_level >= kernel_min_x86_march {
|
boxedlist.append(&kernel_expander_row);
|
||||||
boxedlist.append(&kernel_expander_row);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
13
src/main.rs
13
src/main.rs
@ -51,7 +51,8 @@ i18n!(fallback = "en_US", backend = I18nBackend::new());
|
|||||||
const APP_ID: &str = "com.github.pikaos-linux.pika-kernel-manager";
|
const APP_ID: &str = "com.github.pikaos-linux.pika-kernel-manager";
|
||||||
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||||
pub const APP_ICON: &str = "com.github.pikaos-linux.pika-kernel-manager";
|
pub const APP_ICON: &str = "com.github.pikaos-linux.pika-kernel-manager";
|
||||||
pub const APP_GITHUB: &str = "https://github.com/CosmicFusion/pika-kernel-manager";
|
pub const APP_GITHUB: &str = "https://git.pika-os.com/custom-gui-packages/pika-kernel-manager";
|
||||||
|
pub const KERNEL_DB_JSON_URL: &str = "https://git.pika-os.com/custom-gui-packages/pika-kernel-manager/raw/branch/main/kernel-db.json";
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct RunningKernelInfo {
|
struct RunningKernelInfo {
|
||||||
@ -60,20 +61,10 @@ struct RunningKernelInfo {
|
|||||||
sched: String,
|
sched: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
#[derive(Clone)]
|
|
||||||
struct KernelBranch {
|
|
||||||
name: String,
|
|
||||||
db_url: String,
|
|
||||||
db: String,
|
|
||||||
init_script: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct KernelPackage {
|
struct KernelPackage {
|
||||||
name: String,
|
name: String,
|
||||||
main_package: String,
|
main_package: String,
|
||||||
packages: String,
|
packages: String,
|
||||||
min_x86_march: u32,
|
|
||||||
package_version: String,
|
package_version: String,
|
||||||
description: String
|
description: String
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user