make it actually compile

axtloss/rework-partitioning
axtlos 2 years ago
parent c47f47789c
commit 52046109de

@ -62,7 +62,7 @@ pub enum Command {
/// Setup unakite /// Setup unakite
#[clap(name = "unakite")] #[clap(name = "unakite")]
Unakite, Unakite(UnakiteArgs),
/// Read jade installation config /// Read jade installation config
#[clap(name = "config")] #[clap(name = "config")]
@ -100,6 +100,25 @@ pub struct PartitionArgs {
pub partitions: Vec<Partition>, pub partitions: Vec<Partition>,
} }
#[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)] #[derive(Debug)]
pub struct Partition { pub struct Partition {
pub mountpoint: String, pub mountpoint: String,

@ -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() { if !options.is_empty() {
exec_eval( exec_eval(
exec( exec(

@ -1,6 +1,9 @@
use crate::internal::exec::*; use crate::internal::exec::*;
use crate::internal::*; 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) { pub fn install_bootloader_efi(efidir: PathBuf) {
install::install(vec!["grub", "efibootmgr", "grub-btrfs", "crystal-grub-theme"]); install::install(vec!["grub", "efibootmgr", "grub-btrfs", "crystal-grub-theme"]);
let efidir = std::path::Path::new("/mnt").join(efidir); 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", "install unakite grub as efi without --removable",
); );
files_eval( 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" "enable crystal grub theme"
); );
exec_eval( 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 { if efi && firstrun {
exec_eval( exec_eval(
exec( exec(
"umount", "umount",
vec![String::from(bootdev)], vec![String::from(bootdev)],
), ),
format!("Unmount {}", bootdev), &format!("Unmount {}", bootdev),
) );
exec_eval( exec_eval(
exec( exec(
"umount", "umount",
vec![String::from("/")], vec![String::from("/")],
), ),
format!("Unmount old root"), &format!("Unmount old root"),
); );
mount(root, "/"); mount(root, "/", "");
mount(bootdev, efidir); mount(bootdev, efidir, "");
} else if efi && !firstrun { } else if efi && !firstrun {
exec_eval( exec_eval(
exec( exec(
"umount", "umount",
vec![String::from(bootdev)], vec![String::from(bootdev)],
), ),
format!("Unmount {}", bootdev), &format!("Unmount {}", bootdev),
) );
exec_eval( exec_eval(
exec( exec(
"umount", "umount",
vec![String::from("/")], vec![String::from("/")],
), ),
format!("Unmount unakite root"), &format!("Unmount unakite root"),
); );
mount(root, "/"); mount(root, "/", "");
mount(bootdev, efidir); mount(bootdev, efidir, "");
} else if !efi && firstrun { } else if !efi && firstrun {
exec_eval( exec_eval(
exec( exec(
"umount", "umount",
vec![String::from(bootdev)], vec![String::from(bootdev)],
), ),
format!("Unmount {}", bootdev), &format!("Unmount {}", bootdev),
) );
exec_eval( exec_eval(
exec( exec(
"umount", "umount",
vec![String::from("/")], vec![String::from("/")],
), ),
format!("Unmount old root"), &format!("Unmount old root"),
); );
mount(root, "/"); mount(root, "/", "");
mount(bootdev, "/boot"); mount(bootdev, "/boot", "");
} else if !efi && !firstrun { } else if !efi && !firstrun {
exec_eval( exec_eval(
exec( exec(
"umount", "umount",
vec![String::from(bootdev)], vec![String::from(bootdev)],
), ),
format!("Unmount {}", bootdev), &format!("Unmount {}", bootdev),
); );
exec_eval( exec_eval(
exec( exec(
"umount", "umount",
vec![String::from("/")], vec![String::from("/")],
), ),
format!("Unmount unakite root"), &format!("Unmount unakite root"),
); );
mount(oldroot, "/"); mount(oldroot, "/", "");
mount(bootdev, "/boot"); mount(bootdev, "/boot", "");
} else { } else {
panic!("Unknown state"); 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"); 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::install_base_packages();
base::genfstab(); base::genfstab();
if efi { if efi {
install_bootloader_efi(PathBuf::from(efidir)); install_bootloader_efi(PathBuf::from(efidir));
} }
locale::set_locale(""); locale::set_locale("".to_string());
locale::set_timezone("Europe/Berlin"); // TODO: get the proper timezone locale::set_timezone("Europe/Berlin"); // TODO: get the proper timezone
network::set_hostname("unakite"); network::set_hostname("unakite");
network::create_hosts(""); network::create_hosts();
users::new_user( users::new_user(
"unakite", "unakite",
true, true,
"Cp7oN04ZY0PsA", // unakite "Cp7oN04ZY0PsA", // unakite
) );
users::root_pass("Cp7oN04ZY0PsA"); // unakite users::root_pass("Cp7oN04ZY0PsA"); // unakite
desktops::install_desktop_desktup_setup(DesktopSetup::Xfce); desktops::install_desktop_setup(DesktopSetup::Xfce);
install(vec!["gparted", "firefox"]); install(vec!["gparted", "firefox"]);
remount(root, oldroot, efi, efidir, bootdev, false); remount(root, oldroot, efi, efidir, bootdev, false);
} }

@ -59,8 +59,14 @@ fn main() {
Command::Flatpak => { Command::Flatpak => {
base::install_flatpak(); base::install_flatpak();
} }
Command::Unakite => { Command::Unakite(args) => {
unakite::setup_unakite(); unakite::setup_unakite(
&args.root,
&args.oldroot,
args.efi,
&args.efidir,
&args.bootdev,
);
}, },
Command::Config { config } => { Command::Config { config } => {
crate::internal::config::read_config(config); crate::internal::config::read_config(config);

Loading…
Cancel
Save