From 52046109dee5eb2c2a4b9599247734081c5fc5a3 Mon Sep 17 00:00:00 2001 From: axtlos Date: Mon, 9 May 2022 22:50:23 +0200 Subject: [PATCH] make it actually compile --- src/args.rs | 21 +++++++++++++- src/functions/partition.rs | 2 +- src/functions/unakite.rs | 59 ++++++++++++++++++++------------------ src/main.rs | 10 +++++-- 4 files changed, 60 insertions(+), 32 deletions(-) diff --git a/src/args.rs b/src/args.rs index 2bced1f..a944010 100644 --- a/src/args.rs +++ b/src/args.rs @@ -62,7 +62,7 @@ pub enum Command { /// Setup unakite #[clap(name = "unakite")] - Unakite, + Unakite(UnakiteArgs), /// Read jade installation config #[clap(name = "config")] @@ -100,6 +100,25 @@ pub struct PartitionArgs { pub partitions: Vec, } +#[derive(Debug, Args)] +pub struct UnakiteArgs { + /// root device of unakite + #[clap(long)] + pub root: String, + /// root device of crystal + #[clap(long)] + pub oldroot: String, + /// wether it is efi + #[clap(long)] + pub efi: bool, + /// boot directory (if not efi) or efi directory (if efi) + #[clap(long)] + pub efidir: String, + /// device of boot device + #[clap(long)] + pub bootdev: String, +} + #[derive(Debug)] pub struct Partition { pub mountpoint: String, diff --git a/src/functions/partition.rs b/src/functions/partition.rs index 361bd11..4471ce3 100755 --- a/src/functions/partition.rs +++ b/src/functions/partition.rs @@ -485,7 +485,7 @@ fn part_disk(device: &Path, efi: bool) { } } -fn mount(partition: &str, mountpoint: &str, options: &str) { +pub fn mount(partition: &str, mountpoint: &str, options: &str) { if !options.is_empty() { exec_eval( exec( diff --git a/src/functions/unakite.rs b/src/functions/unakite.rs index 893cd9d..724db1e 100644 --- a/src/functions/unakite.rs +++ b/src/functions/unakite.rs @@ -1,6 +1,9 @@ use crate::internal::exec::*; use crate::internal::*; - +use crate::functions::*; +use crate::functions::partition::mount; +use std::path::PathBuf; +use crate::args::DesktopSetup; 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); @@ -32,7 +35,7 @@ pub fn install_bootloader_efi(efidir: PathBuf) { "install unakite grub as efi without --removable", ); files_eval( - append_file("/mnt/etc/default/grub", "GRUB_THEME=\"/usr/share/grub/themes/crystal/theme.txt\""), + files::append_file("/mnt/etc/default/grub", "GRUB_THEME=\"/usr/share/grub/themes/crystal/theme.txt\""), "enable crystal grub theme" ); exec_eval( @@ -44,99 +47,99 @@ pub fn install_bootloader_efi(efidir: PathBuf) { ); } -pub fn remount(root: &str, oldroot: &stre, efi: bool, efidir: &str, bootdev: &str, firstrun: bool) { +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), - ) + &format!("Unmount {}", bootdev), + ); exec_eval( exec( "umount", vec![String::from("/")], ), - format!("Unmount old root"), + &format!("Unmount old root"), ); - mount(root, "/"); - mount(bootdev, efidir); + mount(root, "/", ""); + mount(bootdev, efidir, ""); } else if efi && !firstrun { exec_eval( exec( "umount", vec![String::from(bootdev)], ), - format!("Unmount {}", bootdev), - ) + &format!("Unmount {}", bootdev), + ); exec_eval( exec( "umount", vec![String::from("/")], ), - format!("Unmount unakite root"), + &format!("Unmount unakite root"), ); - mount(root, "/"); - mount(bootdev, efidir); + mount(root, "/", ""); + mount(bootdev, efidir, ""); } else if !efi && firstrun { exec_eval( exec( "umount", vec![String::from(bootdev)], ), - format!("Unmount {}", bootdev), - ) + &format!("Unmount {}", bootdev), + ); exec_eval( exec( "umount", vec![String::from("/")], ), - format!("Unmount old root"), + &format!("Unmount old root"), ); - mount(root, "/"); - mount(bootdev, "/boot"); + mount(root, "/", ""); + mount(bootdev, "/boot", ""); } else if !efi && !firstrun { exec_eval( exec( "umount", vec![String::from(bootdev)], ), - format!("Unmount {}", bootdev), + &format!("Unmount {}", bootdev), ); exec_eval( exec( "umount", vec![String::from("/")], ), - format!("Unmount unakite root"), + &format!("Unmount unakite root"), ); - mount(oldroot, "/"); - mount(bootdev, "/boot"); + mount(oldroot, "/", ""); + mount(bootdev, "/boot", ""); } else { panic!("Unknown state"); } } -pub fn setup_unakite(root: &str, oldroot: &stre, efi: bool, efidir: &str, bootdev: &str) { +pub fn setup_unakite(root: &str, oldroot: &str, efi: bool, efidir: &str, bootdev: &str) { log::debug!("Setting up Unakite"); - remount_efi(root, oldroot, efi, efidir, bootdev, true); + remount(root, oldroot, efi, efidir, bootdev, true); base::install_base_packages(); base::genfstab(); if efi { install_bootloader_efi(PathBuf::from(efidir)); } - locale::set_locale(""); + locale::set_locale("".to_string()); locale::set_timezone("Europe/Berlin"); // TODO: get the proper timezone network::set_hostname("unakite"); - network::create_hosts(""); + network::create_hosts(); users::new_user( "unakite", true, "Cp7oN04ZY0PsA", // unakite - ) + ); users::root_pass("Cp7oN04ZY0PsA"); // unakite - desktops::install_desktop_desktup_setup(DesktopSetup::Xfce); + desktops::install_desktop_setup(DesktopSetup::Xfce); install(vec!["gparted", "firefox"]); remount(root, oldroot, efi, efidir, bootdev, false); } \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 13d9952..67befdc 100755 --- a/src/main.rs +++ b/src/main.rs @@ -59,8 +59,14 @@ fn main() { Command::Flatpak => { base::install_flatpak(); } - Command::Unakite => { - unakite::setup_unakite(); + 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);