add bootloader and base package installation and make crash/log msesages all the same format

axtloss/rework-partitioning
amy 3 years ago
parent 719acfa617
commit dce3a65210

@ -0,0 +1,54 @@
use crate::internal::exec::*;
use crate::internal::*;
pub fn install_base_packages() {
install::install(vec![
"base",
"linux",
"linux-firmware",
"systemd-sysvcompat",
"networkmanager",
"man-db",
"man-pages",
"texinfo",
"micro",
"sudo",
"curl",
"archlinux-keyring",
"neofetch",
"btrfs-progs",
"timeshift",
"timeshift-autosnap",
"which",
]);
}
pub fn create_hosts() {
files::create_file("/mnt/etc/hosts");
files_eval(files::append_file("/mnt/etc/hosts", "127.0.0.1 localhost"), "create /etc/hosts");
}
pub fn install_bootloader_efi(efidir: &str) {
install::install(vec!["grub", "efibootmgr",]);
exec_eval(exec_chroot("grub-install", vec![
String::from("--target=x86_64-efi"),
format!("--efi-directory={}", efidir),
String::from("--bootloader-id=crystal"),
]), "install grub as efi");
exec_eval(exec_chroot("grub-mkconfig", vec![
String::from("-o"),
String::from("/boot/grub/grub.cfg"),
]), "create grub.cfg");
}
pub fn install_bootloader_legacy(device: &str) {
install::install(vec!["grub"]);
exec_eval(exec_chroot("grub-install", vec![
String::from("--target=i386-pc"),
String::from(device),
]), "install grub as legacy");
exec_eval(exec_chroot("grub-mkconfig", vec![
String::from("-o"),
String::from("/boot/grub/grub.cfg"),
]), "create grub.cfg");
}

@ -9,16 +9,16 @@ pub fn set_timezone(timezone: &str) {
format!("/usr/share/zoneinfo/{}", timezone), format!("/usr/share/zoneinfo/{}", timezone),
"/etc/localtime".to_string(), "/etc/localtime".to_string(),
], ],
)); ), "Set timezone");
exec_eval(exec_chroot("hwclock", vec!["--systohc".to_string()])); exec_eval(exec_chroot("hwclock", vec!["--systohc".to_string()]), "Set system clock");
} }
pub fn set_locale(locale: String) { pub fn set_locale(locale: String) {
files_eval(files::append_file("/etc/locale.gen", "en_US.UTF-8 UTF-8")); files_eval(files::append_file("/etc/locale.gen", "en_US.UTF-8 UTF-8"), "add en_US.UTF-8 UTF-8 to locale.gen");
files_eval(files::append_file("/etc/locale.gen", locale.as_str())); files_eval(files::append_file("/etc/locale.gen", locale.as_str()), "add locales to locale.gen");
exec_eval(exec_chroot("locale-gen", vec!["".to_string()])); exec_eval(exec_chroot("locale-gen", vec!["".to_string()]), "generate locales");
files::create_file("/etc/locale.conf"); files::create_file("/etc/locale.conf");
files_eval(files::append_file("/etc/locale.conf", "LANG=en_US.UTF-8")); files_eval(files::append_file("/etc/locale.conf", "LANG=en_US.UTF-8"), "edit locale.conf");
} }
pub fn set_keyboard(keyboard: &str) { pub fn set_keyboard(keyboard: &str) {
@ -26,27 +26,5 @@ pub fn set_keyboard(keyboard: &str) {
files_eval(files::append_file( files_eval(files::append_file(
"/etc/vconsole.conf", "/etc/vconsole.conf",
format!("KEYMAP={}", keyboard).as_str(), format!("KEYMAP={}", keyboard).as_str(),
)); ), "set keyboard layout");
}
fn files_eval(return_code: std::result::Result<(), std::io::Error>) {
match return_code {
Ok(_) => {
log("Success".to_string());
}
Err(e) => {
crash(format!("Failed to create file, Error: {}", e), 1);
}
}
}
fn exec_eval(return_code: std::result::Result<std::process::Output, std::io::Error>) {
match return_code {
Ok(_) => {
log("Success".to_string());
}
Err(e) => {
crash(format!("Failed with error: {}", e), 1);
}
}
} }

@ -3,3 +3,4 @@ pub mod locale;
pub mod network; pub mod network;
pub mod partition; pub mod partition;
pub mod users; pub mod users;
pub mod base;

@ -3,32 +3,14 @@ use crate::internal::*;
pub fn set_hostname(hostname: &str) { pub fn set_hostname(hostname: &str) {
println!("Setting hostname to {}", hostname); println!("Setting hostname to {}", hostname);
files::create_file("/mnt/etc/hostname"); files::create_file("/mnt/etc/hostname");
let return_val = files::append_file("/mnt/etc/hostname", hostname); files_eval(files::append_file("/mnt/etc/hostname", hostname), "set hostname");
match return_val {
Ok(_) => {
log(format!("Set hostname to {}", hostname));
}
Err(e) => {
crash(
format!("Failed to set hostname to {}, Error: {}", hostname, e),
1,
);
}
}
} }
pub fn enable_ipv6(ipv6: bool) { pub fn create_hosts() {
if ipv6 { files::create_file("/mnt/etc/hosts");
let return_val = files::append_file("/mnt/etc/hosts", "::1 localhost"); files_eval(files::append_file("/mnt/etc/hosts", "127.0.0.1 localhost"), "create /etc/hosts");
match return_val {
Ok(_) => {
log("Enabled IPv6".to_string());
}
Err(e) => {
crash(format!("Failed to enable IPv6, Error: {}", e), 1);
}
}
} else {
log("Not enabling ipv6".to_string());
} }
pub fn enable_ipv6() {
files_eval(files::append_file("/mnt/etc/hosts", "::1 localhost"), "add ipv6 localhost");
} }

@ -7,7 +7,7 @@ pub fn partition(device: &str, mode: &str, efi: bool) {
} else { } else {
log(format!("automatically partitioning {}", device)); log(format!("automatically partitioning {}", device));
if efi { if efi {
returncode_eval(exec( exec_eval(exec(
"parted", "parted",
vec![ vec![
String::from("-s"), String::from("-s"),
@ -15,8 +15,8 @@ pub fn partition(device: &str, mode: &str, efi: bool) {
String::from("mklabel"), String::from("mklabel"),
String::from("gpt"), String::from("gpt"),
], ],
)); ), format!("create gpt label on {}", device).as_str());
returncode_eval(exec( exec_eval(exec(
"parted", "parted",
vec![ vec![
String::from("-s"), String::from("-s"),
@ -26,8 +26,8 @@ pub fn partition(device: &str, mode: &str, efi: bool) {
String::from("0"), String::from("0"),
String::from("300"), String::from("300"),
], ],
)); ), "create EFI partition");
returncode_eval(exec( exec_eval(exec(
"parted", "parted",
vec![ vec![
String::from("-s"), String::from("-s"),
@ -37,9 +37,9 @@ pub fn partition(device: &str, mode: &str, efi: bool) {
String::from("300"), String::from("300"),
String::from("100%"), String::from("100%"),
], ],
)); ), "Create btrfs root partition");
} else { } else {
returncode_eval(exec( exec_eval(exec(
"parted", "parted",
vec![ vec![
String::from("-s"), String::from("-s"),
@ -47,8 +47,8 @@ pub fn partition(device: &str, mode: &str, efi: bool) {
String::from("mklabel"), String::from("mklabel"),
String::from("msdos"), String::from("msdos"),
], ],
)); ), format!("Create msdos label on {}", device).as_str());
returncode_eval(exec( exec_eval(exec(
"parted", "parted",
vec![ vec![
String::from("-s"), String::from("-s"),
@ -58,8 +58,8 @@ pub fn partition(device: &str, mode: &str, efi: bool) {
String::from("512MIB"), String::from("512MIB"),
String::from("100&"), String::from("100&"),
], ],
)); ), "create btrfs root partition");
returncode_eval(exec( exec_eval(exec(
"parted", "parted",
vec![ vec![
String::from("-s"), String::from("-s"),
@ -69,7 +69,7 @@ pub fn partition(device: &str, mode: &str, efi: bool) {
String::from("1MIB"), String::from("1MIB"),
String::from("512MIB"), String::from("512MIB"),
], ],
)); ), "create bios boot partition");
} }
} }
if device.contains("nvme") { if device.contains("nvme") {
@ -81,16 +81,10 @@ pub fn partition(device: &str, mode: &str, efi: bool) {
fn part_nvme(device: &str, efi: bool) { fn part_nvme(device: &str, efi: bool) {
if efi { if efi {
returncode_eval(exec( exec_eval(exec("mkfs.vfat", vec![format!("{}p1", device)]), format!("format {}p1 as fat32", device).as_str());
"mkfs.vfat", exec_eval(exec("mkfs.btrfs", vec![format!("{}p2", device)]), format!("format {}p2 as btrfs", device).as_str());
vec![format!("{}p1", device)], mount(format!("{}p2", device).as_str(), "/mnt", "");
)); exec_eval(exec_workdir(
returncode_eval(exec(
"mkfs.btrfs",
vec![format!("{}p2", device)],
));
mount(format!("{}p2", device), "/mnt", "");
returncode_eval(exec_workdir(
"btrfs", "btrfs",
"/mnt", "/mnt",
vec![ vec![
@ -98,8 +92,8 @@ fn part_nvme(device: &str, efi: bool) {
String::from("create"), String::from("create"),
String::from("@"), String::from("@"),
], ],
)); ), "Create btrfs subvolume @");
returncode_eval(exec_workdir( exec_eval(exec_workdir(
"btrfs", "btrfs",
"/mnt", "/mnt",
vec![ vec![
@ -107,25 +101,19 @@ fn part_nvme(device: &str, efi: bool) {
String::from("create"), String::from("create"),
String::from("@home"), String::from("@home"),
], ],
)); ), "Create btrfs subvolume @home");
umount("/mnt"); umount("/mnt");
mount(format!("{}p2", device), "/mnt/", "subvol=@"); mount(format!("{}p2", device).as_str(), "/mnt/", "subvol=@");
files::create_directory("/mnt/boot"); files_eval(files::create_directory("/mnt/boot"), "create /mnt/boot");
files::create_directory("/mnt/boot/efi"); files_eval(files::create_directory("/mnt/boot/efi"), "create /mnt/boot/efi");
files::create_directory("/mnt/home"); files_eval(files::create_directory("/mnt/home"), "create /mnt/home");
mount(format!("{}p2", device), "/mnt/home", "subvol=@home"); mount(format!("{}p2", device).as_str(), "/mnt/home", "subvol=@home");
mount(format!("{}p1", device), "/mnt/boot/efi", ""); mount(format!("{}p1", device).as_str(), "/mnt/boot/efi", "");
} else { } else {
returncode_eval(exec( exec_eval(exec("mkfs.ext4", vec![format!("{}p1", device)]), format!("format {}p1 as ext4", device).as_str());
"mkfs.ext4", exec_eval(exec("mkfs.btrfs", vec![format!("{}p2", device)]), format!("format {}p2 as btrfs", device).as_str());
vec![format!("{}p1", device)], mount(format!("{}p2", device).as_str(), "/mnt/", "");
)); exec_eval(exec_workdir(
returncode_eval(exec(
"mkfs.btrfs",
vec![format!("{}p2", device)],
));
mount(format!("{}p2", device), "/mnt/", "");
returncode_eval(exec_workdir(
"btrfs", "btrfs",
"/mnt", "/mnt",
vec![ vec![
@ -133,8 +121,8 @@ fn part_nvme(device: &str, efi: bool) {
String::from("create"), String::from("create"),
String::from("@"), String::from("@"),
], ],
)); ), "Create btrfs subvolume @");
returncode_eval(exec_workdir( exec_eval(exec_workdir(
"btrfs", "btrfs",
"/mnt", "/mnt",
vec![ vec![
@ -142,28 +130,22 @@ fn part_nvme(device: &str, efi: bool) {
String::from("create"), String::from("create"),
String::from("@home"), String::from("@home"),
], ],
)); ), "Create btrfs subvolume @home");
umount("/mnt"); umount("/mnt");
mount(format!("{}p2", device), "/mnt/", "subvol=@"); mount(format!("{}p2", device).as_str(), "/mnt/", "subvol=@");
files::create_directory("/mnt/boot"); files_eval(files::create_directory("/mnt/boot"), "create /mnt/boot");
files::create_directory("/mnt/home"); files_eval(files::create_directory("/mnt/home"), "create /mnt/home");
mount(format!("{}p2", device), "/mnt/home", "subvol=@home"); mount(format!("{}p2", device).as_str(), "/mnt/home", "subvol=@home");
mount(format!("{}p1", device), "/mnt/boot", ""); mount(format!("{}p1", device).as_str(), "/mnt/boot", "");
} }
} }
fn part_disk(device: &str, efi: bool) { fn part_disk(device: &str, efi: bool) {
if efi { if efi {
returncode_eval(exec( exec_eval(exec("mkfs.vfat", vec![format!("{}1", device)]), format!("format {}1 as fat32", device).as_str());
"mkfs.vfat", exec_eval(exec("mkfs.btrfs", vec![format!("{}2", device)]), format!("format {}2 as btrfs", device).as_str());
vec![format!("{}1", device)], mount(format!("{}2", device).as_str(), "/mnt", "");
)); exec_eval(exec_workdir(
returncode_eval(exec(
"mkfs.btrfs",
vec![format!("{}2", device)],
));
mount(format!("{}2", device), "/mnt", "");
returncode_eval(exec_workdir(
"btrfs", "btrfs",
"/mnt", "/mnt",
vec![ vec![
@ -171,8 +153,8 @@ fn part_disk(device: &str, efi: bool) {
String::from("create"), String::from("create"),
String::from("@"), String::from("@"),
], ],
)); ), "Create btrfs subvolume @");
returncode_eval(exec_workdir( exec_eval(exec_workdir(
"btrfs", "btrfs",
"/mnt", "/mnt",
vec![ vec![
@ -180,25 +162,19 @@ fn part_disk(device: &str, efi: bool) {
String::from("create"), String::from("create"),
String::from("@home"), String::from("@home"),
], ],
)); ), "Create btrfs subvolume @home");
umount("/mnt"); umount("/mnt");
mount(format!("{}2", device), "/mnt/", "subvol=@"); mount(format!("{}2", device).as_str(), "/mnt/", "subvol=@");
files::create_directory("/mnt/boot"); files_eval(files::create_directory("/mnt/boot"), "create /mnt/boot");
files::create_directory("/mnt/boot/efi"); files_eval(files::create_directory("/mnt/boot/efi"), "create /mnt/boot/efi");
files::create_directory("/mnt/home"); files_eval(files::create_directory("/mnt/home"), "create /mnt/home");
mount(format!("{}2", device), "/mnt/home", "subvol=@home"); mount(format!("{}2", device).as_str(), "/mnt/home", "subvol=@home");
mount(format!("{}1", device), "/mnt/boot/efi", ""); mount(format!("{}1", device).as_str(), "/mnt/boot/efi", "");
} else { } else {
returncode_eval(exec( exec_eval(exec("mkfs.ext4", vec![format!("{}1", device)]), format!("format {}1 as ext4", device).as_str());
"mkfs.ext4", exec_eval(exec("mkfs.btrfs", vec![format!("{}2", device)]), format!("format {}2 as btrfs", device).as_str());
vec![format!("{}1", device)], mount(format!("{}2", device).as_str(), "/mnt/", "");
)); exec_eval(exec_workdir(
returncode_eval(exec(
"mkfs.btrfs",
vec![format!("{}2", device)],
));
mount(format!("{}2", device), "/mnt/", "");
returncode_eval(exec_workdir(
"btrfs", "btrfs",
"/mnt", "/mnt",
vec![ vec![
@ -206,8 +182,8 @@ fn part_disk(device: &str, efi: bool) {
String::from("create"), String::from("create"),
String::from("@"), String::from("@"),
], ],
)); ), "Create btrfs subvolume @");
returncode_eval(exec_workdir( exec_eval(exec_workdir(
"btrfs", "btrfs",
"/mnt", "/mnt",
vec![ vec![
@ -215,40 +191,29 @@ fn part_disk(device: &str, efi: bool) {
String::from("create"), String::from("create"),
String::from("@home"), String::from("@home"),
], ],
)); ), "create btrfs subvolume @home");
umount("/mnt"); umount("/mnt");
mount(format!("{}2", device), "/mnt/", "subvol=@"); mount(format!("{}2", device).as_str(), "/mnt/", "subvol=@");
files::create_directory("/mnt/boot"); files_eval(files::create_directory("/mnt/boot"), "create directory /mnt/boot");
files::create_directory("/mnt/home"); files_eval(files::create_directory("/mnt/home"), "create directory /mnt/home");
mount(format!("{}2", device), "/mnt/home", "subvol=@home"); mount(format!("{}2", device).as_str(), "/mnt/home", "subvol=@home");
mount(format!("{}1", device), "/mnt/boot", ""); mount(format!("{}1", device).as_str(), "/mnt/boot", "");
} }
} }
fn mount(partition: String, mountpoint: &str, options: &str) { fn mount(partition: &str, mountpoint: &str, options: &str) {
let options = if options.is_empty() { "\"\"" } else { options }; let options = if options.is_empty() { "\"\"" } else { options };
returncode_eval(exec( exec_eval(exec(
"mount", "mount",
vec![ vec![
partition, String::from(partition),
String::from(mountpoint), String::from(mountpoint),
String::from("-o"), String::from("-o"),
String::from(options), String::from(options),
], ],
)); ), format!("mount {} with options {} at {}", partition, options, mountpoint).as_str());
} }
fn umount(mountpoint: &str) { fn umount(mountpoint: &str) {
returncode_eval(exec("umount", vec![String::from(mountpoint)])); exec_eval(exec("umount", vec![String::from(mountpoint)]), format!("unmount {}", mountpoint).as_str());
}
fn returncode_eval(return_code: std::result::Result<std::process::Output, std::io::Error>) {
match return_code {
Ok(_) => {
log("Success".to_string());
}
Err(e) => {
crash(format!("Failed with error: {}", e), 1);
}
}
} }

@ -2,7 +2,7 @@ use crate::internal::exec::*;
use crate::internal::*; use crate::internal::*;
pub fn new_user(username: &str, hasroot: bool, password: &str) { pub fn new_user(username: &str, hasroot: bool, password: &str) {
let return_val = exec_chroot( exec_eval(exec_chroot(
"useradd", "useradd",
vec![ vec![
String::from("-m"), String::from("-m"),
@ -10,20 +10,9 @@ pub fn new_user(username: &str, hasroot: bool, password: &str) {
String::from("/bin/bash"), String::from("/bin/bash"),
String::from(username), String::from(username),
], ],
); ), format!("Create user {}", username).as_str());
match return_val {
Ok(_) => {
log(format!("Created user {}", username));
}
Err(e) => {
crash(
format!("Failed to create user {}, Error: {}", username, e),
1,
);
}
}
if hasroot { if hasroot {
let return_val = exec_chroot( exec_eval(exec_chroot(
"usermod", "usermod",
vec![ vec![
String::from("-a"), String::from("-a"),
@ -31,17 +20,9 @@ pub fn new_user(username: &str, hasroot: bool, password: &str) {
String::from("wheel"), String::from("wheel"),
String::from(username), String::from(username),
], ],
); ), format!("Add user {} to wheel group", username).as_str());
match return_val {
Ok(_) => {
log(format!("Added user {} to group wheel", username));
}
Err(e) => {
crash(format!("Failed to add user {}, Error: {}", username, e), 1);
}
}
} }
let return_val = exec_chroot( exec_eval(exec_chroot(
"usermod", "usermod",
vec![ vec![
String::from("--password"), String::from("--password"),
@ -54,23 +35,12 @@ pub fn new_user(username: &str, hasroot: bool, password: &str) {
String::from("-stdin)"), String::from("-stdin)"),
String::from(username), String::from(username),
], ],
); ), format!("Set password for user {}", username).as_str());
match return_val {
Ok(_) => {
log(format!("Set password for user {}", username));
}
Err(e) => {
crash(
format!("Failed to set password for user {}, Error: {}", username, e),
1,
);
}
}
} }
pub fn root_pass(root_pass: &str) { pub fn root_pass(root_pass: &str) {
println!("Setting root password to '{}'", root_pass); println!("Setting root password to '{}'", root_pass);
let return_val = exec_chroot( exec_eval(exec_chroot(
"usermod", "usermod",
vec![ vec![
String::from("--password"), String::from("--password"),
@ -83,13 +53,5 @@ pub fn root_pass(root_pass: &str) {
String::from("-stdin)"), String::from("-stdin)"),
String::from("root"), String::from("root"),
], ],
); ), "set root password");
match return_val {
Ok(_) => {
log("Set root password".to_string());
}
Err(e) => {
crash(format!("Failed to set root password, Error: {}", e), 1);
}
}
} }

@ -1,18 +1,18 @@
use std::process::Command; use std::process::Command;
pub fn exec(command: &str, args: Vec<String>) -> Result<std::process::Output, std::io::Error> { pub fn exec(command: &str, args: Vec<String>) -> Result<std::process::ExitStatus, std::io::Error> {
let returncode = Command::new(command).args(args).output(); let returncode = Command::new(command).args(args).status();
returncode returncode
} }
pub fn exec_chroot( pub fn exec_chroot(
command: &str, command: &str,
args: Vec<String>, args: Vec<String>
) -> Result<std::process::Output, std::io::Error> { ) -> Result<std::process::ExitStatus, std::io::Error> {
let returncode = Command::new("arch-chroot") let returncode = Command::new("arch-chroot")
.args(&["/mnt", command]) .args(&["/mnt", command])
.args(args) .args(args)
.output(); .status();
returncode returncode
} }
@ -20,10 +20,10 @@ pub fn exec_workdir(
command: &str, command: &str,
workdir: &str, workdir: &str,
args: Vec<String>, args: Vec<String>,
) -> Result<std::process::Output, std::io::Error> { ) -> Result<std::process::ExitStatus, std::io::Error> {
let returncode = Command::new(command) let returncode = Command::new(command)
.args(args) .args(args)
.current_dir(workdir) .current_dir(workdir)
.output(); .status();
returncode returncode
} }

@ -3,13 +3,13 @@ use std::fs::{File, OpenOptions};
use std::io::prelude::*; use std::io::prelude::*;
pub fn create_file(path: &str) { pub fn create_file(path: &str) {
let return_val = File::create(path); let returncode = File::create(path);
match return_val { match returncode {
Ok(_file) => { Ok(_) => {
log(format!("Created file {}", path)); log(format!("Create {}: Sucess", path));
} }
Err(e) => { Err(e) => {
crash(format!("Failed to create file {}, Error: {}", path, e), 1); crash(format!("Create {}: Failed with error {}", path, e), 1);
} }
} }
} }
@ -21,18 +21,6 @@ pub fn append_file(path: &str, content: &str) -> std::io::Result<()> {
Ok(()) Ok(())
} }
pub fn create_directory(path: &str) { pub fn create_directory(path: &str) -> std::io::Result<()> {
let return_val = std::fs::create_dir(path); std::fs::create_dir(path)
match return_val {
Ok(_) => {
log(format!("Created directory {}", path));
}
Err(e) => {
crash(
format!("Failed to create directory {}, Error: {}", path, e),
1,
);
} }
}
}

@ -2,6 +2,7 @@ pub mod exec;
pub mod files; pub mod files;
pub mod install; pub mod install;
pub mod strings; pub mod strings;
pub mod returncode_eval;
pub fn install(pkgs: Vec<&str>) { pub fn install(pkgs: Vec<&str>) {
install::install(pkgs); install::install(pkgs);
@ -15,6 +16,14 @@ pub fn log(a: String) {
strings::log(a); strings::log(a);
} }
pub fn files_eval(returncode: std::result::Result<(), std::io::Error>, logmsg: &str) {
returncode_eval::files_eval(returncode, logmsg);
}
pub fn exec_eval(returncode: std::result::Result<std::process::ExitStatus, std::io::Error>, logmsg: &str) {
returncode_eval::exec_eval(returncode, logmsg);
}
#[macro_export] #[macro_export]
macro_rules! uwu { macro_rules! uwu {
($x:expr) => {{ ($x:expr) => {{

@ -0,0 +1,23 @@
use crate::internal::*;
pub fn exec_eval(return_code: std::result::Result<std::process::ExitStatus, std::io::Error>, logmsg: &str) {
match &return_code {
Ok(_) => {
log(format!("{}: Success", logmsg));
}
Err(e) => {
crash(format!("{}: Failed with error: {}", logmsg, e), return_code.unwrap_err().raw_os_error().unwrap());
}
}
}
pub fn files_eval(return_code: std::result::Result<(), std::io::Error>, logmsg: &str) {
match &return_code {
Ok(_) => {
log(format!("[ \x1b[2;1;32mOK\x1b[0m ] {}", logmsg));
}
Err(e) => {
crash(format!("[ \x1b[2;1;31mFAILED\x1b[0m ] {} ERROR: {}", logmsg, e), return_code.unwrap_err().raw_os_error().unwrap());
}
}
}

@ -8,6 +8,7 @@ fn main() {
let app = App::new("jade") let app = App::new("jade")
.version(env!("CARGO_PKG_VERSION")) .version(env!("CARGO_PKG_VERSION"))
.about(env!("CARGO_PKG_DESCRIPTION")) .about(env!("CARGO_PKG_DESCRIPTION"))
.author(env!("CARGO_PKG_AUTHORS"))
.subcommand( .subcommand(
SubCommand::with_name("partition") SubCommand::with_name("partition")
.about("Partition the install destination") .about("Partition the install destination")
@ -29,6 +30,32 @@ fn main() {
.takes_value(false), .takes_value(false),
), ),
) )
.subcommand(
SubCommand::with_name("install-base")
.about("Install base packages")
)
.subcommand(
SubCommand::with_name("bootloader")
.about("Install bootloader")
.subcommand(
SubCommand::with_name("grub-efi")
.about("Install grub-efi")
.arg(
Arg::with_name("efidir")
.help("The directory to install the EFI bootloader to")
.required(true),
),
)
.subcommand(
SubCommand::with_name("grub-legacy")
.about("Install grub-legacy")
.arg(
Arg::with_name("device")
.help("The device to install the bootloader to")
.required(true),
),
),
)
.subcommand( .subcommand(
SubCommand::with_name("locale") SubCommand::with_name("locale")
.about("Set locale stuff") .about("Set locale stuff")
@ -58,6 +85,12 @@ fn main() {
.help("The hostname to use") .help("The hostname to use")
.required(true), .required(true),
) )
.arg(
Arg::with_name("create-hosts")
.help("create /etc/hosts")
.long("hosts")
.takes_value(false),
)
.arg( .arg(
Arg::with_name("ipv6") Arg::with_name("ipv6")
.help("Wether ipv6 should be enabled") .help("Wether ipv6 should be enabled")
@ -65,7 +98,7 @@ fn main() {
.long("ipv6") .long("ipv6")
.required(true) .required(true)
.takes_value(false), .takes_value(false),
) ),
) )
.subcommand( .subcommand(
SubCommand::with_name("users") SubCommand::with_name("users")
@ -128,7 +161,8 @@ fn main() {
locale::set_keyboard(kbrlayout); locale::set_keyboard(kbrlayout);
locale::set_timezone(timezn); locale::set_timezone(timezn);
} else if let Some(app) = app.subcommand_matches("networking") { } else if let Some(app) = app.subcommand_matches("networking") {
network::enable_ipv6(app.is_present("ipv6")); if app.is_present("ipv6") { network::enable_ipv6() }
if app.is_present("create-hosts") { network::create_hosts() }
network::set_hostname(app.value_of("hostname").unwrap()) network::set_hostname(app.value_of("hostname").unwrap())
} else if let Some(app) = app.subcommand_matches("users") { } else if let Some(app) = app.subcommand_matches("users") {
if let Some(app) = app.subcommand_matches("newUser") { if let Some(app) = app.subcommand_matches("newUser") {
@ -144,6 +178,14 @@ fn main() {
} }
} else if let Some(app) = app.subcommand_matches("desktops") { } else if let Some(app) = app.subcommand_matches("desktops") {
desktops::choose_pkgs(app.value_of("desktopsetup").unwrap()); desktops::choose_pkgs(app.value_of("desktopsetup").unwrap());
} else if let Some(app) = app.subcommand_matches("bootloader") {
if let Some(app) = app.subcommand_matches("grub-efi") {
base::install_bootloader_efi(app.value_of("efidir").unwrap());
} else if let Some(app) = app.subcommand_matches("grub-legacy") {
base::install_bootloader_legacy(app.value_of("device").unwrap());
}
} else if let Some(_) = app.subcommand_matches("install-base") {
base::install_base_packages();
} else { } else {
println!("Running TUI installer"); println!("Running TUI installer");
} }

Loading…
Cancel
Save