diff --git a/Cargo.toml b/Cargo.toml index 32fa6e4..d08db40 100755 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,7 @@ [package] name = "jade" +description = "The new installer for crystal linux, contains backend and TUI" +authors = ["Amy "] version = "0.1.0" edition = "2021" diff --git a/src/functions/partition.rs b/src/functions/partition.rs index 257986f..f31d4fc 100755 --- a/src/functions/partition.rs +++ b/src/functions/partition.rs @@ -83,11 +83,11 @@ fn part_nvme(device: &str, efi: bool) { if efi { returncode_eval(exec( "mkfs.vfat", - vec![String::from(format!("{}p1", device))], + vec![format!("{}p1", device)], )); returncode_eval(exec( "mkfs.btrfs", - vec![String::from(format!("{}p2", device))], + vec![format!("{}p2", device)], )); mount(format!("{}p2", device), "/mnt", ""); returncode_eval(exec_workdir( @@ -118,11 +118,11 @@ fn part_nvme(device: &str, efi: bool) { } else { returncode_eval(exec( "mkfs.ext4", - vec![String::from(format!("{}p1", device))], + vec![format!("{}p1", device)], )); returncode_eval(exec( "mkfs.btrfs", - vec![String::from(format!("{}p2", device))], + vec![format!("{}p2", device)], )); mount(format!("{}p2", device), "/mnt/", ""); returncode_eval(exec_workdir( @@ -156,11 +156,11 @@ fn part_disk(device: &str, efi: bool) { if efi { returncode_eval(exec( "mkfs.vfat", - vec![String::from(format!("{}1", device))], + vec![format!("{}1", device)], )); returncode_eval(exec( "mkfs.btrfs", - vec![String::from(format!("{}2", device))], + vec![format!("{}2", device)], )); mount(format!("{}2", device), "/mnt", ""); returncode_eval(exec_workdir( @@ -191,11 +191,11 @@ fn part_disk(device: &str, efi: bool) { } else { returncode_eval(exec( "mkfs.ext4", - vec![String::from(format!("{}1", device))], + vec![format!("{}1", device)], )); returncode_eval(exec( "mkfs.btrfs", - vec![String::from(format!("{}2", device))], + vec![format!("{}2", device)], )); mount(format!("{}2", device), "/mnt/", ""); returncode_eval(exec_workdir( @@ -230,7 +230,7 @@ fn mount(partition: String, mountpoint: &str, options: &str) { returncode_eval(exec( "mount", vec![ - String::from(partition), + partition, String::from(mountpoint), String::from("-o"), String::from(options), diff --git a/src/functions/users.rs b/src/functions/users.rs index 1890937..7241acf 100755 --- a/src/functions/users.rs +++ b/src/functions/users.rs @@ -46,7 +46,7 @@ pub fn new_user(username: &str, hasroot: bool, password: &str) { vec![ String::from("--password"), String::from("$(echo"), - String::from(format!("${}", password)), + format!("${}", password), String::from("|"), String::from("openssl"), String::from("passwd"), @@ -75,7 +75,7 @@ pub fn root_pass(root_pass: &str) { vec![ String::from("--password"), String::from("$(echo"), - String::from(format!("${{{}}}", root_pass)), + format!("${{{}}}", root_pass), String::from("|"), String::from("openssl"), String::from("passwd"), diff --git a/src/internal/files.rs b/src/internal/files.rs index bf288a5..5ea20c9 100755 --- a/src/internal/files.rs +++ b/src/internal/files.rs @@ -17,22 +17,10 @@ pub fn create_file(path: &str) { pub fn append_file(path: &str, content: &str) -> std::io::Result<()> { log(format!("Appending {} to file {}", content, path)); let mut file = OpenOptions::new().append(true).open(path)?; - file.write(content.as_bytes())?; + file.write_all(content.as_bytes())?; Ok(()) } -pub fn delete_file(path: &str) { - let return_val = std::fs::remove_file(path); - match return_val { - Ok(_) => { - log(format!("Deleted file {}", path)); - } - Err(e) => { - crash(format!("Failed to delete file {}, Error: {}", path, e), 1); - } - } -} - pub fn create_directory(path: &str) { let return_val = std::fs::create_dir(path); match return_val { @@ -48,19 +36,3 @@ pub fn create_directory(path: &str) { } } -pub fn overwrite_file(path: &str, content: &str) { - delete_file(path); - create_file(path); - let return_val = append_file(path, content); - match return_val { - Ok(_) => { - log(format!("Overwrote file {}", path)); - } - Err(e) => { - crash( - format!("Failed to overwrite file {}, Error: {}", path, e), - 1, - ); - } - } -} diff --git a/src/internal/mod.rs b/src/internal/mod.rs index dc2da91..c597e23 100755 --- a/src/internal/mod.rs +++ b/src/internal/mod.rs @@ -7,10 +7,6 @@ pub fn install(pkgs: Vec<&str>) { install::install(pkgs); } -pub fn info(a: String) { - strings::info(a); -} - pub fn crash(a: String, b: i32) { strings::crash(a, b); } diff --git a/src/internal/strings.rs b/src/internal/strings.rs index 21a244a..a276eb8 100755 --- a/src/internal/strings.rs +++ b/src/internal/strings.rs @@ -3,14 +3,7 @@ use std::env; use std::process::exit; use std::str::FromStr; use std::time::UNIX_EPOCH; -pub fn info(a: String) { - let a = if env::var("JADE_UWU").unwrap_or_else(|_| "".to_string()) == "true" { - uwu!(&a) - } else { - a - }; - println!("\x1b[2;22;35m❖\x1b[0m \x1b[1;37m{}\x1b[0m", a) -} + pub fn crash(a: String, b: i32) { let a = if env::var("JADE_UWU").unwrap_or_else(|_| "".to_string()) == "true" { uwu!(&a)