From bb977c65c07ce7aa42065da032030dde4ac41016 Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Sat, 17 Feb 2024 22:05:42 +0300 Subject: [PATCH] RR: Fix manual partition table order and sorting --- data/scripts/manual-partition-install.sh | 4 +- debian/changelog | 2 +- src/install_page/mod.rs | 1 + src/manual_partitioning/mod.rs | 76 ++++++++++++++++-------- src/partitioning_page/mod.rs | 10 ++++ src/style.css | 12 +++- 6 files changed, 77 insertions(+), 28 deletions(-) diff --git a/data/scripts/manual-partition-install.sh b/data/scripts/manual-partition-install.sh index fbe7153..71c89c6 100644 --- a/data/scripts/manual-partition-install.sh +++ b/data/scripts/manual-partition-install.sh @@ -8,9 +8,11 @@ TIMEZONE="$(cat "/tmp/pika-installer-gtk4-timezone.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 then - rm -rf /tmp/pika-installer-gtk4-crypttab + rm -rf /tmp/pika-installer-gtk4-crypttab || true touch /tmp/pika-installer-gtk4-crypttab for cryptentry in /tmp/pika-installer-gtk4-target-manual-luks-p*.json; do diff --git a/debian/changelog b/debian/changelog index 32f26a0..9b182e7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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 diff --git a/src/install_page/mod.rs b/src/install_page/mod.rs index 3bb94ec..d93ac7d 100644 --- a/src/install_page/mod.rs +++ b/src/install_page/mod.rs @@ -37,6 +37,7 @@ pub fn install_page( let mut _iter_count = 0; _iter_count = 0; let mut unlocked_array: Vec = 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() { let new_crypt = if partitions.mountpoint != "/" && !unlocked_array.contains(&partitions.partition) diff --git a/src/manual_partitioning/mod.rs b/src/manual_partitioning/mod.rs index ec46dda..51e8130 100644 --- a/src/manual_partitioning/mod.rs +++ b/src/manual_partitioning/mod.rs @@ -7,7 +7,7 @@ use glib::*; use gtk::*; use std::thread; -use std::cell::{RefCell, RefMut}; +use std::cell::{RefCell}; use std::rc::Rc; @@ -223,6 +223,12 @@ pub fn manual_partitioning( .build(); 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() .icon_name("list-add") .vexpand(true) @@ -237,6 +243,15 @@ pub fn manual_partitioning( .build(); 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() .halign(Align::Start) .valign(Align::End) @@ -258,9 +273,15 @@ pub fn manual_partitioning( partition_method_manual_main_box.append(&partition_method_manual_gparted_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(&fstab_valid_check); 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); + 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 |_| { while let Some(row) = drive_mounts_adw_listbox.last_child() { if row.widget_name() == "DriveMountRow" { @@ -353,9 +374,28 @@ pub fn manual_partitioning( counter = row.next_sibling(); } 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::>() + { + 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 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() { bottom_next_button.set_sensitive(true); } @@ -378,12 +418,12 @@ pub fn manual_partitioning( } fn partition_err_check( - partition_method_manual_warn_label: >k::Label, partition_method_manual_error_label: >k::Label, - manual_drive_mount_array_ref: RefMut<'_, Vec>, - check_part_unique: &Rc>, + partition_method_manual_valid_label: >k::Label, + manual_drive_mount_array: &Rc>>, ) { 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 .iter() .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::>() - { - if mountopts.contains("subvol") { - *check_part_unique.borrow_mut() = false - } - } - for drivemounts in manual_drive_mount_array_ref .iter() .map(|x| x) @@ -680,14 +709,11 @@ fn partition_err_check( 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); - } } diff --git a/src/partitioning_page/mod.rs b/src/partitioning_page/mod.rs index 56c2679..2eb124b 100644 --- a/src/partitioning_page/mod.rs +++ b/src/partitioning_page/mod.rs @@ -261,6 +261,16 @@ pub fn partitioning_page( 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"); } + 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") { let partition_file = partition_file.unwrap(); fs::remove_file(&partition_file).expect(&partition_file.to_str().unwrap()); diff --git a/src/style.css b/src/style.css index 763254a..003ccce 100644 --- a/src/style.css +++ b/src/style.css @@ -8,6 +8,11 @@ color: orange; } +.small_valid_text { + font-size: 14px; + color: green; +} + .big_error_text { font-size: 32px; color: red; @@ -19,4 +24,9 @@ .medium_sized_text { font-size: 18px; -} \ No newline at end of file +} + +.valid-action { + background-color:green; + color: white; +}