axtloss/rework-partitioning
amy 3 years ago
parent 09573dd0b1
commit 3dba94d714

@ -200,7 +200,7 @@ fn part_disk(device: &str, efi: bool) {
format!("format {}1 as fat32", device).as_str(),
);
exec_eval(
exec("mkfs.btrfs", vec![format!("{}2", device)]),
exec("mkfs.btrfs", vec!["-f".to_string(), format!("{}2", device)]),
format!("format {}2 as btrfs", device).as_str(),
);
mount(format!("{}2", device).as_str(), "/mnt", "");
@ -244,7 +244,7 @@ fn part_disk(device: &str, efi: bool) {
format!("format {}1 as ext4", device).as_str(),
);
exec_eval(
exec("mkfs.btrfs", vec![format!("{}2", device)]),
exec("mkfs.btrfs", vec!["-f".to_string(), format!("{}2", device)]),
format!("format {}2 as btrfs", device).as_str(),
);
mount(format!("{}2", device).as_str(), "/mnt/", "");
@ -288,23 +288,39 @@ fn part_disk(device: &str, efi: bool) {
}
fn mount(partition: &str, mountpoint: &str, options: &str) {
let options = if options.is_empty() { "\"\"" } else { options };
exec_eval(
exec(
"mount",
vec![
String::from(partition),
String::from(mountpoint),
String::from("-o"),
String::from(options),
],
),
format!(
"mount {} with options {} at {}",
partition, options, mountpoint
)
.as_str(),
);
if !options.is_empty() {
exec_eval(
exec(
"mount",
vec![
String::from(partition),
String::from(mountpoint),
String::from("-o"),
String::from(options),
],
),
format!(
"mount {} with options {} at {}",
partition, options, mountpoint
)
.as_str(),
);
} else {
exec_eval(
exec(
"mount",
vec![
String::from(partition),
String::from(mountpoint),
],
),
format!(
"mount {} with no options at {}",
partition, mountpoint
)
.as_str(),
);
}
}
fn umount(mountpoint: &str) {

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

@ -10,7 +10,7 @@ pub fn crash(a: String, b: i32) {
} else {
a
};
println!("\x1b[2;22;31m❌:\x1b[0m \x1b[1;91m{}\x1b[0m", a);
println!("[ \x1b[2;1;32mOK\x1b[0m ] {}", a);
exit(b);
}
pub fn log(a: String) {

Loading…
Cancel
Save