RR: Fix manual partition table order and sorting

This commit is contained in:
Ward from fusion-voyager-3 2024-02-17 22:05:42 +03:00
parent 7b83565fe3
commit bb977c65c0
6 changed files with 77 additions and 28 deletions

View File

@ -8,9 +8,11 @@ TIMEZONE="$(cat "/tmp/pika-installer-gtk4-timezone.txt")"
touch "/tmp/pika-installer-gtk4-status-parting.txt" touch "/tmp/pika-installer-gtk4-status-parting.txt"
rm -rf /tmp/pika-installer-gtk4-swaplist || true
if ls /tmp/pika-installer-gtk4-target-manual-luks-p*.json if ls /tmp/pika-installer-gtk4-target-manual-luks-p*.json
then then
rm -rf /tmp/pika-installer-gtk4-crypttab rm -rf /tmp/pika-installer-gtk4-crypttab || true
touch /tmp/pika-installer-gtk4-crypttab touch /tmp/pika-installer-gtk4-crypttab
for cryptentry in /tmp/pika-installer-gtk4-target-manual-luks-p*.json; do for cryptentry in /tmp/pika-installer-gtk4-target-manual-luks-p*.json; do

2
debian/changelog vendored
View File

@ -1,4 +1,4 @@
pika-installer-gtk4 (1.0.0-100pika9) pikauwu; urgency=low pika-installer-gtk4 (1.0.0-100pika10) pikauwu; urgency=low
* First release * First release

View File

@ -37,6 +37,7 @@ pub fn install_page(
let mut _iter_count = 0; let mut _iter_count = 0;
_iter_count = 0; _iter_count = 0;
let mut unlocked_array: Vec<String> = Default::default(); let mut unlocked_array: Vec<String> = Default::default();
manual_drive_mount_array.borrow_mut().sort_by_key(|p| p.clone().mountpoint);
for partitions in manual_drive_mount_array.borrow_mut().iter() { for partitions in manual_drive_mount_array.borrow_mut().iter() {
let new_crypt = if partitions.mountpoint != "/" let new_crypt = if partitions.mountpoint != "/"
&& !unlocked_array.contains(&partitions.partition) && !unlocked_array.contains(&partitions.partition)

View File

@ -7,7 +7,7 @@ use glib::*;
use gtk::*; use gtk::*;
use std::thread; use std::thread;
use std::cell::{RefCell, RefMut}; use std::cell::{RefCell};
use std::rc::Rc; use std::rc::Rc;
@ -223,6 +223,12 @@ pub fn manual_partitioning(
.build(); .build();
partition_refresh_button.add_css_class("destructive-action"); partition_refresh_button.add_css_class("destructive-action");
let fstab_valid_check = gtk::Button::builder()
.label("Validate Filesystem Table")
.halign(gtk::Align::Start)
.build();
fstab_valid_check.add_css_class("valid-action");
let drive_mount_add_button = gtk::Button::builder() let drive_mount_add_button = gtk::Button::builder()
.icon_name("list-add") .icon_name("list-add")
.vexpand(true) .vexpand(true)
@ -237,6 +243,15 @@ pub fn manual_partitioning(
.build(); .build();
partition_method_manual_error_label.add_css_class("small_error_text"); partition_method_manual_error_label.add_css_class("small_error_text");
let partition_method_manual_valid_label = gtk::Label::builder()
.halign(Align::Start)
.valign(Align::End)
.vexpand(true)
.visible(false)
.label("Filesystem Table is valid!")
.build();
partition_method_manual_valid_label.add_css_class("small_valid_text");
let partition_method_manual_warn_label = gtk::Label::builder() let partition_method_manual_warn_label = gtk::Label::builder()
.halign(Align::Start) .halign(Align::Start)
.valign(Align::End) .valign(Align::End)
@ -258,9 +273,15 @@ pub fn manual_partitioning(
partition_method_manual_main_box.append(&partition_method_manual_gparted_button); partition_method_manual_main_box.append(&partition_method_manual_gparted_button);
drive_mounts_adw_listbox.append(&drive_mount_add_button); drive_mounts_adw_listbox.append(&drive_mount_add_button);
partition_method_manual_main_box.append(&drive_mounts_viewport); partition_method_manual_main_box.append(&drive_mounts_viewport);
partition_method_manual_main_box.append(&fstab_valid_check);
partition_method_manual_main_box.append(&partition_method_manual_error_label); partition_method_manual_main_box.append(&partition_method_manual_error_label);
partition_method_manual_main_box.append(&partition_method_manual_valid_label);
partition_method_manual_main_box.append(&partition_method_manual_warn_label); partition_method_manual_main_box.append(&partition_method_manual_warn_label);
fstab_valid_check.connect_clicked(clone!(@weak partition_method_manual_error_label, @weak partition_method_manual_valid_label, @strong manual_drive_mount_array, @strong check_part_unique => move |_| {
partition_err_check(&partition_method_manual_error_label, &partition_method_manual_valid_label, &manual_drive_mount_array);
}));
partition_refresh_button.connect_clicked(clone!(@weak drive_mounts_adw_listbox,@strong part_table_array, @strong manual_drive_mount_array => move |_| { partition_refresh_button.connect_clicked(clone!(@weak drive_mounts_adw_listbox,@strong part_table_array, @strong manual_drive_mount_array => move |_| {
while let Some(row) = drive_mounts_adw_listbox.last_child() { while let Some(row) = drive_mounts_adw_listbox.last_child() {
if row.widget_name() == "DriveMountRow" { if row.widget_name() == "DriveMountRow" {
@ -353,9 +374,28 @@ pub fn manual_partitioning(
counter = row.next_sibling(); counter = row.next_sibling();
} }
let manual_drive_mount_array_ref_clone = manual_drive_mount_array_ref.clone(); let manual_drive_mount_array_ref_clone = manual_drive_mount_array_ref.clone();
partition_err_check(&partition_method_manual_warn_label, &partition_method_manual_error_label, manual_drive_mount_array_ref, &check_part_unique);
*check_part_unique.borrow_mut() = true;
for mountopts in manual_drive_mount_array_ref
.iter()
.map(|x| x.mountopt.as_str())
.collect::<HashSet<&str>>()
{
if mountopts.contains("subvol") {
*check_part_unique.borrow_mut() = false
}
}
if *check_part_unique.borrow_mut() == false {
partition_method_manual_warn_label
.set_label("Partition reuse check will be skipped due to subvol usage.");
partition_method_manual_warn_label.set_visible(true);
} else {
partition_method_manual_warn_label.set_visible(false);
}
if partitioning_stack.visible_child_name() == Some(GString::from_string_unchecked("partition_method_manual_page".into())) { if partitioning_stack.visible_child_name() == Some(GString::from_string_unchecked("partition_method_manual_page".into())) {
if manual_drive_mount_array_ref_clone.iter().any(|x| {if x.mountpoint == "/" {return true} else {return false}}) && manual_drive_mount_array_ref_clone.iter().any(|x| {if x.mountpoint == "/boot" {return true} else {return false}}) && manual_drive_mount_array_ref_clone.iter().any(|x| {if x.mountpoint == "/boot/efi" {return true} else {return false}}) && !partition_method_manual_error_label.is_visible() { if manual_drive_mount_array_ref_clone.iter().any(|x| {if x.mountpoint == "/" {return true} else {return false}}) && manual_drive_mount_array_ref_clone.iter().any(|x| {if x.mountpoint == "/boot" {return true} else {return false}}) && manual_drive_mount_array_ref_clone.iter().any(|x| {if x.mountpoint == "/boot/efi" {return true} else {return false}}) && !partition_method_manual_error_label.is_visible() && partition_method_manual_valid_label.is_visible() {
if !bottom_next_button.is_sensitive() { if !bottom_next_button.is_sensitive() {
bottom_next_button.set_sensitive(true); bottom_next_button.set_sensitive(true);
} }
@ -378,12 +418,12 @@ pub fn manual_partitioning(
} }
fn partition_err_check( fn partition_err_check(
partition_method_manual_warn_label: &gtk::Label,
partition_method_manual_error_label: &gtk::Label, partition_method_manual_error_label: &gtk::Label,
manual_drive_mount_array_ref: RefMut<'_, Vec<DriveMount>>, partition_method_manual_valid_label: &gtk::Label,
check_part_unique: &Rc<RefCell<bool>>, manual_drive_mount_array: &Rc<RefCell<Vec<DriveMount>>>,
) { ) {
let mut empty_mountpoint = false; let mut empty_mountpoint = false;
let manual_drive_mount_array_ref = manual_drive_mount_array.borrow_mut();
for mountpoint in manual_drive_mount_array_ref for mountpoint in manual_drive_mount_array_ref
.iter() .iter()
.map(|x| x.mountpoint.as_str()) .map(|x| x.mountpoint.as_str())
@ -456,17 +496,6 @@ fn partition_err_check(
} }
} }
*check_part_unique.borrow_mut() = true;
for mountopts in manual_drive_mount_array_ref
.iter()
.map(|x| x.mountopt.as_str())
.collect::<HashSet<&str>>()
{
if mountopts.contains("subvol") {
*check_part_unique.borrow_mut() = false
}
}
for drivemounts in manual_drive_mount_array_ref for drivemounts in manual_drive_mount_array_ref
.iter() .iter()
.map(|x| x) .map(|x| x)
@ -680,14 +709,11 @@ fn partition_err_check(
partition_method_manual_error_label.set_visible(false); partition_method_manual_error_label.set_visible(false);
} }
} }
if !partition_method_manual_error_label.is_visible() {
partition_method_manual_valid_label.set_visible(true)
} else {
partition_method_manual_valid_label.set_visible(false)
}
} }
} }
if *check_part_unique.borrow_mut() == false {
partition_method_manual_warn_label
.set_label("Partition reuse check will be skipped due to subvol usage.");
partition_method_manual_warn_label.set_visible(true);
} else {
partition_method_manual_warn_label.set_visible(false);
}
} }

View File

@ -261,6 +261,16 @@ pub fn partitioning_page(
if Path::new("/tmp/pika-installer-gtk4-target-manual-luks.txt").exists() { if Path::new("/tmp/pika-installer-gtk4-target-manual-luks.txt").exists() {
fs::remove_file("/tmp/pika-installer-gtk4-target-manual-luks.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-target-manual.txt"); fs::remove_file("/tmp/pika-installer-gtk4-target-manual-luks.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-target-manual.txt");
} }
if Path::new("/tmp/pika-installer-gtk4-fail.txt").exists() {
fs::remove_file("/tmp/pika-installer-gtk4-fail.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-fail.txt");
}
if Path::new("/tmp/pika-installer-gtk4-successful.txt").exists() {
fs::remove_file("/tmp/pika-installer-gtk4-successful.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-successful.txt");
}
for status_file in glob("/tmp/pika-installer-gtk4-status*").expect("Failed to read glob pattern") {
let status_file = status_file.unwrap();
fs::remove_file(&status_file).expect(&status_file.to_str().unwrap());
}
for partition_file in glob("/tmp/pika-installer-gtk4-target-manual-p*").expect("Failed to read glob pattern") { for partition_file in glob("/tmp/pika-installer-gtk4-target-manual-p*").expect("Failed to read glob pattern") {
let partition_file = partition_file.unwrap(); let partition_file = partition_file.unwrap();
fs::remove_file(&partition_file).expect(&partition_file.to_str().unwrap()); fs::remove_file(&partition_file).expect(&partition_file.to_str().unwrap());

View File

@ -8,6 +8,11 @@
color: orange; color: orange;
} }
.small_valid_text {
font-size: 14px;
color: green;
}
.big_error_text { .big_error_text {
font-size: 32px; font-size: 32px;
color: red; color: red;
@ -19,4 +24,9 @@
.medium_sized_text { .medium_sized_text {
font-size: 18px; font-size: 18px;
} }
.valid-action {
background-color:green;
color: white;
}