fix full select
This commit is contained in:
parent
0c03d60203
commit
c055c23e08
@ -10,38 +10,48 @@ fn main() {
|
|||||||
let percent_socket_path = "/tmp/pika_apt_upgrade_percent.sock";
|
let percent_socket_path = "/tmp/pika_apt_upgrade_percent.sock";
|
||||||
let status_socket_path = "/tmp/pika_apt_upgrade_status.sock";
|
let status_socket_path = "/tmp/pika_apt_upgrade_status.sock";
|
||||||
let json_file_path = "/tmp/pika-apt-exclusions.json";
|
let json_file_path = "/tmp/pika-apt-exclusions.json";
|
||||||
let mut excluded_updates_vec = Vec::new();
|
let mut excluded_updates_vec: Vec<String> = Vec::new();
|
||||||
|
|
||||||
let json: serde_json::Value = serde_json::from_str(
|
if std::path::Path::new(json_file_path).exists() {
|
||||||
&std::fs::read_to_string(json_file_path).expect("Unable to read file"),
|
let data = std::fs::read_to_string(json_file_path).expect("Unable to read file");
|
||||||
)
|
let json: serde_json::Value = serde_json::from_str(&data).expect("JSON was not well-formatted");
|
||||||
.expect("JSON was not well-formatted");
|
|
||||||
|
if let serde_json::Value::Array(exclusions) = &json["exclusions"] {
|
||||||
if let serde_json::Value::Array(exclusions) = &json["exclusions"] {
|
for exclusion in exclusions {
|
||||||
for exclusion in exclusions {
|
match exclusion["package"].as_str() {
|
||||||
excluded_updates_vec.push(exclusion["package"].as_str().unwrap());
|
Some(v) => {
|
||||||
|
excluded_updates_vec.push(v.to_owned());
|
||||||
|
}
|
||||||
|
None => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let apt_cache = new_cache!().unwrap();
|
let apt_cache = new_cache!().unwrap();
|
||||||
let apt_upgrade_cache = new_cache!().unwrap();
|
|
||||||
|
|
||||||
apt_cache.upgrade(Upgrade::FullUpgrade).unwrap();
|
apt_cache.upgrade(Upgrade::FullUpgrade).unwrap();
|
||||||
|
|
||||||
for change in apt_cache.get_changes(false) {
|
let apt_upgrade_cache = if excluded_updates_vec.is_empty() {
|
||||||
if !excluded_updates_vec
|
apt_cache
|
||||||
.iter()
|
} else {
|
||||||
.any(|e| change.name().contains(e))
|
let apt_upgrade_cache = new_cache!().unwrap();
|
||||||
{
|
for change in apt_cache.get_changes(false) {
|
||||||
let pkg = apt_upgrade_cache.get(change.name()).unwrap();
|
if !excluded_updates_vec
|
||||||
if change.marked_upgrade() || change.marked_install() || change.marked_downgrade() {
|
.iter()
|
||||||
pkg.mark_install(true, false);
|
.any(|e| change.name().contains(e))
|
||||||
} else if change.marked_delete() {
|
{
|
||||||
pkg.mark_delete(false);
|
let pkg = apt_upgrade_cache.get(change.name()).unwrap();
|
||||||
|
if change.marked_upgrade() || change.marked_install() || change.marked_downgrade() {
|
||||||
|
pkg.mark_install(true, false);
|
||||||
|
} else if change.marked_delete() {
|
||||||
|
pkg.mark_delete(false);
|
||||||
|
}
|
||||||
|
pkg.protect();
|
||||||
}
|
}
|
||||||
pkg.protect();
|
|
||||||
}
|
}
|
||||||
}
|
apt_upgrade_cache
|
||||||
|
};
|
||||||
|
|
||||||
apt_upgrade_cache.resolve(true).unwrap();
|
apt_upgrade_cache.resolve(true).unwrap();
|
||||||
|
|
||||||
|
@ -209,7 +209,10 @@ pub fn apt_update_page(
|
|||||||
// The main loop executes the asynchronous block
|
// The main loop executes the asynchronous block
|
||||||
update_percent_server_context.spawn_local(clone!(#[weak] apt_update_dialog_progress_bar, async move {
|
update_percent_server_context.spawn_local(clone!(#[weak] apt_update_dialog_progress_bar, async move {
|
||||||
while let Ok(state) = update_percent_receiver.recv().await {
|
while let Ok(state) = update_percent_receiver.recv().await {
|
||||||
apt_update_dialog_progress_bar.set_fraction(state.parse::<f64>().unwrap()/100.0)
|
match state.parse::<f64>() {
|
||||||
|
Ok(p) => apt_update_dialog_progress_bar.set_fraction(p/100.0),
|
||||||
|
Err(_) => {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -471,7 +471,10 @@ fn apt_full_upgrade_from_socket(
|
|||||||
match state.as_ref() {
|
match state.as_ref() {
|
||||||
"FN_OVERRIDE_SUCCESSFUL" => {}
|
"FN_OVERRIDE_SUCCESSFUL" => {}
|
||||||
_ => {
|
_ => {
|
||||||
apt_upgrade_dialog_progress_bar.set_fraction(state.parse::<f64>().unwrap()/100.0)
|
match state.parse::<f64>() {
|
||||||
|
Ok(p) => apt_upgrade_dialog_progress_bar.set_fraction(p/100.0),
|
||||||
|
Err(_) => {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,8 @@ use std::thread;
|
|||||||
|
|
||||||
pub fn build_ui(app: &Application) {
|
pub fn build_ui(app: &Application) {
|
||||||
// setup glib
|
// setup glib
|
||||||
glib::set_prgname(Some(t!("app_name").to_string()));
|
glib::set_prgname(Some(t!("application_name").to_string()));
|
||||||
glib::set_application_name(&t!("app_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 (internet_loop_sender, internet_loop_receiver) = async_channel::unbounded();
|
let (internet_loop_sender, internet_loop_receiver) = async_channel::unbounded();
|
||||||
|
Loading…
Reference in New Issue
Block a user