Skip to content
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.

Commit

Permalink
feat(disks): support install system to logical partition
Browse files Browse the repository at this point in the history
  • Loading branch information
eatradish committed Jan 10, 2024
1 parent f96f5b8 commit d8d06d4
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 40 deletions.
35 changes: 0 additions & 35 deletions src/disks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ const EFI_DETECT_PATH: &str = "/sys/firmware/efi";
pub const ALLOWED_FS_TYPE: &[&str] = &["ext4", "xfs"];
const DEFAULT_FS_TYPE: &str = "ext4";

const MBR_NON_PRIMARY_PART_ERROR: &str = r#"Installer has detected that you are attempting to install AOSC OS on an MBR extended partition. This is not allowed as it may cause startup issues.
Please select a primary partition instead."#;
const SUPPORT_PARTITION_TYPE: &[&str] = &["primary", "logical"];

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand Down Expand Up @@ -282,38 +279,6 @@ fn get_partition_table_type(device_path: Option<&Path>) -> Result<String> {
))
}

pub fn mbr_is_primary_partition(
device_path: Option<&Path>,
part_path: Option<&Path>,
) -> Result<()> {
let partition_t = get_partition_table_type(device_path)?;

if partition_t != "msdos" {
return Ok(());
}

for mut device in libparted::Device::devices(true) {
if let Ok(disk) = libparted::Disk::new(&mut device) {
let mut parts = disk.parts();
let part = parts
.find(|x| x.get_path() == part_path)
.ok_or_else(|| anyhow!("Can not find select partition!"))?;

let part_type = part.type_get_name();

info!("part_type: {}", part_type);

if part_type != "primary" {
return Err(anyhow!(MBR_NON_PRIMARY_PART_ERROR));
} else {
return Ok(());
}
}
}

Ok(())
}

#[cfg(not(target_arch = "powerpc64"))]
pub fn right_combine(device_path: Option<&Path>) -> Result<()> {
let partition_table_t = get_partition_table_type(device_path)?;
Expand Down
6 changes: 1 addition & 5 deletions src/frontend/tui.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
disks::{
self, auto_create_partitions, device_is_empty, is_efi_booted, mbr_is_primary_partition,
self, auto_create_partitions, device_is_empty, is_efi_booted,
DkDerive, ALLOWED_FS_TYPE,
},
install::{self, find_language_by_locale, find_locale_by_language, read_locale, umount_all},
Expand Down Expand Up @@ -546,10 +546,6 @@ fn select_partition(siv: &mut Cursive, config: InstallConfig, dev: Rc<DkDerive>)
let config_copy_2 = config.clone();
let fs_type = current_partition.fs_type.clone();
let current_partition_clone = current_partition.clone();
if let Err(e) = mbr_is_primary_partition(current_partition.parent_path.as_deref(), current_partition.path.as_deref()) {
show_msg(s, &e.to_string());
return;
}

if let Err(e) = disks::right_combine(current_partition.parent_path.as_deref()) {
let view = wrap_in_dialog(LinearLayout::vertical()
Expand Down

0 comments on commit d8d06d4

Please sign in to comment.