RR: Fix manual crypttab + add basis for translations + config.rs

This commit is contained in:
Ward from fusion-voyager-3 2024-02-18 18:39:04 +03:00
parent aea05bb610
commit a35c78fb21
9 changed files with 197 additions and 17 deletions

137
Cargo.lock generated
View File

@ -2,6 +2,15 @@
# It is not intended for manual editing.
version = 3
[[package]]
name = "aho-corasick"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0"
dependencies = [
"memchr",
]
[[package]]
name = "anyhow"
version = "1.0.79"
@ -50,6 +59,12 @@ version = "2.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"
[[package]]
name = "block"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
[[package]]
name = "cairo-rs"
version = "0.18.5"
@ -75,6 +90,15 @@ dependencies = [
"system-deps",
]
[[package]]
name = "cc"
version = "1.0.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
dependencies = [
"libc",
]
[[package]]
name = "cfg-expr"
version = "0.15.6"
@ -294,6 +318,26 @@ dependencies = [
"unicode-width",
]
[[package]]
name = "gettext-rs"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e49ea8a8fad198aaa1f9655a2524b64b70eb06b2f3ff37da407566c93054f364"
dependencies = [
"gettext-sys",
"locale_config",
]
[[package]]
name = "gettext-sys"
version = "0.21.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c63ce2e00f56a206778276704bbe38564c8695249fdc8f354b4ef71c57c3839d"
dependencies = [
"cc",
"temp-dir",
]
[[package]]
name = "gio"
version = "0.18.4"
@ -552,6 +596,12 @@ version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c"
[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libadwaita"
version = "0.5.3"
@ -590,6 +640,28 @@ version = "0.2.152"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7"
[[package]]
name = "locale_config"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d2c35b16f4483f6c26f0e4e9550717a2f6575bcd6f12a53ff0c490a94a6934"
dependencies = [
"lazy_static",
"objc",
"objc-foundation",
"regex",
"winapi",
]
[[package]]
name = "malloc_buf"
version = "0.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb"
dependencies = [
"libc",
]
[[package]]
name = "memchr"
version = "2.7.1"
@ -605,6 +677,35 @@ dependencies = [
"autocfg",
]
[[package]]
name = "objc"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1"
dependencies = [
"malloc_buf",
]
[[package]]
name = "objc-foundation"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9"
dependencies = [
"block",
"objc",
"objc_id",
]
[[package]]
name = "objc_id"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c92d4ddb4bd7b50d730c215ff871754d0da6b2178849f8a2a2ab69712d0c073b"
dependencies = [
"objc",
]
[[package]]
name = "once_cell"
version = "1.19.0"
@ -659,6 +760,7 @@ dependencies = [
"async-channel",
"duct",
"fragile",
"gettext-rs",
"glib",
"glob",
"gtk4",
@ -766,6 +868,35 @@ dependencies = [
"proc-macro2",
]
[[package]]
name = "regex"
version = "1.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15"
dependencies = [
"aho-corasick",
"memchr",
"regex-automata",
"regex-syntax",
]
[[package]]
name = "regex-automata"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
[[package]]
name = "rustc_version"
version = "0.4.0"
@ -893,6 +1024,12 @@ version = "0.12.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69758bda2e78f098e4ccb393021a0963bb3442eac05f135c30f61b7370bbafae"
[[package]]
name = "temp-dir"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd16aa9ffe15fe021c6ee3766772132c6e98dfa395a167e16864f61a9cfb71d6"
[[package]]
name = "thiserror"
version = "1.0.56"

View File

@ -16,5 +16,6 @@ pretty-bytes = "0.2.2"
time = "0.3.31"
vte = { version = "0.0.2", package = "zoha-vte4", features = ["v0_72"] }
glob = "0.3.1"
gettext-rs = { version = "0.7", features = ["gettext-system"] }
serde_json = "1.0.113"
serde = { version = "1.0", features = ["derive"] }

View File

@ -21,13 +21,13 @@ then
LUKS=$(jq -r .partition $cryptentry)
MAP=$(jq -r .partition $cryptentry | cut -d "/" -f2-)
UUID="$(blkid "$(lsblk -sJp | jq -r --arg dsk /dev/"$LUKS" '.blockdevices | .[] | select(.name == $dsk) | .children | .[0] | .name')" -s UUID -o value)"
echo "$MAP $UUID none luks,discard" >> /tmp/pika-installer-gtk4-crypttab
echo "$MAP UUID="$UUID" none luks,discard" >> /tmp/pika-installer-gtk4-crypttab
else
LUKS=$(jq -r .partition $cryptentry)
MAP=$(jq -r .partition $cryptentry | cut -d "/" -f2-)
UUID="$(blkid "$(lsblk -sJp | jq -r --arg dsk /dev/"$LUKS" '.blockdevices | .[] | select(.name == $dsk) | .children | .[0] | .name')" -s UUID -o value)"
LUKS_PASSWD=$(jq -r .password $cryptentry)
echo "$MAP $UUID /key-"$MAP".txt luks" >> /tmp/pika-installer-gtk4-crypttab
echo "$MAP UUID="$UUID" /key-"$MAP".txt luks" >> /tmp/pika-installer-gtk4-crypttab
touch /key-"$MAP".txt
openssl genrsa > /key-"$MAP".txt
echo $LUKS_PASSWD | cryptsetup luksAddKey UUID=$UUID /key-"$MAP".txt -

7
src/config.rs Normal file
View File

@ -0,0 +1,7 @@
pub const APP_ID: &str = "com.github.pikaos-linux.pikainstallergtk4";
pub const GETTEXT_PACKAGE: &str = env!("CARGO_PKG_NAME");
pub const LOCALEDIR: &str = "/usr/share/locale";
//pub const PKGDATADIR: &str = " /usr/share";
//pub const RESOURCES_FILE: &str = concat!(@PKGDATADIR@, "/resources.gresource");
//pub const VERSION: &str = env!("CARGO_PKG_VERSION");
pub const DISTRO_ICON: &str = "pika-logo";

View File

@ -6,6 +6,8 @@ use glib::*;
/// Use all libadwaita libraries (libadwaita -> adw because cargo)
use gtk::*;
use crate::config::{DISTRO_ICON};
use std::path::Path;
use std::process::Command;
@ -32,7 +34,7 @@ pub fn done_page(
// the header icon for the installation_successful icon
let done_header_icon = gtk::Image::builder()
.icon_name("debian-swirl")
.icon_name(DISTRO_ICON)
.halign(gtk::Align::Start)
.hexpand(true)
.pixel_size(78)

View File

@ -70,33 +70,47 @@ impl ObjectImpl for DriveMountRow {
.width_request(300)
.build();
let mountpoint_entry_adw_box = gtk::Box::builder()
.hexpand(true)
.valign(gtk::Align::Start)
.homogeneous(true)
.build();
let mountpoint_entry_adw_listbox = gtk::ListBox::builder()
.margin_top(5)
.margin_bottom(5)
.vexpand(true)
.hexpand(true)
.valign(gtk::Align::Start)
.build();
mountpoint_entry_adw_listbox.add_css_class("boxed-list");
let mountpoint_entry_row = adw::EntryRow::builder()
.title("Mountpoint")
.vexpand(true)
.hexpand(true)
.valign(gtk::Align::Start)
.width_request(300)
.build();
let mountopt_entry_adw_box = gtk::Box::builder()
.hexpand(true)
.valign(gtk::Align::Start)
.homogeneous(true)
.build();
let mountopt_entry_adw_listbox = gtk::ListBox::builder()
.margin_top(5)
.margin_bottom(5)
.margin_start(5)
.vexpand(true)
.hexpand(true)
.valign(gtk::Align::Start)
.build();
mountopt_entry_adw_listbox.add_css_class("boxed-list");
let mountopt_entry_row = adw::EntryRow::builder()
.title("Additional Mount Options")
.vexpand(true)
.hexpand(true)
.valign(gtk::Align::Start)
.width_request(300)
.build();
let partition_row_delete_button = gtk::Button::builder()
@ -104,9 +118,9 @@ impl ObjectImpl for DriveMountRow {
.margin_start(5)
.margin_top(5)
.margin_bottom(5)
.width_request(40)
.vexpand(true)
.hexpand(true)
.width_request(53)
.height_request(53)
.valign(gtk::Align::Start)
.icon_name("edit-delete")
.halign(gtk::Align::End)
.build();
@ -119,10 +133,12 @@ impl ObjectImpl for DriveMountRow {
action_row_content_box.append(&partition_row_expander_adw_listbox);
mountpoint_entry_adw_listbox.append(&mountpoint_entry_row);
action_row_content_box.append(&mountpoint_entry_adw_listbox);
mountpoint_entry_adw_box.append(&mountpoint_entry_adw_listbox);
action_row_content_box.append(&mountpoint_entry_adw_box);
mountopt_entry_adw_listbox.append(&mountopt_entry_row);
action_row_content_box.append(&mountopt_entry_adw_listbox);
mountopt_entry_adw_box.append(&mountopt_entry_adw_listbox);
action_row_content_box.append(&mountopt_entry_adw_box);
action_row_content_box.append(&partition_row_delete_button);

View File

@ -1,3 +1,4 @@
use crate::config::DISTRO_ICON;
use std::cell::RefCell;
// Use libraries
use adw::prelude::*;
@ -423,7 +424,7 @@ pub fn install_page(
.build();
let placeholder_icon = gtk::Image::builder()
.icon_name("debian-swirl")
.icon_name(DISTRO_ICON)
.halign(gtk::Align::Center)
.valign(gtk::Align::Center)
.hexpand(true)

View File

@ -1,4 +1,5 @@
// Use libraries
use crate::build_ui::build_ui;
use adw::prelude::*;
use adw::*;
use gdk::Display;
@ -6,6 +7,10 @@ use gdk::Display;
/// Use all libadwaita libraries (libadwaita -> adw because cargo)
use gtk::*;
mod config;
use gettextrs::{gettext, LocaleCategory};
use config::{GETTEXT_PACKAGE, LOCALEDIR, APP_ID};
mod automatic_partitioning;
mod build_ui;
mod done_page;
@ -24,7 +29,7 @@ mod welcome_page;
/// main function
fn main() {
let application = adw::Application::new(
Some("com.github.pikaos-linux.pikainstallergtk4"),
Some(APP_ID),
Default::default(),
);
application.connect_startup(|app| {
@ -38,8 +43,18 @@ fn main() {
&provider,
STYLE_PROVIDER_PRIORITY_APPLICATION,
);
// Prepare i18n
gettextrs::setlocale(LocaleCategory::LcAll, "");
gettextrs::bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR).expect("Unable to bind the text domain");
gettextrs::textdomain(GETTEXT_PACKAGE).expect("Unable to switch to the text domain");
// Fallback if no translation present
if gettext("first_setup_initial_box_text_title") == "first_setup_initial_box_text_title" {
println!("Warning: Current LANG is not supported, using fallback Locale.");
gettextrs::setlocale(LocaleCategory::LcAll, "en_US.UTF8");
}
app.connect_activate(build_ui::build_ui);
app.connect_activate(build_ui);
});
application.run();
}
}

View File

@ -1,4 +1,5 @@
// Use libraries
use crate::config::DISTRO_ICON;
use adw::prelude::*;
use adw::*;
use glib::*;
@ -31,7 +32,7 @@ pub fn welcome_page(window: &adw::ApplicationWindow, content_stack: &gtk::Stack)
// the header icon for the welcome icon
let welcome_header_icon = gtk::Image::builder()
.icon_name("debian-swirl")
.icon_name(DISTRO_ICON)
.halign(gtk::Align::Start)
.hexpand(true)
.pixel_size(78)