Add info output, make config output more pretty

axtloss/rework-partitioning
Amy 3 years ago
parent 41cc70d62a
commit 3cd7e5768f
No known key found for this signature in database
GPG Key ID: C642EA4B2F4096BE

@ -47,7 +47,7 @@ jade genfstab
### configuring locale settings ### configuring locale settings
```sh ```sh
# set the keyboard layout to colemak, the timezone to Europe/Berlin and set en_US.UTF-8 as the locale # set the keyboard layout to colemak, the timezone to Europe/Berlin and set en_US.UTF-8 as the locale
jade locale colemak Europe/Berlin "en_US.UTF-8 UTF-8" jade locale colemak Europe/Berlin en_US.UTF-8 UTF-8
``` ```
### configue network settings ### configue network settings

Binary file not shown.

@ -90,46 +90,60 @@ pub fn read_config(configpath: &str) {
} }
let config: Config = config.unwrap(); let config: Config = config.unwrap();
println!("---------Setup Partitions---------"); info(format!(
println!("{}", config.partition.device); "Block device to use : /dev/{}",
println!("{}", config.partition.mode); config.partition.device
println!("{}", config.partition.efi); ));
info(format!("Partitioning mode : {}", config.partition.mode));
info(format!("Partitioning for EFI : {}", config.partition.efi));
partition::partition( partition::partition(
config.partition.device.as_str(), format!("/dev/{}", config.partition.device).as_str(),
config.partition.mode.as_str(), config.partition.mode.as_str(),
config.partition.efi, config.partition.efi,
); );
base::install_base_packages(); base::install_base_packages();
base::genfstab(); base::genfstab();
println!("---------Install Bootloader---------"); println!();
println!("{}", config.bootloader.r#type); info(format!(
println!("{}", config.bootloader.location); "Installing bootloader : {}",
config.bootloader.r#type
));
info(format!(
"Installing bootloader to : {}",
config.bootloader.location
));
if config.bootloader.r#type == "grub-efi" { if config.bootloader.r#type == "grub-efi" {
base::install_bootloader_efi(config.bootloader.location.as_str()); base::install_bootloader_efi(config.bootloader.location.as_str());
} else if config.bootloader.r#type == "grub-legacy" { } else if config.bootloader.r#type == "grub-legacy" {
base::install_bootloader_legacy(config.bootloader.location.as_str()); base::install_bootloader_legacy(config.bootloader.location.as_str());
} }
println!("---------Set Locale---------"); println!();
println!("{:?}", config.locale.locale); info(format!("Adding Locales : {:?}", config.locale.locale));
println!("{}", config.locale.keymap); info(format!("Using keymap : {}", config.locale.keymap));
println!("{}", config.locale.timezone); info(format!("Setting timezone : {}", config.locale.timezone));
locale::set_locale(config.locale.locale.join(" ")); locale::set_locale(config.locale.locale.join(" "));
locale::set_keyboard(config.locale.keymap.as_str()); locale::set_keyboard(config.locale.keymap.as_str());
locale::set_timezone(config.locale.timezone.as_str()); locale::set_timezone(config.locale.timezone.as_str());
println!("---------Set Networking---------"); println!();
println!("{}", config.networking.hostname); info(format!("Hostname : {}", config.networking.hostname));
println!("{}", config.networking.ipv6); info(format!("Enabling ipv6 : {}", config.networking.ipv6));
network::set_hostname(config.networking.hostname.as_str()); network::set_hostname(config.networking.hostname.as_str());
network::create_hosts(); network::create_hosts();
if config.networking.ipv6 { if config.networking.ipv6 {
network::enable_ipv6(); network::enable_ipv6();
} }
println!("---------Create Users---------"); println!();
println!("---------"); println!("---------");
for i in 0..config.users.len() { for i in 0..config.users.len() {
println!("{}", config.users[i].name); info(format!("Creating user : {}", config.users[i].name));
println!("{}", config.users[i].password); info(format!(
println!("{}", config.users[i].hasroot); "Setting use password : {}",
config.users[i].password
));
info(format!(
"Enabling root for user : {}",
config.users[i].hasroot
));
users::new_user( users::new_user(
config.users[i].name.as_str(), config.users[i].name.as_str(),
config.users[i].hasroot, config.users[i].hasroot,
@ -137,19 +151,20 @@ pub fn read_config(configpath: &str) {
); );
println!("---------"); println!("---------");
} }
println!("---------Set Rootpass---------"); println!();
println!("{}", config.rootpass); info(format!("Setting root password : {}", config.rootpass));
users::root_pass(config.rootpass.as_str()); users::root_pass(config.rootpass.as_str());
println!("---------Install Desktop---------"); println!();
println!("{}", config.desktop); info(format!("Installing desktop : {}", config.desktop));
desktops::choose_pkgs(config.desktop.as_str()); if config.desktop == "none" || config.desktop.is_empty() {
println!("---------Setup Timeshift---------"); desktops::choose_pkgs(config.desktop.as_str());
println!("{}", config.timeshift); }
println!();
info(format!("Enabling timeshift : {}", config.timeshift));
if config.timeshift { if config.timeshift {
base::setup_timeshift(); base::setup_timeshift();
} }
println!("---------Install Extra packages---------"); info(format!("Extra packages : {:?}", config.extra_packages));
println!("{:?}", config.extra_packages);
let mut extra_packages: Vec<&str> = Vec::new(); let mut extra_packages: Vec<&str> = Vec::new();
for i in 0..config.extra_packages.len() { for i in 0..config.extra_packages.len() {
extra_packages.push(config.extra_packages[i].as_str()); extra_packages.push(config.extra_packages[i].as_str());

@ -17,6 +17,9 @@ pub fn log(a: String) {
strings::log(a); strings::log(a);
} }
pub fn info(a: String) {
strings::info(a);
}
pub fn files_eval(returncode: std::result::Result<(), std::io::Error>, logmsg: &str) { pub fn files_eval(returncode: std::result::Result<(), std::io::Error>, logmsg: &str) {
returncode_eval::files_eval(returncode, logmsg); returncode_eval::files_eval(returncode, logmsg);
} }

@ -10,7 +10,7 @@ pub fn exec_eval(
} }
Err(e) => { Err(e) => {
crash( crash(
format!("{} ERROR: {}", logmsg, e), format!("[ \x1b[2;1;32mFAILED\x1b[0m ] {} ERROR: {}", logmsg, e),
return_code.unwrap_err().raw_os_error().unwrap(), return_code.unwrap_err().raw_os_error().unwrap(),
); );
} }
@ -24,7 +24,7 @@ pub fn files_eval(return_code: std::result::Result<(), std::io::Error>, logmsg:
} }
Err(e) => { Err(e) => {
crash( crash(
format!("{} ERROR: {}", logmsg, e), format!("[ \x1b[2;1;32mFAILED\x1b[0m ] {} ERROR: {}", logmsg, e),
return_code.unwrap_err().raw_os_error().unwrap(), return_code.unwrap_err().raw_os_error().unwrap(),
); );
} }

@ -10,7 +10,7 @@ pub fn crash(a: String, b: i32) {
} else { } else {
a a
}; };
println!("[ \x1b[2;1;32mOK\x1b[0m ] {}", a); println!("{}", a);
exit(b); exit(b);
} }
pub fn log(a: String) { pub fn log(a: String) {
@ -22,7 +22,22 @@ pub fn log(a: String) {
a a
}; };
eprintln!( eprintln!(
"{} {}", "[ \x1b[2;1;33mLOG\x1b[0m ] {} {}",
std::time::SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_secs(),
a
);
}
pub fn info(a: String) {
let a = if env::var("JADE_UWU").unwrap_or_else(|_| "".to_string()) == "true" {
uwu!(&a)
} else {
a
};
eprintln!(
"[ \x1b[2;1;39mINFO\x1b[0m ] {} {}",
std::time::SystemTime::now() std::time::SystemTime::now()
.duration_since(UNIX_EPOCH) .duration_since(UNIX_EPOCH)
.unwrap() .unwrap()

Loading…
Cancel
Save