begin making conditional progs

This commit is contained in:
Ward from fusion-voyager-3 2024-08-23 22:53:14 +03:00
parent 4b6ac18be9
commit 3f7473e90e
4 changed files with 91 additions and 28 deletions

View File

@ -60,7 +60,7 @@ fi
pub const automatic_home_subvol_btrfs_locked_installation_prog: &str = r###"
PIKA_INSTALL_AUTO_LUKS_PASSWORD={AUTO_LUKS_PASSWORD}
PIKA_INSTALL_AUTO_LUKS_PASSWORD='{AUTO_LUKS_PASSWORD}'
parted -s -a optimal /dev/"$PIKA_INSTALL_AUTO_TARGET_DISK" mklabel gpt \
mkpart "linux-efi" 1MiB 500Mib \
@ -199,7 +199,7 @@ fi
pub const automatic_home_part_btrfs_locked_installation_prog: &str = r###"
PIKA_INSTALL_AUTO_LUKS_PASSWORD={AUTO_LUKS_PASSWORD}
PIKA_INSTALL_AUTO_LUKS_PASSWORD='{AUTO_LUKS_PASSWORD}'
PIKA_INSTALL_AUTO_ROOT_SIZE={ROOT_PART_SIZE_AS_I64_MIB}
parted -s -a optimal /dev/"$PIKA_INSTALL_AUTO_TARGET_DISK" mklabel gpt \
@ -335,7 +335,7 @@ fi
pub const automatic_home_none_btrfs_locked_installation_prog: &str = r###"
PIKA_INSTALL_AUTO_LUKS_PASSWORD={AUTO_LUKS_PASSWORD}
PIKA_INSTALL_AUTO_LUKS_PASSWORD='{AUTO_LUKS_PASSWORD}'
parted -s -a optimal /dev/"$PIKA_INSTALL_AUTO_TARGET_DISK" mklabel gpt \
mkpart "linux-efi" 1MiB 500Mib \

View File

@ -56,7 +56,7 @@ fi
pub const automatic_home_part_ext4_locked_installation_prog: &str = r###"
PIKA_INSTALL_AUTO_LUKS_PASSWORD={AUTO_LUKS_PASSWORD}
PIKA_INSTALL_AUTO_LUKS_PASSWORD='{AUTO_LUKS_PASSWORD}'
PIKA_INSTALL_AUTO_ROOT_SIZE={ROOT_PART_SIZE_AS_I64_MIB}
parted -s -a optimal /dev/"$PIKA_INSTALL_AUTO_TARGET_DISK" mklabel gpt \
@ -168,7 +168,7 @@ fi
pub const automatic_home_none_ext4_locked_installation_prog: &str = r###"
PIKA_INSTALL_AUTO_LUKS_PASSWORD={AUTO_LUKS_PASSWORD}
PIKA_INSTALL_AUTO_LUKS_PASSWORD='{AUTO_LUKS_PASSWORD}'
parted -s -a optimal /dev/"$PIKA_INSTALL_AUTO_TARGET_DISK" mklabel gpt \
mkpart "linux-efi" 1MiB 500Mib \

View File

@ -57,7 +57,7 @@ fi
pub const automatic_home_part_xfs_locked_installation_prog: &str = r###"
PIKA_INSTALL_AUTO_LUKS_PASSWORD={AUTO_LUKS_PASSWORD}
PIKA_INSTALL_AUTO_LUKS_PASSWORD='{AUTO_LUKS_PASSWORD}'
PIKA_INSTALL_AUTO_ROOT_SIZE={ROOT_PART_SIZE_AS_I64_MIB}
parted -s -a optimal /dev/"$PIKA_INSTALL_AUTO_TARGET_DISK" mklabel gpt \
@ -169,7 +169,7 @@ fi
pub const automatic_home_none_xfs_locked_installation_prog: &str = r###"
PIKA_INSTALL_AUTO_LUKS_PASSWORD={AUTO_LUKS_PASSWORD}
PIKA_INSTALL_AUTO_LUKS_PASSWORD='{AUTO_LUKS_PASSWORD}'
parted -s -a optimal /dev/"$PIKA_INSTALL_AUTO_TARGET_DISK" mklabel gpt \
mkpart "linux-efi" 1MiB 500Mib \

View File

@ -8,16 +8,19 @@ 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;
pub const standard_installation_prog: &str = r###"#! /bin/bash
set -e
SOCKET_PATH="/tmp/pikainstall-status.sock"
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}
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(
@ -35,7 +38,9 @@ pub fn create_installation_script(
partition_method_manual_luks_enabled_refcell: &Rc<RefCell<bool>>,
partition_method_manual_crypttab_entry_array_refcell: &Rc<RefCell<Vec<CrypttabEntry>>>,
) {
let script = strfmt::strfmt(
let mut final_script = String::new();
let standard_installation_format = strfmt::strfmt(
standard_installation_prog,
&std::collections::HashMap::from([
("CHROOT_PATH".to_string(), "/media/pikaos/installation"),
@ -54,25 +59,83 @@ pub fn create_installation_script(
None => "",
},
),
]),
)
.unwrap();
let script2 = strfmt::strfmt(
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().as_str(),
),
(
"ROOT_PART_SIZE_AS_I64_MIB".to_string(),
(partition_method_automatic_ratio_refcell.borrow().round() as i64 / 1048576).to_string().as_str(),
"TIMEZONE".to_string(),
timezone_selection_text_refcell.borrow().as_str(),
),
]),
)
.unwrap();
println!("{}", script2)
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.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().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" => {}
"none" => {}
_ => panic!()
}
}
"ext4" => {
}
"xfs" => {
}
_ => 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" => {}
_ => panic!()
}
println!("{}", final_script)
}