make it actually compile

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

@ -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<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)]
pub struct Partition {
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() {
exec_eval(
exec(

@ -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);
}

@ -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);

Loading…
Cancel
Save