From 2ab9308ec9f09788370176c8625b990ffd672f30 Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Sat, 7 Sep 2024 13:20:56 +0300 Subject: [PATCH] begin add apt repo mgmt --- Cargo.lock | 172 ++++++++++++++++++++++++++--- Cargo.toml | 2 + locales/en_US.json | 3 +- src/bin/gui/apt_manage_page/mod.rs | 52 +++++++++ src/bin/gui/build_ui/mod.rs | 7 ++ src/bin/gui/main.rs | 1 + 6 files changed, 223 insertions(+), 14 deletions(-) create mode 100644 src/bin/gui/apt_manage_page/mod.rs diff --git a/Cargo.lock b/Cargo.lock index 304188d..c4da664 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -41,6 +41,14 @@ dependencies = [ "libc", ] +[[package]] +name = "apt-sources-lists" +version = "0.1.0" +source = "git+https://github.com/CosmicFusion/apt-sources-lists-snapshot#d15cbccf8329db0e530bbe910c5b7a49c697e547" +dependencies = [ + "err-derive", +] + [[package]] name = "arc-swap" version = "1.7.1" @@ -67,7 +75,7 @@ checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.70", ] [[package]] @@ -252,6 +260,12 @@ version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" +[[package]] +name = "countme" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7704b5fdd17b18ae31c4c1da5a2e0305a2bf17b5249300a9ee9ed7b72114c636" + [[package]] name = "crossbeam-deque" version = "0.8.5" @@ -312,7 +326,7 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn", + "syn 2.0.70", ] [[package]] @@ -329,7 +343,26 @@ checksum = "4b2c1c1776b986979be68bb2285da855f8d8a35851a769fca8740df7c3d07877" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.70", +] + +[[package]] +name = "deb822-lossless" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "286f48b96d8b0b1430db71c92b8a641f5edf0d926d44f51bf2159aabcf526a2a" +dependencies = [ + "regex", + "rowan", + "serde", +] + +[[package]] +name = "deb822-tools" +version = "0.1.0" +source = "git+https://github.com/CosmicFusion/deb822-tools#9bcf4f74dd2fe345488d31c192f2d7cb3e1f1706" +dependencies = [ + "deb822-lossless", ] [[package]] @@ -338,6 +371,20 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +[[package]] +name = "err-derive" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22deed3a8124cff5fa835713fa105621e43bbdc46690c3a6b68328a012d350d4" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "rustversion", + "syn 1.0.109", + "synstructure", +] + [[package]] name = "errno" version = "0.3.9" @@ -463,7 +510,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.70", ] [[package]] @@ -684,7 +731,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn", + "syn 2.0.70", ] [[package]] @@ -697,7 +744,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn", + "syn 2.0.70", ] [[package]] @@ -856,7 +903,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn", + "syn 2.0.70", ] [[package]] @@ -1010,6 +1057,14 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +[[package]] +name = "legacy-apt-list-tools-rs" +version = "0.1.0" +source = "git+https://github.com/CosmicFusion/legacy-apt-list-tools-rs#0606e8431239a45a14cddc9934ad3eab46e4bb99" +dependencies = [ + "apt-sources-lists", +] + [[package]] name = "libadwaita" version = "0.7.0" @@ -1349,8 +1404,10 @@ dependencies = [ "async-trait", "chrono", "crossbeam-utils 0.8.20", + "deb822-tools", "futures 0.3.30", "gtk4", + "legacy-apt-list-tools-rs", "libadwaita", "libflatpak", "lock_api 0.4.12", @@ -1400,6 +1457,30 @@ dependencies = [ "toml_edit 0.21.1", ] +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + [[package]] name = "proc-macro2" version = "1.0.86" @@ -1462,6 +1543,18 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +[[package]] +name = "rowan" +version = "0.15.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a542b0253fa46e632d27a1dc5cf7b930de4df8659dc6e720b647fc72147ae3d" +dependencies = [ + "countme", + "hashbrown 0.14.5", + "rustc-hash", + "text-size", +] + [[package]] name = "rust-apt" version = "0.7.0" @@ -1501,7 +1594,7 @@ dependencies = [ "serde", "serde_json", "serde_yaml", - "syn", + "syn 2.0.70", ] [[package]] @@ -1530,6 +1623,12 @@ version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustc_version" version = "0.2.3" @@ -1561,6 +1660,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "rustversion" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" + [[package]] name = "ryu" version = "1.0.18" @@ -1626,7 +1731,7 @@ checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.70", ] [[package]] @@ -1710,6 +1815,17 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "syn" version = "2.0.70" @@ -1721,6 +1837,18 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "synstructure" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", + "unicode-xid", +] + [[package]] name = "system-deps" version = "6.2.2" @@ -1772,6 +1900,12 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "text-size" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f18aa187839b2bdb1ad2fa35ead8c4c2976b64e4363c386d45ac0f7ee85c9233" + [[package]] name = "thiserror" version = "1.0.61" @@ -1789,7 +1923,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.70", ] [[package]] @@ -1851,7 +1985,7 @@ checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.70", ] [[package]] @@ -1994,12 +2128,24 @@ version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" +[[package]] +name = "unicode-xid" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "229730647fbc343e3a80e463c1db7f78f3855d3f3739bee0dda773c9a037c90a" + [[package]] name = "version-compare" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "852e951cb7832cb45cb1169900d19760cfa39b82bc0ea9c0e5a14ae88411c98b" +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + [[package]] name = "walkdir" version = "2.5.0" @@ -2037,7 +2183,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn", + "syn 2.0.70", "wasm-bindgen-shared", ] @@ -2059,7 +2205,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.70", "wasm-bindgen-backend", "wasm-bindgen-shared", ] diff --git a/Cargo.toml b/Cargo.toml index 8ef248e..ded7277 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,6 +26,8 @@ gtk = { version = "0.9.0", package = "gtk4", features = ["v4_12"] } async-channel = "2.1.1" rust-i18n = "3.0.1" rust-apt = { git = "https://gitlab.com/volian/rust-apt" } +apt-deb822-tools = { package = "deb822-tools", git = "https://github.com/CosmicFusion/deb822-tools" } +apt-legacy-tools = { package = "legacy-apt-list-tools-rs", git = "https://github.com/CosmicFusion/legacy-apt-list-tools-rs" } tokio = { version = "1", features = ["full"] } tokio-uds = "0.2" serde = { version = "1.0.203", features = ["derive"] } diff --git a/locales/en_US.json b/locales/en_US.json index 92f49b3..aff8e41 100644 --- a/locales/en_US.json +++ b/locales/en_US.json @@ -84,5 +84,6 @@ "apt_update_dialog_ignore_label": "Ignore APT Updates", "apt_ignored_viewport_page_title": "APT Updates Were Failed & Ignored", "flatpak_update_dialog_ignore_label": "Ignore Flatpak Updates", - "flatpak_ignored_viewport_page_title": "Flatpak Updates Were Failed & Ignored" + "flatpak_ignored_viewport_page_title": "Flatpak Updates Were Failed & Ignored", + "apt_manage_page_title": "APT Settings" } \ No newline at end of file diff --git a/src/bin/gui/apt_manage_page/mod.rs b/src/bin/gui/apt_manage_page/mod.rs new file mode 100644 index 0000000..25dbf37 --- /dev/null +++ b/src/bin/gui/apt_manage_page/mod.rs @@ -0,0 +1,52 @@ +use crate::apt_package_row::AptPackageRow; +use adw::gio::SimpleAction; +use adw::prelude::*; +use apt_deb822_tools::Deb822Repository; +use gtk::glib::*; +use gtk::*; +use pika_unixsocket_tools::pika_unixsocket_tools::*; +use rust_apt::cache::*; +use rust_apt::new_cache; +use rust_apt::records::RecordField; +use std::cell::RefCell; +use std::process::Command; +use std::rc::Rc; +use std::thread; +use tokio::runtime::Runtime; + + +pub fn apt_manage_page( + window: adw::ApplicationWindow, + retry_signal_action: &SimpleAction, +) -> gtk::Box { + + let deb822_sources = Deb822Repository::get_deb822_sources().unwrap(); + + let system_source = deb822_sources.iter().filter(|x| { + match &x.repolib_id { + Some(t) => { + if t == "system" { + true + } else { + false + } + } + None => false + } + }).next().unwrap(); + + let main_box = Box::builder() + .hexpand(true) + .vexpand(true) + .orientation(Orientation::Vertical) + .build(); + + let system_mirror_entry = gtk::Entry::builder() + .placeholder_text(system_source.repolib_default_mirror.as_deref().unwrap()) + .text(system_source.uris.as_deref().unwrap()) + .build(); + + main_box.append(&system_mirror_entry); + + main_box +} \ No newline at end of file diff --git a/src/bin/gui/build_ui/mod.rs b/src/bin/gui/build_ui/mod.rs index 777d8f0..f748ee1 100644 --- a/src/bin/gui/build_ui/mod.rs +++ b/src/bin/gui/build_ui/mod.rs @@ -1,3 +1,4 @@ +use crate::apt_manage_page::apt_manage_page; use crate::apt_update_page; use crate::config::{APP_GITHUB, APP_ICON, APP_ID, VERSION}; use crate::flatpak_update_page; @@ -275,6 +276,12 @@ pub fn build_ui(app: &Application) { &t!("flatpak_update_page_title"), ); + window_adw_stack.add_titled( + &apt_manage_page(window, &apt_retry_signal_action), + Some("apt_manage_page"), + &t!("apt_manage_page_title"), + ); + // Refresh button refresh_button.connect_clicked(clone!( diff --git a/src/bin/gui/main.rs b/src/bin/gui/main.rs index bbbc648..9bb1db6 100644 --- a/src/bin/gui/main.rs +++ b/src/bin/gui/main.rs @@ -1,5 +1,6 @@ mod apt_package_row; mod apt_update_page; +mod apt_manage_page; mod build_ui; mod config; mod flatpak_ref_row;