Rework partitioning functions

axtloss/rework-partitioning
axtloss 2 years ago
parent b7b1d38cc8
commit 8cd714f537
No known key found for this signature in database
GPG Key ID: DD6D66939396C90E

@ -64,10 +64,6 @@ pub enum Command {
#[clap(name = "flatpak")]
Flatpak,
/// Setup Unakite
#[clap(name = "unakite")]
Unakite(UnakiteArgs),
/// Read Jade installation config
#[clap(name = "config")]
Config {
@ -99,9 +95,6 @@ pub struct PartitionArgs {
#[clap(long)]
pub efi: bool,
#[clap(long)]
pub unakite: bool,
/// The partitions to use for manual partitioning
#[clap(required_if_eq("mode", "Partition::Manual"), parse(try_from_str = parse_partitions))]
pub partitions: Vec<Partition>,
@ -113,25 +106,6 @@ pub struct InstallBaseArgs {
pub kernel: String,
}
#[derive(Debug, Args)]
pub struct UnakiteArgs {
/// Root device of Unakite
#[clap(long)]
pub root: String,
/// Root device of Crystal
#[clap(long)]
pub oldroot: String,
/// Whether the system is an EFI system
#[clap(long)]
pub efi: bool,
/// Boot directory (if not EFI), or EFI directory
#[clap(long)]
pub efidir: String,
/// Blockdev of boot device
#[clap(long)]
pub bootdev: String,
}
#[derive(Debug)]
pub struct Partition {
pub mountpoint: String,

@ -3,5 +3,4 @@ pub mod desktops;
pub mod locale;
pub mod network;
pub mod partition;
pub mod unakite;
pub mod users;

@ -1,6 +1,7 @@
use crate::args;
use crate::args::PartitionMode;
use crate::internal::exec::*;
use crate::internal::files::create_directory;
use crate::internal::*;
use std::path::{Path, PathBuf};
@ -88,7 +89,6 @@ pub fn partition(
mode: PartitionMode,
efi: bool,
partitions: &mut Vec<args::Partition>,
unakite: bool,
) {
println!("{:?}", mode);
match mode {
@ -97,18 +97,23 @@ pub fn partition(
crash(format!("The device {device:?} doesn't exist"), 1);
}
log::debug!("automatically partitioning {device:?}");
if efi {
partition_with_efi(&device, unakite);
} else {
partition_no_efi(&device, unakite);
}
if device.to_string_lossy().contains("nvme")
create_partitions(&device, efi);
let part1: String; // This is probably a horrible way of doing this, but the borrow checker is annoying
let part2: String;
let partitions: Vec<&str> = if device.to_string_lossy().contains("nvme")
|| device.to_string_lossy().contains("mmcblk")
{
part_nvme(&device, efi, unakite);
part1 = format!("{}p1", device.to_string_lossy());
part2 = format!("{}p2", device.to_string_lossy());
vec![part1.as_str(), part2.as_str()]
} else {
part_disk(&device, efi, unakite);
}
part1 = format!("{}1", device.to_string_lossy());
part2 = format!("{}2", device.to_string_lossy());
vec![part1.as_str(), part2.as_str()]
};
auto_format(partitions);
mount_disks(efi);
}
PartitionMode::Manual => {
log::debug!("Manual partitioning");
@ -129,86 +134,7 @@ pub fn partition(
}
}
fn partition_no_efi(device: &Path, unakite: bool) {
let device = device.to_string_lossy().to_string();
exec_eval(
exec(
"parted",
vec![
String::from("-s"),
String::from(&device),
String::from("mklabel"),
String::from("msdos"),
],
),
format!("Create msdos label on {}", device).as_str(),
);
exec_eval(
exec(
"parted",
vec![
String::from("-s"),
String::from(&device),
String::from("mkpart"),
String::from("primary"),
String::from("ext4"),
String::from("1MIB"),
String::from("512MIB"),
],
),
"create bios boot partition",
);
if unakite {
exec_eval(
exec(
"parted",
vec![
String::from("-s"),
String::from(&device),
String::from("mkpart"),
String::from("primary"),
String::from("btrfs"),
String::from("512MIB"),
String::from("10048MIB"),
],
),
"create btrfs Unakite root partition",
);
exec_eval(
exec(
"parted",
vec![
String::from("-s"),
device,
String::from("mkpart"),
String::from("primary"),
String::from("btrfs"),
String::from("10048MIB"),
String::from("100%"),
],
),
"create btrfs Crystal root partition",
);
} else {
exec_eval(
exec(
"parted",
vec![
String::from("-s"),
device,
String::from("mkpart"),
String::from("primary"),
String::from("btrfs"),
String::from("512MIB"),
String::from("100%"),
],
),
"create btrfs root partition",
);
}
}
fn partition_with_efi(device: &Path, unakite: bool) {
fn create_partitions(device: &Path, efi: bool) {
let device = device.to_string_lossy().to_string();
exec_eval(
exec(
@ -217,11 +143,17 @@ fn partition_with_efi(device: &Path, unakite: bool) {
String::from("-s"),
String::from(&device),
String::from("mklabel"),
String::from("gpt"),
String::from(if efi { "gpt" } else { "msdos" }),
],
),
format!("create gpt label on {}", &device).as_str(),
format!(
"Create {} label on {}",
if efi { "gpt" } else { "msdos" },
device
)
.as_str(),
);
if efi {
exec_eval(
exec(
"parted",
@ -236,7 +168,7 @@ fn partition_with_efi(device: &Path, unakite: bool) {
),
"create EFI partition",
);
if unakite {
} else {
exec_eval(
exec(
"parted",
@ -245,29 +177,14 @@ fn partition_with_efi(device: &Path, unakite: bool) {
String::from(&device),
String::from("mkpart"),
String::from("primary"),
String::from("btrfs"),
String::from("ext4"),
String::from("1MIB"),
String::from("512MIB"),
String::from("10048MIB"),
],
),
"create btrfs Unakite root partition",
);
exec_eval(
exec(
"parted",
vec![
String::from("-s"),
device,
String::from("mkpart"),
String::from("primary"),
String::from("btrfs"),
String::from("10048MIB"),
String::from("100%"),
],
),
"create btrfs Crystal root partition",
"create bios boot partition",
);
} else {
}
exec_eval(
exec(
"parted",
@ -284,382 +201,36 @@ fn partition_with_efi(device: &Path, unakite: bool) {
"create btrfs root partition",
);
}
}
fn part_nvme(device: &Path, efi: bool, unakite: bool) {
let device = device.to_string_lossy().to_string();
if efi && !unakite {
exec_eval(
exec(
"mkfs.vfat",
vec![String::from("-F32"), format!("{}p1", device)],
),
format!("format {}p1 as fat32", device).as_str(),
);
exec_eval(
exec(
"mkfs.btrfs",
vec!["-f".to_string(), format!("{}p2", device)],
),
format!("format {}p2 as btrfs", device).as_str(),
);
mount(format!("{}p2", device).as_str(), "/mnt", "");
exec_eval(
exec_workdir(
"btrfs",
"/mnt",
vec![
String::from("subvolume"),
String::from("create"),
String::from("@"),
],
),
"Create btrfs subvolume @",
);
exec_eval(
exec_workdir(
"btrfs",
"/mnt",
vec![
String::from("subvolume"),
String::from("create"),
String::from("@home"),
],
),
"Create btrfs subvolume @home",
);
umount("/mnt");
mount(format!("{}p2", device).as_str(), "/mnt/", "subvol=@");
files_eval(files::create_directory("/mnt/boot"), "create /mnt/boot");
files_eval(
files::create_directory("/mnt/boot/efi"),
"create /mnt/boot/efi",
);
files_eval(files::create_directory("/mnt/home"), "create /mnt/home");
mount(
format!("{}p2", device).as_str(),
"/mnt/home",
"subvol=@home",
);
mount(format!("{}p1", device).as_str(), "/mnt/boot/efi", "");
} else if !efi && !unakite {
exec_eval(
exec("mkfs.ext4", vec![format!("{}p1", device)]),
format!("format {}p1 as ext4", device).as_str(),
);
exec_eval(
exec(
"mkfs.btrfs",
vec!["-f".to_string(), format!("{}p2", device)],
),
format!("format {}p2 as btrfs", device).as_str(),
);
mount(format!("{}p2", device).as_str(), "/mnt/", "");
exec_eval(
exec_workdir(
"btrfs",
"/mnt",
vec![
String::from("subvolume"),
String::from("create"),
String::from("@"),
],
),
"Create btrfs subvolume @",
);
exec_eval(
exec_workdir(
"btrfs",
"/mnt",
vec![
String::from("subvolume"),
String::from("create"),
String::from("@home"),
],
),
"Create btrfs subvolume @home",
);
umount("/mnt");
mount(format!("{}p2", device).as_str(), "/mnt/", "subvol=@");
files_eval(files::create_directory("/mnt/boot"), "create /mnt/boot");
files_eval(files::create_directory("/mnt/home"), "create /mnt/home");
mount(
format!("{}p2", device).as_str(),
"/mnt/home",
"subvol=@home",
);
mount(format!("{}p1", device).as_str(), "/mnt/boot", "");
} else if efi && unakite {
fn auto_format(partitions: Vec<&str>) {
exec_eval(
exec(
"mkfs.vfat",
vec![String::from("-F32"), format!("{}p1", device)],
),
format!("format {}p1 as fat32", device).as_str(),
);
exec_eval(
exec(
"mkfs.btrfs",
vec!["-f".to_string(), format!("{}p2", device)],
),
format!("format {}p2 as btrfs", device).as_str(),
);
exec_eval(
exec(
"mkfs.btrfs",
vec!["-f".to_string(), format!("{}p3", device)],
),
format!("format {}p3 as btrfs", device).as_str(),
);
mount(format!("{}p3", device).as_str(), "/mnt", "");
exec_eval(
exec_workdir(
"btrfs",
"/mnt",
vec![
String::from("subvolume"),
String::from("create"),
String::from("@"),
],
),
"Create btrfs subvolume @",
);
exec_eval(
exec_workdir(
"btrfs",
"/mnt",
vec![
String::from("subvolume"),
String::from("create"),
String::from("@home"),
"-F32".to_string(),
"-n".to_string(),
"CYRSTAL_EFI".to_string(),
partitions[0].to_string(),
],
),
"Create btrfs subvolume @home",
);
umount("/mnt");
mount(format!("{}p3", device).as_str(), "/mnt/", "subvol=@");
files_eval(files::create_directory("/mnt/boot"), "create /mnt/boot");
files_eval(
files::create_directory("/mnt/boot/efi"),
"create /mnt/boot/efi",
);
files_eval(files::create_directory("/mnt/home"), "create /mnt/home");
mount(
format!("{}p3", device).as_str(),
"/mnt/home",
"subvol=@home",
);
mount(format!("{}p1", device).as_str(), "/mnt/boot/efi", "");
} else if !efi && unakite {
exec_eval(
exec("mkfs.ext4", vec![format!("{}p1", device)]),
format!("format {}p1 as ext4", device).as_str(),
format!("format {} as fat32 with label CRYSTAL_EFI", partitions[0]).as_str(),
);
exec_eval(
exec(
"mkfs.btrfs",
vec!["-f".to_string(), format!("{}p2", device)],
),
format!("format {}p2 as btrfs", device).as_str(),
);
mount(format!("{}p2", device).as_str(), "/mnt/", "");
exec_eval(
exec_workdir(
"btrfs",
"/mnt",
vec![
String::from("subvolume"),
String::from("create"),
String::from("@"),
],
),
"Create btrfs subvolume @",
);
exec_eval(
exec_workdir(
"btrfs",
"/mnt",
"mkfs.btfrs",
vec![
String::from("subvolume"),
String::from("create"),
String::from("@home"),
"-f".to_string(),
"-L".to_string(),
"CRYSTAL_ROOT".to_string(),
partitions[1].to_string(),
],
),
"Create btrfs subvolume @home",
format!("format {} as btrfs with label CRYSTAL_ROOT", partitions[1]).as_str(),
);
umount("/mnt");
mount(format!("{}p2", device).as_str(), "/mnt/", "subvol=@");
files_eval(files::create_directory("/mnt/boot"), "create /mnt/boot");
files_eval(files::create_directory("/mnt/home"), "create /mnt/home");
mount(
format!("{}p2", device).as_str(),
"/mnt/home",
"subvol=@home",
);
mount(format!("{}p1", device).as_str(), "/mnt/boot", "");
}
}
fn part_disk(device: &Path, efi: bool, unakite: bool) {
let device = device.to_string_lossy().to_string();
if efi && !unakite {
exec_eval(
exec(
"mkfs.vfat",
vec![String::from("-F32"), format!("{}1", device)],
),
format!("format {}1 as fat32", device).as_str(),
);
exec_eval(
exec("mkfs.btrfs", vec!["-f".to_string(), format!("{}2", device)]),
format!("format {}2 as btrfs", device).as_str(),
);
mount(format!("{}2", device).as_str(), "/mnt", "");
exec_eval(
exec_workdir(
"btrfs",
"/mnt",
vec![
String::from("subvolume"),
String::from("create"),
String::from("@"),
],
),
"Create btrfs subvolume @",
);
exec_eval(
exec_workdir(
"btrfs",
"/mnt",
vec![
String::from("subvolume"),
String::from("create"),
String::from("@home"),
],
),
"Create btrfs subvolume @home",
);
umount("/mnt");
mount(format!("{}2", device).as_str(), "/mnt/", "subvol=@");
files_eval(files::create_directory("/mnt/boot"), "create /mnt/boot");
files_eval(
files::create_directory("/mnt/boot/efi"),
"create /mnt/boot/efi",
);
files_eval(files::create_directory("/mnt/home"), "create /mnt/home");
mount(format!("{}2", device).as_str(), "/mnt/home", "subvol=@home");
mount(format!("{}1", device).as_str(), "/mnt/boot/efi", "");
} else if !efi && !unakite {
exec_eval(
exec("mkfs.ext4", vec![format!("{}1", device)]),
format!("format {}1 as ext4", device).as_str(),
);
exec_eval(
exec("mkfs.btrfs", vec!["-f".to_string(), format!("{}2", device)]),
format!("format {}2 as btrfs", device).as_str(),
);
mount(format!("{}2", device).as_str(), "/mnt/", "");
exec_eval(
exec_workdir(
"btrfs",
"/mnt",
vec![
String::from("subvolume"),
String::from("create"),
String::from("@"),
],
),
"Create btrfs subvolume @",
);
exec_eval(
exec_workdir(
"btrfs",
"/mnt",
vec![
String::from("subvolume"),
String::from("create"),
String::from("@home"),
],
),
"create btrfs subvolume @home",
);
umount("/mnt");
mount(format!("{}2", device).as_str(), "/mnt/", "subvol=@");
files_eval(
files::create_directory("/mnt/boot"),
"create directory /mnt/boot",
);
files_eval(
files::create_directory("/mnt/home"),
"create directory /mnt/home",
);
mount(format!("{}2", device).as_str(), "/mnt/home", "subvol=@home");
mount(format!("{}1", device).as_str(), "/mnt/boot", "");
} else if efi && unakite {
exec_eval(
exec(
"mkfs.vfat",
vec![String::from("-F32"), format!("{}1", device)],
),
format!("format {}1 as fat32", device).as_str(),
);
exec_eval(
exec("mkfs.btrfs", vec!["-f".to_string(), format!("{}2", device)]),
format!("format {}2 as btrfs", device).as_str(),
);
exec_eval(
exec("mkfs.btrfs", vec!["-f".to_string(), format!("{}3", device)]),
format!("format {}3 as btrfs", device).as_str(),
);
mount(format!("{}3", device).as_str(), "/mnt", "");
exec_eval(
exec_workdir(
"btrfs",
"/mnt",
vec![
String::from("subvolume"),
String::from("create"),
String::from("@"),
],
),
"Create btrfs subvolume @",
);
exec_eval(
exec_workdir(
"btrfs",
"/mnt",
vec![
String::from("subvolume"),
String::from("create"),
String::from("@home"),
],
),
"Create btrfs subvolume @home",
);
umount("/mnt");
mount(format!("{}3", device).as_str(), "/mnt/", "subvol=@");
files_eval(files::create_directory("/mnt/boot"), "create /mnt/boot");
files_eval(
files::create_directory("/mnt/boot/efi"),
"create /mnt/boot/efi",
);
files_eval(files::create_directory("/mnt/home"), "create /mnt/home");
mount(format!("{}3", device).as_str(), "/mnt/home", "subvol=@home");
mount(format!("{}1", device).as_str(), "/mnt/boot/efi", "");
} else if !efi && unakite {
exec_eval(
exec("mkfs.ext4", vec![format!("{}1", device)]),
format!("format {}1 as ext4", device).as_str(),
);
exec_eval(
exec("mkfs.btrfs", vec!["-f".to_string(), format!("{}2", device)]),
format!("format {}2 as btrfs", device).as_str(),
);
exec_eval(
exec("mkfs.btrfs", vec!["-f".to_string(), format!("{}3", device)]),
format!("format {}3 as btrfs", device).as_str(),
);
mount(format!("{}3", device).as_str(), "/mnt/", "");
fn mount_disks(efi: bool) {
mount("/dev/disk/by-label/CRYSTAL_ROOT", "/mnt", "");
exec_eval(
exec_workdir(
"btrfs",
@ -670,7 +241,7 @@ fn part_disk(device: &Path, efi: bool, unakite: bool) {
String::from("@"),
],
),
"Create btrfs subvolume @",
"create btrfs subvolume @",
);
exec_eval(
exec_workdir(
@ -685,17 +256,22 @@ fn part_disk(device: &Path, efi: bool, unakite: bool) {
"create btrfs subvolume @home",
);
umount("/mnt");
mount(format!("{}3", device).as_str(), "/mnt/", "subvol=@");
files_eval(
files::create_directory("/mnt/boot"),
"create directory /mnt/boot",
mount("/dev/disk/by-label/CRYSTAL_ROOT", "/mnt", "subvol=@");
files_eval(create_directory("/mnt/home"), "create directory /mnt/home");
mount(
"/dev/disk/by-label/CRYSTAL_ROOT",
"/mnt/home",
"subvol=@home",
);
files_eval(create_directory("/mnt/boot"), "create directory /mnt/boot");
if efi {
files_eval(
files::create_directory("/mnt/home"),
"create directory /mnt/home",
create_directory("/mnt/boot/efi"),
"create directory /mnt/boot/efi",
);
mount(format!("{}3", device).as_str(), "/mnt/home", "subvol=@home");
mount(format!("{}1", device).as_str(), "/mnt/boot", "");
mount("/dev/disk/by-label/CRYSTAL_EFI", "/mnt/boot/efi", "");
} else {
mount("/dev/disk/by-label/CRYSTAL_BOOT", "/mnt/boot", "");
}
}

@ -1,180 +0,0 @@
use crate::args::DesktopSetup;
use crate::functions::partition::mount;
use crate::functions::*;
use crate::internal::exec::*;
use crate::internal::*;
use std::path::PathBuf;
pub fn install_bootloader_efi(efidir: PathBuf) {
install::install(vec![
"grub",
"efibootmgr",
"grub-btrfs",
"crystal-grub-theme",
]);
let efidir = std::path::Path::new("/mnt").join(efidir);
let efi_str = efidir.to_str().unwrap();
if !std::path::Path::new(&format!("/mnt{efi_str}")).exists() {
crash(format!("The efidir {efidir:?} doesn't exist"), 1);
}
exec_eval(
exec_chroot(
"grub-install",
vec![
String::from("--target=x86_64-efi"),
format!("--efi-directory={}", efi_str),
String::from("--bootloader-id=unakite"),
String::from("--removable"),
],
),
"install unakite grub as efi with --removable",
);
exec_eval(
exec_chroot(
"grub-install",
vec![
String::from("--target=x86_64-efi"),
format!("--efi-directory={}", efi_str),
String::from("--bootloader-id=unakite"),
],
),
"install unakite grub as efi without --removable",
);
files_eval(
files::append_file(
"/mnt/etc/default/grub",
"GRUB_THEME=\"/usr/share/grub/themes/crystal/theme.txt\"",
),
"enable crystal grub theme",
);
exec_eval(
exec_chroot(
"grub-mkconfig",
vec![String::from("-o"), String::from("/boot/grub/grub.cfg")],
),
"create grub.cfg",
);
}
pub fn remount(root: &str, oldroot: &str, efi: bool, efidir: &str, bootdev: &str, firstrun: bool) {
if efi && firstrun {
exec_eval(
exec("umount", vec![String::from(bootdev)]),
&format!("Unmount {}", bootdev),
);
exec_eval(
exec("umount", vec![String::from(oldroot)]),
"Unmount old root",
);
mount(root, "/mnt", "");
exec_eval(
exec("mkdir", vec![String::from("-p"), String::from(efidir)]),
format!("Creating mountpoint {efidir} for {bootdev}").as_str(),
);
mount(bootdev, efidir, "");
} else if efi && !firstrun {
exec_eval(
exec("umount", vec![String::from(bootdev)]),
&format!("Unmount {}", bootdev),
);
exec_eval(
exec("umount", vec![String::from(root)]),
"Unmount unakite root",
);
mount(oldroot, "/mnt", "");
mount(bootdev, efidir, "");
} else if !efi && firstrun {
exec_eval(
exec("umount", vec![String::from(bootdev)]),
&format!("Unmount {}", bootdev),
);
exec_eval(
exec("umount", vec![String::from(oldroot)]),
"Unmount old root",
);
mount(root, "/mnt", "");
exec_eval(
exec("mkdir", vec![String::from("-p"), String::from("/mnt/boot")]),
format!("Creating mountpoint /boot for {bootdev}").as_str(),
);
mount(bootdev, "/mnt/boot", "");
} else if !efi && !firstrun {
exec_eval(
exec("umount", vec![String::from(bootdev)]),
&format!("Unmount {}", bootdev),
);
exec_eval(
exec("umount", vec![String::from(root)]),
"Unmount unakite root",
);
mount(oldroot, "/mnt", "");
mount(bootdev, "/mnt/boot", "");
} else {
panic!("Unknown state");
}
}
pub fn setup_unakite(root: &str, oldroot: &str, efi: bool, efidir: &str, bootdev: &str) {
log::debug!("Setting up Unakite");
remount(root, oldroot, efi, efidir, bootdev, true);
base::install_base_packages("linux".to_string());
base::genfstab();
locale::set_locale("en_US.UTF-8 UTF-8".to_string());
locale::set_timezone("Europe/Berlin"); // TODO: get the proper timezone
network::set_hostname("unakite");
network::create_hosts();
users::new_user(
"unakite",
true,
"Cp7oN04ZY0PsA", // unakite
false,
"/bin/bash",
);
exec_eval(
exec(
"sed",
vec![
String::from("-i"),
String::from("-e"),
String::from("s/crystal/unakite/g"),
String::from("/mnt/etc/os-release"),
],
),
"Change os-release",
);
exec_eval(
exec(
"sed",
vec![
String::from("-i"),
String::from("-e"),
String::from("s/Crystal/Unakite/g"),
String::from("/mnt/etc/os-release"),
],
),
"Change os-release",
);
if efi {
install_bootloader_efi(PathBuf::from(efidir.replace("/mnt", "")));
}
users::root_pass("Cp7oN04ZY0PsA"); // unakite
desktops::install_desktop_setup(DesktopSetup::Xfce);
install(vec!["gparted", "firefox"]);
exec_eval(
exec(
"cp",
vec![
String::from("/tmp/jade.json"),
String::from("/mnt/etc/installSettings.json"),
],
),
"Copy jade.json to /etc/installSettings.json in unakite",
);
remount(root, oldroot, efi, efidir, bootdev, false);
exec_eval(
exec_chroot(
"grub-mkconfig",
vec![String::from("-o"), String::from("/boot/grub/grub.cfg")],
),
"Recreate grub.cfg in crystal",
);
}

@ -18,7 +18,6 @@ struct Config {
flatpak: bool,
zramd: bool,
extra_packages: Vec<String>,
unakite: Unakite,
kernel: String,
}
@ -57,15 +56,6 @@ struct Users {
shell: String,
}
#[derive(Serialize, Deserialize)]
struct Unakite {
enable: bool,
root: String,
oldroot: String,
efidir: String,
bootdev: String,
}
pub fn read_config(configpath: PathBuf) {
let data = std::fs::read_to_string(&configpath);
match &data {
@ -107,7 +97,6 @@ pub fn read_config(configpath: PathBuf) {
config.partition.mode,
config.partition.efi,
&mut partitions,
config.unakite.enable,
);
base::install_base_packages(config.kernel);
base::genfstab();
@ -199,69 +188,5 @@ pub fn read_config(configpath: PathBuf) {
extra_packages.push(config.extra_packages[i].as_str());
}
install(extra_packages);
log::info!("Setup unakite");
if config.partition.mode == PartitionMode::Auto
&& !config.partition.efi
&& config.unakite.enable
&& !config.partition.device.to_string().contains("nvme")
{
let root = PathBuf::from("/dev/").join(config.partition.device.as_str());
unakite::setup_unakite(
format!("{}2", root.to_str().unwrap()).as_str(),
format!("{}3", root.to_str().unwrap()).as_str(),
config.partition.efi,
"/boot",
format!("{}1", root.to_str().unwrap()).as_str(),
)
} else if config.partition.mode == PartitionMode::Auto
&& config.partition.efi
&& config.unakite.enable
&& !config.partition.device.to_string().contains("nvme")
{
let root = PathBuf::from("/dev/").join(config.partition.device.as_str());
unakite::setup_unakite(
format!("{}2", root.to_str().unwrap()).as_str(),
format!("{}3", root.to_str().unwrap()).as_str(),
config.partition.efi,
"/boot/efi",
format!("{}1", root.to_str().unwrap()).as_str(),
)
} else if config.unakite.enable {
unakite::setup_unakite(
&config.unakite.root,
&config.unakite.oldroot,
config.partition.efi,
&config.unakite.efidir,
&config.unakite.bootdev,
);
} else if config.partition.mode == PartitionMode::Auto
&& config.partition.efi
&& config.unakite.enable
&& config.partition.device.to_string().contains("nvme")
{
let root = PathBuf::from("/dev/").join(config.partition.device.as_str());
unakite::setup_unakite(
format!("{}p2", root.to_str().unwrap()).as_str(),
format!("{}p3", root.to_str().unwrap()).as_str(),
config.partition.efi,
"/boot/efi",
format!("{}p1", root.to_str().unwrap()).as_str(),
)
} else if config.partition.mode == PartitionMode::Auto
&& !config.partition.efi
&& config.unakite.enable
&& config.partition.device.to_string().contains("nvme")
{
let root = PathBuf::from("/dev/").join(config.partition.device.as_str());
unakite::setup_unakite(
format!("{}p2", root.to_str().unwrap()).as_str(),
format!("{}p3", root.to_str().unwrap()).as_str(),
config.partition.efi,
"/boot",
format!("{}p1", root.to_str().unwrap()).as_str(),
)
} else {
log::info!("Unakite disabled");
}
println!("Installation finished! You may reboot now!")
}

@ -14,13 +14,7 @@ fn main() {
match opt.command {
Command::Partition(args) => {
let mut partitions = args.partitions;
partition::partition(
args.device,
args.mode,
args.efi,
&mut partitions,
args.unakite,
);
partition::partition(args.device, args.mode, args.efi, &mut partitions);
}
Command::InstallBase(args) => {
base::install_base_packages(args.kernel);
@ -74,15 +68,6 @@ fn main() {
Command::Flatpak => {
base::install_flatpak();
}
Command::Unakite(args) => {
unakite::setup_unakite(
&args.root,
&args.oldroot,
args.efi,
&args.efidir,
&args.bootdev,
);
}
Command::Config { config } => {
crate::internal::config::read_config(config);
}

Loading…
Cancel
Save