begin terminal page

This commit is contained in:
Ward from fusion-voyager-3 2024-08-24 07:16:18 +03:00
parent 8e34fd3bcf
commit 8741225d1b
12 changed files with 542 additions and 414 deletions

View File

@ -27,7 +27,7 @@
"keyboard_page_title": "Keyboard",
"crypttab_dialog_response_crypttab_dialog_boot": "Unlock on Boot Manually",
"crypttab_dialog_response_crypttab_dialog_auto": "Unlock Automatically with Root Unlock",
"view_logs": "View Logs",
"progress_log_button_content_tooltip": "View Logs",
"parting_status_text": "Partitioning The Target Drives.",
"image_status_text": "Writing Image to target.",
"flag1_status_text": "Enabling BLS_BOOT flag on /boot.",

View File

@ -193,5 +193,7 @@ pub fn build_ui(app: &adw::Application) {
&partition_method_manual_crypttab_entry_array_refcell,
);
installation_progress_page::installation_progress_page(&carousel, &language_changed_action);
window.present()
}

View File

@ -1,436 +1,121 @@
use crate::{
build_ui::{BlockDevice, CrypttabEntry, FstabEntry, PikaKeymap, PikaLocale},
config::{MINIMUM_BOOT_BYTE_SIZE, MINIMUM_EFI_BYTE_SIZE},
config::{MINIMUM_BOOT_BYTE_SIZE, MINIMUM_EFI_BYTE_SIZE, DISTRO_ICON},
installer_stack_page,
installation_progress_page,
};
use adw::prelude::*;
use glib::{clone, closure_local};
use glib::{clone, closure_local, GString};
use gtk::{gio, glib};
use std::{cell::RefCell, fs, ops::Deref, path::Path, process::Command, rc::Rc};
mod auto_basic;
mod auto_btrfs;
mod auto_ext4;
mod auto_xfs;
mod manual_basic;
/// DEBUG
use std::io::{self, Write};
use duct::cmd;
/// DEBUG END
pub const standard_installation_prog: &str = r###"#! /bin/bash
set -e
pub fn installation_progress_page(
main_carousel: &adw::Carousel,
language_changed_action: &gio::SimpleAction,
) {
let installation_progress_box = gtk::Box::builder()
.orientation(gtk::Orientation::Vertical)
.build();
SOCKET_PATH="/tmp/pikainstall-status.sock"
let installation_progress_log_stack = gtk::Stack::builder()
.transition_type(gtk::StackTransitionType::SlideUpDown)
.margin_start(15)
.margin_end(15)
.build();
rm -rf /tmp/pika-installer-gtk4-swaplist
rm -rf /tmp/PIKA_CRYPT
let installation_progress_log_terminal_buffer = gtk::TextBuffer::builder().build();
PIKA_INSTALL_CHROOT_PATH='{CHROOT_PATH}'
PIKA_INSTALL_LOCALE='{LOCALE}.UTF-8'
PIKA_INSTALL_KEYMAP_BASE='{KEYMAP_BASE}'
PIKA_INSTALL_KEYMAP_VARIANT='{KEYMAP_VARIANT}'
PIKA_INSTALL_TIMEZONE='{TIMEZONE}'
"###;
let installation_progress_log_terminal = gtk::TextView::builder()
.vexpand(true)
.hexpand(true)
.editable(false)
.buffer(&installation_progress_log_terminal_buffer)
.build();
pub fn create_installation_script(
language_selection_text_refcell: &Rc<RefCell<PikaLocale>>,
keymap_selection_text_refcell: &Rc<RefCell<PikaKeymap>>,
timezone_selection_text_refcell: &Rc<RefCell<String>>,
partition_method_type_refcell: &Rc<RefCell<String>>,
partition_method_automatic_target_refcell: &Rc<RefCell<BlockDevice>>,
partition_method_automatic_target_fs_refcell: &Rc<RefCell<String>>,
partition_method_automatic_luks_enabled_refcell: &Rc<RefCell<bool>>,
partition_method_automatic_luks_refcell: &Rc<RefCell<String>>,
partition_method_automatic_ratio_refcell: &Rc<RefCell<f64>>,
partition_method_automatic_seperation_refcell: &Rc<RefCell<String>>,
partition_method_manual_fstab_entry_array_refcell: &Rc<RefCell<Vec<FstabEntry>>>,
partition_method_manual_luks_enabled_refcell: &Rc<RefCell<bool>>,
partition_method_manual_crypttab_entry_array_refcell: &Rc<RefCell<Vec<CrypttabEntry>>>,
) -> String {
let mut final_script = String::new();
let placeholder_icon = gtk::Image::builder()
.icon_name(DISTRO_ICON)
.halign(gtk::Align::Center)
.valign(gtk::Align::Center)
.hexpand(true)
.vexpand(true)
.pixel_size(256)
.margin_top(5)
.margin_bottom(5)
.margin_start(5)
.margin_end(5)
.build();
let variant = match keymap_selection_text_refcell.borrow().clone().variant {
Some(t) => {
t.replace("'", r###"'"'"'"###)
}
None => "".to_string(),
};
let progress_bar_box = gtk::Box::builder()
.orientation(gtk::Orientation::Horizontal)
.margin_start(10)
.margin_end(15)
.build();
let standard_installation_format = strfmt::strfmt(
standard_installation_prog,
&std::collections::HashMap::from([
("CHROOT_PATH".to_string(), "/media/pikaos/installation"),
(
"LOCALE".to_string(),
language_selection_text_refcell.borrow().name.replace("'", r###"'"'"'"###).as_str(),
),
(
"KEYMAP_BASE".to_string(),
keymap_selection_text_refcell.borrow().name.replace("'", r###"'"'"'"###).as_str(),
),
(
"KEYMAP_VARIANT".to_string(),
variant.as_str()
),
(
"TIMEZONE".to_string(),
timezone_selection_text_refcell.borrow().replace("'", r###"'"'"'"###).as_str(),
),
]),
)
.unwrap();
let installation_progress_bar = gtk::ProgressBar::builder()
.hexpand(true)
.margin_end(5)
.margin_top(5)
.margin_bottom(5)
.show_text(true)
.build();
installation_progress_bar.add_css_class("small_fg_text");
final_script.push_str(&standard_installation_format);
let progress_log_button = gtk::Button::builder()
.icon_name("terminal-symbolic")
.halign(gtk::Align::End)
.margin_start(5)
.margin_top(5)
.margin_bottom(5)
.build();
match &*partition_method_type_refcell.borrow().as_str() {
"automatic" => {
let is_encrypted = *partition_method_automatic_luks_enabled_refcell.borrow();
//
let automatic_standard_installation_format = strfmt::strfmt(
auto_basic::automatic_standard_installation_prog,
&std::collections::HashMap::from([
(
"AUTO_INSTALL_TARGET_DISK".to_string(),
partition_method_automatic_target_refcell.borrow().block_name.replace("'", r###"'"'"'"###).as_str(),
),
]),
)
.unwrap();
progress_bar_box.append(&installation_progress_bar);
progress_bar_box.append(&progress_log_button);
final_script.push_str(&automatic_standard_installation_format);
//
match &*partition_method_automatic_target_fs_refcell.borrow().as_str().to_lowercase() {
"btrfs" => {
match &*partition_method_automatic_seperation_refcell.borrow().as_str() {
"subvol" => {
if is_encrypted {
final_script.push_str(&strfmt::strfmt(
auto_btrfs::automatic_home_subvol_btrfs_locked_installation_prog,
&std::collections::HashMap::from([
("CHROOT_PATH".to_string(), "/media/pikaos/installation"),
(
"AUTO_LUKS_PASSWORD".to_string(),
partition_method_automatic_luks_refcell.borrow().replace("'", r###"'"'"'"###).as_str(),
)
]),
)
.unwrap());
} else {
final_script.push_str(&strfmt::strfmt(
auto_btrfs::automatic_home_subvol_btrfs_open_installation_prog,
&std::collections::HashMap::from([
("CHROOT_PATH".to_string(), "/media/pikaos/installation"),
]),
)
.unwrap());
}
}
"partition" => {
if is_encrypted {
final_script.push_str(&strfmt::strfmt(
auto_btrfs::automatic_home_part_btrfs_locked_installation_prog,
&std::collections::HashMap::from([
("CHROOT_PATH".to_string(), "/media/pikaos/installation"),
(
"AUTO_LUKS_PASSWORD".to_string(),
partition_method_automatic_luks_refcell.borrow().replace("'", r###"'"'"'"###).as_str(),
),
(
"ROOT_PART_SIZE_AS_I64_MIB".to_string(),
(partition_method_automatic_ratio_refcell.borrow().round() as i64 / 1048576).to_string().replace("'", r###"'"'"'"###).as_str(),
)
]),
)
.unwrap());
} else {
final_script.push_str(&strfmt::strfmt(
auto_btrfs::automatic_home_part_btrfs_open_installation_prog,
&std::collections::HashMap::from([
("CHROOT_PATH".to_string(), "/media/pikaos/installation"),
(
"ROOT_PART_SIZE_AS_I64_MIB".to_string(),
(partition_method_automatic_ratio_refcell.borrow().round() as i64 / 1048576).to_string().replace("'", r###"'"'"'"###).as_str(),
)
]),
)
.unwrap());
}
}
"none" => {
if is_encrypted {
final_script.push_str(&strfmt::strfmt(
auto_btrfs::automatic_home_none_btrfs_locked_installation_prog,
&std::collections::HashMap::from([
("CHROOT_PATH".to_string(), "/media/pikaos/installation"),
(
"AUTO_LUKS_PASSWORD".to_string(),
partition_method_automatic_luks_refcell.borrow().replace("'", r###"'"'"'"###).as_str(),
)
]),
)
.unwrap());
} else {
final_script.push_str(&strfmt::strfmt(
auto_btrfs::automatic_home_none_btrfs_open_installation_prog,
&std::collections::HashMap::from([
("CHROOT_PATH".to_string(), "/media/pikaos/installation"),
]),
)
.unwrap());
}
}
_ => panic!()
}
}
"ext4" => {
match &*partition_method_automatic_seperation_refcell.borrow().as_str() {
"partition" => {
if is_encrypted {
final_script.push_str(&strfmt::strfmt(
auto_ext4::automatic_home_part_ext4_locked_installation_prog,
&std::collections::HashMap::from([
("CHROOT_PATH".to_string(), "/media/pikaos/installation"),
(
"AUTO_LUKS_PASSWORD".to_string(),
partition_method_automatic_luks_refcell.borrow().replace("'", r###"'"'"'"###).as_str(),
),
(
"ROOT_PART_SIZE_AS_I64_MIB".to_string(),
(partition_method_automatic_ratio_refcell.borrow().round() as i64 / 1048576).to_string().replace("'", r###"'"'"'"###).as_str(),
)
]),
)
.unwrap());
} else {
final_script.push_str(&strfmt::strfmt(
auto_ext4::automatic_home_part_ext4_open_installation_prog,
&std::collections::HashMap::from([
("CHROOT_PATH".to_string(), "/media/pikaos/installation"),
(
"ROOT_PART_SIZE_AS_I64_MIB".to_string(),
(partition_method_automatic_ratio_refcell.borrow().round() as i64 / 1048576).to_string().replace("'", r###"'"'"'"###).as_str(),
)
]),
)
.unwrap());
}
}
"none" => {
if is_encrypted {
final_script.push_str(&strfmt::strfmt(
auto_ext4::automatic_home_none_ext4_locked_installation_prog,
&std::collections::HashMap::from([
("CHROOT_PATH".to_string(), "/media/pikaos/installation"),
(
"AUTO_LUKS_PASSWORD".to_string(),
partition_method_automatic_luks_refcell.borrow().replace("'", r###"'"'"'"###).as_str(),
)
]),
)
.unwrap());
} else {
final_script.push_str(&strfmt::strfmt(
auto_ext4::automatic_home_none_ext4_open_installation_prog,
&std::collections::HashMap::from([
("CHROOT_PATH".to_string(), "/media/pikaos/installation"),
]),
)
.unwrap());
}
}
_ => panic!()
}
}
"xfs" => {
match &*partition_method_automatic_seperation_refcell.borrow().as_str() {
"partition" => {
if is_encrypted {
final_script.push_str(&strfmt::strfmt(
auto_xfs::automatic_home_part_xfs_locked_installation_prog,
&std::collections::HashMap::from([
("CHROOT_PATH".to_string(), "/media/pikaos/installation"),
(
"AUTO_LUKS_PASSWORD".to_string(),
partition_method_automatic_luks_refcell.borrow().replace("'", r###"'"'"'"###).as_str(),
),
(
"ROOT_PART_SIZE_AS_I64_MIB".to_string(),
(partition_method_automatic_ratio_refcell.borrow().round() as i64 / 1048576).to_string().replace("'", r###"'"'"'"###).as_str(),
)
]),
)
.unwrap());
} else {
final_script.push_str(&strfmt::strfmt(
auto_xfs::automatic_home_part_xfs_open_installation_prog,
&std::collections::HashMap::from([
("CHROOT_PATH".to_string(), "/media/pikaos/installation"),
(
"ROOT_PART_SIZE_AS_I64_MIB".to_string(),
(partition_method_automatic_ratio_refcell.borrow().round() as i64 / 1048576).to_string().replace("'", r###"'"'"'"###).as_str(),
)
]),
)
.unwrap());
}
}
"none" => {
if is_encrypted {
final_script.push_str(&strfmt::strfmt(
auto_xfs::automatic_home_none_xfs_locked_installation_prog,
&std::collections::HashMap::from([
("CHROOT_PATH".to_string(), "/media/pikaos/installation"),
(
"AUTO_LUKS_PASSWORD".to_string(),
partition_method_automatic_luks_refcell.borrow().replace("'", r###"'"'"'"###).as_str(),
)
]),
)
.unwrap());
} else {
final_script.push_str(&strfmt::strfmt(
auto_xfs::automatic_home_none_xfs_open_installation_prog,
&std::collections::HashMap::from([
("CHROOT_PATH".to_string(), "/media/pikaos/installation"),
]),
)
.unwrap());
}
}
_ => panic!()
}
}
_ => panic!()
}
//
if is_encrypted {
final_script.push_str(auto_basic::automatic_locked_part_pikainstall_prog);
} else {
final_script.push_str(auto_basic::automatic_open_part_pikainstall_prog);
}
}
"manual" => {
let is_encrypted = *partition_method_manual_luks_enabled_refcell.borrow();
if is_encrypted {
final_script.push_str(
r###"
mkdir -p /tmp/PIKA_CRYPT/
touch /tmp/PIKA_CRYPT/crypttab
"###
installation_progress_log_stack.add_titled(
&placeholder_icon,
Some("slideshow_page"),
"slideshow_page",
);
installation_progress_log_stack.add_titled(
&installation_progress_log_terminal,
Some("terminal_log_page"),
"terminal_log_page",
);
for crypt_entry in partition_method_manual_crypttab_entry_array_refcell.borrow().iter() {
match &crypt_entry.password {
Some(p) => {
final_script.push_str(&strfmt::strfmt(
manual_basic::manual_crypt_entry_with_keyfile,
&std::collections::HashMap::from([
(
"MAP".to_string(),
crypt_entry.map.replace("'", r###"'"'"'"###).as_str()
),
(
"UUID".to_string(),
crypt_entry.uuid.replace("'", r###"'"'"'"###).as_str()
),
(
"LUKS_PASSWD".to_string(),
p.replace("'", r###"'"'"'"###).as_str()
)
]),
)
.unwrap());
}
None => {
final_script.push_str(&strfmt::strfmt(
manual_basic::manual_crypt_entry,
&std::collections::HashMap::from([
(
"MAP".to_string(),
crypt_entry.map.replace("'", r###"'"'"'"###).as_str()
),
(
"UUID".to_string(),
crypt_entry.uuid.replace("'", r###"'"'"'"###).as_str()
)
]),
)
.unwrap());
installation_progress_box.append(&installation_progress_log_stack);
installation_progress_box.append(&progress_bar_box);
//
progress_log_button.connect_clicked(
clone!(
#[weak]
installation_progress_log_stack,
move |_|
{
if installation_progress_log_stack.visible_child_name() == Some(GString::from_string_unchecked("slideshow_page".into())) {
installation_progress_log_stack.set_visible_child_name("terminal_log_page");
} else {
installation_progress_log_stack.set_visible_child_name("slideshow_page");
}
}
};
}
let mut did_make_swap_list = false;
for fstab_entry in partition_method_manual_fstab_entry_array_refcell.borrow().iter() {
if fstab_entry.mountpoint == "[SWAP]" {
if !did_make_swap_list {
final_script.push_str(
r###"
touch /tmp/pika-installer-gtk4-swaplist
"###
)
);
did_make_swap_list = true
}
final_script.push_str(&strfmt::strfmt(
manual_basic::manual_swap_mount_prog,
&std::collections::HashMap::from([
(
"PART".to_string(),
fstab_entry.partition.part_name.replace("'", r###"'"'"'"###).as_str()
),
]),
)
.unwrap());
} else if !fstab_entry.mountopts.is_empty() {
final_script.push_str(&strfmt::strfmt(
manual_basic::manual_partition_mount_with_opts_prog,
&std::collections::HashMap::from([
(
"PART".to_string(),
fstab_entry.partition.part_name.replace("'", r###"'"'"'"###).as_str()
),
(
"MOUNTPOINT".to_string(),
fstab_entry.mountpoint.replace("'", r###"'"'"'"###).as_str()
),
(
"OPTS".to_string(),
fstab_entry.mountopts.replace("'", r###"'"'"'"###).as_str()
),
]),
)
.unwrap());
} else {
final_script.push_str(&strfmt::strfmt(
manual_basic::manual_partition_mount_prog,
&std::collections::HashMap::from([
(
"PART".to_string(),
fstab_entry.partition.part_name.replace("'", r###"'"'"'"###).as_str()
),
(
"MOUNTPOINT".to_string(),
fstab_entry.mountpoint.replace("'", r###"'"'"'"###).as_str()
),
]),
)
.unwrap());
}
}
if is_encrypted {
final_script.push_str(manual_basic::manual_locked_part_pikainstall_prog);
} else {
final_script.push_str(manual_basic::manual_open_part_pikainstall_prog);
}
}
_ => panic!()
}
//
final_script
language_changed_action.connect_activate(clone!(
#[weak]
progress_log_button,
move |_, _| {
progress_log_button.set_tooltip_text(Some(&t!("progress_log_button_content_tooltip")));
}
));
main_carousel.append(&installation_progress_box);
}

View File

@ -9,6 +9,8 @@ use glib::{clone, closure_local};
use gtk::{gio, glib};
use std::{cell::RefCell, fs, ops::Deref, path::Path, process::Command, rc::Rc};
mod script_gen;
/// DEBUG
use std::io::{self, Write};
use duct::cmd;
@ -79,6 +81,8 @@ pub fn installation_summary_page(
//
install_confirm_button.connect_clicked(clone!(
#[weak]
main_carousel,
#[strong]
language_selection_text_refcell,
#[strong]
@ -108,7 +112,7 @@ pub fn installation_summary_page(
move |_|
{
std::io::stdout().flush().unwrap();
let cmd = installation_progress_page::create_installation_script(
let cmd = script_gen::create_installation_script(
&language_selection_text_refcell,
&keymap_selection_text_refcell,
&timezone_selection_text_refcell,
@ -126,7 +130,8 @@ pub fn installation_summary_page(
let big_cmd = cmd!("sudo", "bash", "-c",
cmd
);
assert!(big_cmd.run().is_ok());
//assert!(big_cmd.run().is_ok());
main_carousel.scroll_to(&main_carousel.nth_page(7), true);
}
)
);

View File

@ -0,0 +1,436 @@
use crate::{
build_ui::{BlockDevice, CrypttabEntry, FstabEntry, PikaKeymap, PikaLocale},
config::{MINIMUM_BOOT_BYTE_SIZE, MINIMUM_EFI_BYTE_SIZE},
installer_stack_page,
};
use adw::prelude::*;
use glib::{clone, closure_local};
use gtk::{gio, glib};
use std::{cell::RefCell, fs, ops::Deref, path::Path, process::Command, rc::Rc};
mod auto_basic;
mod auto_btrfs;
mod auto_ext4;
mod auto_xfs;
mod manual_basic;
pub const standard_installation_prog: &str = r###"#! /bin/bash
set -e
SOCKET_PATH="/tmp/pikainstall-status.sock"
rm -rf /tmp/pika-installer-gtk4-swaplist
rm -rf /tmp/PIKA_CRYPT
PIKA_INSTALL_CHROOT_PATH='{CHROOT_PATH}'
PIKA_INSTALL_LOCALE='{LOCALE}.UTF-8'
PIKA_INSTALL_KEYMAP_BASE='{KEYMAP_BASE}'
PIKA_INSTALL_KEYMAP_VARIANT='{KEYMAP_VARIANT}'
PIKA_INSTALL_TIMEZONE='{TIMEZONE}'
"###;
pub fn create_installation_script(
language_selection_text_refcell: &Rc<RefCell<PikaLocale>>,
keymap_selection_text_refcell: &Rc<RefCell<PikaKeymap>>,
timezone_selection_text_refcell: &Rc<RefCell<String>>,
partition_method_type_refcell: &Rc<RefCell<String>>,
partition_method_automatic_target_refcell: &Rc<RefCell<BlockDevice>>,
partition_method_automatic_target_fs_refcell: &Rc<RefCell<String>>,
partition_method_automatic_luks_enabled_refcell: &Rc<RefCell<bool>>,
partition_method_automatic_luks_refcell: &Rc<RefCell<String>>,
partition_method_automatic_ratio_refcell: &Rc<RefCell<f64>>,
partition_method_automatic_seperation_refcell: &Rc<RefCell<String>>,
partition_method_manual_fstab_entry_array_refcell: &Rc<RefCell<Vec<FstabEntry>>>,
partition_method_manual_luks_enabled_refcell: &Rc<RefCell<bool>>,
partition_method_manual_crypttab_entry_array_refcell: &Rc<RefCell<Vec<CrypttabEntry>>>,
) -> String {
let mut final_script = String::new();
let variant = match keymap_selection_text_refcell.borrow().clone().variant {
Some(t) => {
t.replace("'", r###"'"'"'"###)
}
None => "".to_string(),
};
let standard_installation_format = strfmt::strfmt(
standard_installation_prog,
&std::collections::HashMap::from([
("CHROOT_PATH".to_string(), "/media/pikaos/installation"),
(
"LOCALE".to_string(),
language_selection_text_refcell.borrow().name.replace("'", r###"'"'"'"###).as_str(),
),
(
"KEYMAP_BASE".to_string(),
keymap_selection_text_refcell.borrow().name.replace("'", r###"'"'"'"###).as_str(),
),
(
"KEYMAP_VARIANT".to_string(),
variant.as_str()
),
(
"TIMEZONE".to_string(),
timezone_selection_text_refcell.borrow().replace("'", r###"'"'"'"###).as_str(),
),
]),
)
.unwrap();
final_script.push_str(&standard_installation_format);
match &*partition_method_type_refcell.borrow().as_str() {
"automatic" => {
let is_encrypted = *partition_method_automatic_luks_enabled_refcell.borrow();
//
let automatic_standard_installation_format = strfmt::strfmt(
auto_basic::automatic_standard_installation_prog,
&std::collections::HashMap::from([
(
"AUTO_INSTALL_TARGET_DISK".to_string(),
partition_method_automatic_target_refcell.borrow().block_name.replace("'", r###"'"'"'"###).as_str(),
),
]),
)
.unwrap();
final_script.push_str(&automatic_standard_installation_format);
//
match &*partition_method_automatic_target_fs_refcell.borrow().as_str().to_lowercase() {
"btrfs" => {
match &*partition_method_automatic_seperation_refcell.borrow().as_str() {
"subvol" => {
if is_encrypted {
final_script.push_str(&strfmt::strfmt(
auto_btrfs::automatic_home_subvol_btrfs_locked_installation_prog,
&std::collections::HashMap::from([
("CHROOT_PATH".to_string(), "/media/pikaos/installation"),
(
"AUTO_LUKS_PASSWORD".to_string(),
partition_method_automatic_luks_refcell.borrow().replace("'", r###"'"'"'"###).as_str(),
)
]),
)
.unwrap());
} else {
final_script.push_str(&strfmt::strfmt(
auto_btrfs::automatic_home_subvol_btrfs_open_installation_prog,
&std::collections::HashMap::from([
("CHROOT_PATH".to_string(), "/media/pikaos/installation"),
]),
)
.unwrap());
}
}
"partition" => {
if is_encrypted {
final_script.push_str(&strfmt::strfmt(
auto_btrfs::automatic_home_part_btrfs_locked_installation_prog,
&std::collections::HashMap::from([
("CHROOT_PATH".to_string(), "/media/pikaos/installation"),
(
"AUTO_LUKS_PASSWORD".to_string(),
partition_method_automatic_luks_refcell.borrow().replace("'", r###"'"'"'"###).as_str(),
),
(
"ROOT_PART_SIZE_AS_I64_MIB".to_string(),
(partition_method_automatic_ratio_refcell.borrow().round() as i64 / 1048576).to_string().replace("'", r###"'"'"'"###).as_str(),
)
]),
)
.unwrap());
} else {
final_script.push_str(&strfmt::strfmt(
auto_btrfs::automatic_home_part_btrfs_open_installation_prog,
&std::collections::HashMap::from([
("CHROOT_PATH".to_string(), "/media/pikaos/installation"),
(
"ROOT_PART_SIZE_AS_I64_MIB".to_string(),
(partition_method_automatic_ratio_refcell.borrow().round() as i64 / 1048576).to_string().replace("'", r###"'"'"'"###).as_str(),
)
]),
)
.unwrap());
}
}
"none" => {
if is_encrypted {
final_script.push_str(&strfmt::strfmt(
auto_btrfs::automatic_home_none_btrfs_locked_installation_prog,
&std::collections::HashMap::from([
("CHROOT_PATH".to_string(), "/media/pikaos/installation"),
(
"AUTO_LUKS_PASSWORD".to_string(),
partition_method_automatic_luks_refcell.borrow().replace("'", r###"'"'"'"###).as_str(),
)
]),
)
.unwrap());
} else {
final_script.push_str(&strfmt::strfmt(
auto_btrfs::automatic_home_none_btrfs_open_installation_prog,
&std::collections::HashMap::from([
("CHROOT_PATH".to_string(), "/media/pikaos/installation"),
]),
)
.unwrap());
}
}
_ => panic!()
}
}
"ext4" => {
match &*partition_method_automatic_seperation_refcell.borrow().as_str() {
"partition" => {
if is_encrypted {
final_script.push_str(&strfmt::strfmt(
auto_ext4::automatic_home_part_ext4_locked_installation_prog,
&std::collections::HashMap::from([
("CHROOT_PATH".to_string(), "/media/pikaos/installation"),
(
"AUTO_LUKS_PASSWORD".to_string(),
partition_method_automatic_luks_refcell.borrow().replace("'", r###"'"'"'"###).as_str(),
),
(
"ROOT_PART_SIZE_AS_I64_MIB".to_string(),
(partition_method_automatic_ratio_refcell.borrow().round() as i64 / 1048576).to_string().replace("'", r###"'"'"'"###).as_str(),
)
]),
)
.unwrap());
} else {
final_script.push_str(&strfmt::strfmt(
auto_ext4::automatic_home_part_ext4_open_installation_prog,
&std::collections::HashMap::from([
("CHROOT_PATH".to_string(), "/media/pikaos/installation"),
(
"ROOT_PART_SIZE_AS_I64_MIB".to_string(),
(partition_method_automatic_ratio_refcell.borrow().round() as i64 / 1048576).to_string().replace("'", r###"'"'"'"###).as_str(),
)
]),
)
.unwrap());
}
}
"none" => {
if is_encrypted {
final_script.push_str(&strfmt::strfmt(
auto_ext4::automatic_home_none_ext4_locked_installation_prog,
&std::collections::HashMap::from([
("CHROOT_PATH".to_string(), "/media/pikaos/installation"),
(
"AUTO_LUKS_PASSWORD".to_string(),
partition_method_automatic_luks_refcell.borrow().replace("'", r###"'"'"'"###).as_str(),
)
]),
)
.unwrap());
} else {
final_script.push_str(&strfmt::strfmt(
auto_ext4::automatic_home_none_ext4_open_installation_prog,
&std::collections::HashMap::from([
("CHROOT_PATH".to_string(), "/media/pikaos/installation"),
]),
)
.unwrap());
}
}
_ => panic!()
}
}
"xfs" => {
match &*partition_method_automatic_seperation_refcell.borrow().as_str() {
"partition" => {
if is_encrypted {
final_script.push_str(&strfmt::strfmt(
auto_xfs::automatic_home_part_xfs_locked_installation_prog,
&std::collections::HashMap::from([
("CHROOT_PATH".to_string(), "/media/pikaos/installation"),
(
"AUTO_LUKS_PASSWORD".to_string(),
partition_method_automatic_luks_refcell.borrow().replace("'", r###"'"'"'"###).as_str(),
),
(
"ROOT_PART_SIZE_AS_I64_MIB".to_string(),
(partition_method_automatic_ratio_refcell.borrow().round() as i64 / 1048576).to_string().replace("'", r###"'"'"'"###).as_str(),
)
]),
)
.unwrap());
} else {
final_script.push_str(&strfmt::strfmt(
auto_xfs::automatic_home_part_xfs_open_installation_prog,
&std::collections::HashMap::from([
("CHROOT_PATH".to_string(), "/media/pikaos/installation"),
(
"ROOT_PART_SIZE_AS_I64_MIB".to_string(),
(partition_method_automatic_ratio_refcell.borrow().round() as i64 / 1048576).to_string().replace("'", r###"'"'"'"###).as_str(),
)
]),
)
.unwrap());
}
}
"none" => {
if is_encrypted {
final_script.push_str(&strfmt::strfmt(
auto_xfs::automatic_home_none_xfs_locked_installation_prog,
&std::collections::HashMap::from([
("CHROOT_PATH".to_string(), "/media/pikaos/installation"),
(
"AUTO_LUKS_PASSWORD".to_string(),
partition_method_automatic_luks_refcell.borrow().replace("'", r###"'"'"'"###).as_str(),
)
]),
)
.unwrap());
} else {
final_script.push_str(&strfmt::strfmt(
auto_xfs::automatic_home_none_xfs_open_installation_prog,
&std::collections::HashMap::from([
("CHROOT_PATH".to_string(), "/media/pikaos/installation"),
]),
)
.unwrap());
}
}
_ => panic!()
}
}
_ => panic!()
}
//
if is_encrypted {
final_script.push_str(auto_basic::automatic_locked_part_pikainstall_prog);
} else {
final_script.push_str(auto_basic::automatic_open_part_pikainstall_prog);
}
}
"manual" => {
let is_encrypted = *partition_method_manual_luks_enabled_refcell.borrow();
if is_encrypted {
final_script.push_str(
r###"
mkdir -p /tmp/PIKA_CRYPT/
touch /tmp/PIKA_CRYPT/crypttab
"###
);
for crypt_entry in partition_method_manual_crypttab_entry_array_refcell.borrow().iter() {
match &crypt_entry.password {
Some(p) => {
final_script.push_str(&strfmt::strfmt(
manual_basic::manual_crypt_entry_with_keyfile,
&std::collections::HashMap::from([
(
"MAP".to_string(),
crypt_entry.map.replace("'", r###"'"'"'"###).as_str()
),
(
"UUID".to_string(),
crypt_entry.uuid.replace("'", r###"'"'"'"###).as_str()
),
(
"LUKS_PASSWD".to_string(),
p.replace("'", r###"'"'"'"###).as_str()
)
]),
)
.unwrap());
}
None => {
final_script.push_str(&strfmt::strfmt(
manual_basic::manual_crypt_entry,
&std::collections::HashMap::from([
(
"MAP".to_string(),
crypt_entry.map.replace("'", r###"'"'"'"###).as_str()
),
(
"UUID".to_string(),
crypt_entry.uuid.replace("'", r###"'"'"'"###).as_str()
)
]),
)
.unwrap());
}
}
};
}
let mut did_make_swap_list = false;
for fstab_entry in partition_method_manual_fstab_entry_array_refcell.borrow().iter() {
if fstab_entry.mountpoint == "[SWAP]" {
if !did_make_swap_list {
final_script.push_str(
r###"
touch /tmp/pika-installer-gtk4-swaplist
"###
);
did_make_swap_list = true
}
final_script.push_str(&strfmt::strfmt(
manual_basic::manual_swap_mount_prog,
&std::collections::HashMap::from([
(
"PART".to_string(),
fstab_entry.partition.part_name.replace("'", r###"'"'"'"###).as_str()
),
]),
)
.unwrap());
} else if !fstab_entry.mountopts.is_empty() {
final_script.push_str(&strfmt::strfmt(
manual_basic::manual_partition_mount_with_opts_prog,
&std::collections::HashMap::from([
(
"PART".to_string(),
fstab_entry.partition.part_name.replace("'", r###"'"'"'"###).as_str()
),
(
"MOUNTPOINT".to_string(),
fstab_entry.mountpoint.replace("'", r###"'"'"'"###).as_str()
),
(
"OPTS".to_string(),
fstab_entry.mountopts.replace("'", r###"'"'"'"###).as_str()
),
]),
)
.unwrap());
} else {
final_script.push_str(&strfmt::strfmt(
manual_basic::manual_partition_mount_prog,
&std::collections::HashMap::from([
(
"PART".to_string(),
fstab_entry.partition.part_name.replace("'", r###"'"'"'"###).as_str()
),
(
"MOUNTPOINT".to_string(),
fstab_entry.mountpoint.replace("'", r###"'"'"'"###).as_str()
),
]),
)
.unwrap());
}
}
if is_encrypted {
final_script.push_str(manual_basic::manual_locked_part_pikainstall_prog);
} else {
final_script.push_str(manual_basic::manual_open_part_pikainstall_prog);
}
}
_ => panic!()
}
final_script
}

View File

@ -19,8 +19,8 @@ mod automatic_partitioning_page;
mod manual_partitioning_page;
mod partitioning_page;
//
mod installation_progress_page;
mod installation_summary_page;
mod installation_progress_page;
#[macro_use]
extern crate rust_i18n;

View File

@ -14,7 +14,7 @@
}
.small_fg_text {
font-size: 48px;
font-size: 18px;
}
.big_error_text {