Add gpg key downloader

This commit is contained in:
Ward from fusion-voyager-3 2024-09-21 23:15:54 +03:00
parent 830def1d3d
commit 6ab9b48579
6 changed files with 69 additions and 3 deletions

42
Cargo.lock generated
View File

@ -365,6 +365,18 @@ dependencies = [
"deb822-lossless",
]
[[package]]
name = "duct"
version = "0.13.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4ab5718d1224b63252cd0c6f74f6480f9ffeb117438a2e0f5cf6d9a4798929c"
dependencies = [
"libc",
"once_cell",
"os_pipe",
"shared_child",
]
[[package]]
name = "equivalent"
version = "1.0.1"
@ -1311,6 +1323,16 @@ version = "1.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
[[package]]
name = "os_pipe"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ffd2b0a5634335b135d5728d84c5e0fd726954b87111f7506a61c502280d982"
dependencies = [
"libc",
"windows-sys 0.59.0",
]
[[package]]
name = "pango"
version = "0.20.0"
@ -1405,6 +1427,7 @@ dependencies = [
"chrono",
"crossbeam-utils 0.8.20",
"deb822-tools",
"duct",
"futures 0.3.30",
"gtk4",
"legacy-apt-list-tools-rs",
@ -1767,6 +1790,16 @@ dependencies = [
"yaml-rust",
]
[[package]]
name = "shared_child"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09fa9338aed9a1df411814a5b2252f7cd206c55ae9bf2fa763f8de84603aa60c"
dependencies = [
"libc",
"windows-sys 0.59.0",
]
[[package]]
name = "signal-hook-registry"
version = "1.4.2"
@ -2287,6 +2320,15 @@ dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "windows-sys"
version = "0.59.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "windows-targets"
version = "0.48.5"

View File

@ -40,4 +40,5 @@ chrono = "0.4.38"
lock_api = "0.4.2"
libflatpak = { version = "0.5.0", package = "libflatpak", features = ["v1_11_1"] }
regex = "1.10.6"
duct = "0.13.7"

View File

@ -14,6 +14,7 @@ install:
cp -vf target/release/pikman-update-manager $(DESTDIR)/usr/bin/
cp -vf target/release/apt_update $(DESTDIR)/usr/lib/pika/pikman-update-manager/scripts/
cp -vf target/release/apt_full_upgrade $(DESTDIR)/usr/lib/pika/pikman-update-manager/scripts/
cp -vf data/wget.sh $(DESTDIR)/usr/lib/pika/pikman-update-manager/scripts/
cp -vf data/*.gschema.xml $(DESTDIR)/usr/share/glib-2.0/schemas/
#cp -vf data/com.github.pikaos-linux.pikagnomelayouts.desktop $(DESTDIR)/usr/share/applications/
#cp -vfr data/polkit-1 $(DESTDIR)/usr/share/
@ -29,6 +30,7 @@ install_no_build_debug:
cp -vf target/debug/pikman-update-manager $(DESTDIR)/usr/bin/
cp -vf target/debug/apt_update $(DESTDIR)/usr/lib/pika/pikman-update-manager/scripts/
cp -vf target/debug/apt_full_upgrade $(DESTDIR)/usr/lib/pika/pikman-update-manager/scripts/
cp -vf data/wget.sh $(DESTDIR)/usr/lib/pika/pikman-update-manager/scripts/
cp -vf data/*.gschema.xml $(DESTDIR)/usr/share/glib-2.0/schemas/
#cp -vf data/com.github.pikaos-linux.pikagnomelayouts.desktop $(DESTDIR)/usr/share/applications/
#cp -vfr data/polkit-1 $(DESTDIR)/usr/share/

2
data/wget.sh Normal file
View File

@ -0,0 +1,2 @@
#! /bin/bash
wget -O $2 $1

View File

@ -108,5 +108,7 @@
"unofficial_source_add_is_source_label_label": "With Source Repository",
"unofficial_source_signed_keyring_checkbutton_label": "Signed By Keyring",
"unofficial_source_signed_file_checkbutton_label": "Signed By File",
"unofficial_source_signed_url_checkbutton_label": "Signed By URL"
"unofficial_source_signed_url_checkbutton_label": "Signed By URL",
"key_download_error_dialog_heading": "GPG Download Error",
"key_download_error_dialog_ok_label": "OK"
}

View File

@ -608,13 +608,30 @@ pub fn apt_manage_page(
Some(unofficial_source_add_archs_entry.text().to_string())
},
signed_by: match sign_method {
1 => Some(unofficial_source_add_archs_entry.text().to_string()),
1 => Some(unofficial_source_add_signed_entry.text().to_string()),
2 => Some(format!("/etc/apt/keyrings/{}.gpg.key", repo_file_name)),
_ => None
},
..Default::default()
};
dbg!(new_repo);
if sign_method == 2 {
let key_download_cmd = duct::cmd!("pkexec", "/usr/lib/pika/pikman-update-manager/scripts/wget.sh", &unofficial_source_add_signed_entry.text().to_string(), &format!("/etc/apt/keyrings/{}.gpg.key", repo_file_name))
.run();
match key_download_cmd {
Ok(_) => {}
Err(e) => {
let key_download_error_dialog = adw::MessageDialog::builder()
.heading(t!("key_download_error_dialog_heading"))
.body(e.to_string())
.build();
key_download_error_dialog.add_response(
"key_download_error_dialog_ok",
&t!("key_download_error_dialog_ok_label").to_string(),
);
key_download_error_dialog.present();
}
}
}
}
"apt_update_dialog_ignore" => {
unofficial_source_add_dialog.close();