From 4d121cf36805eefb58c4b25827b94dcc57c2ca3d Mon Sep 17 00:00:00 2001 From: amy Date: Sun, 23 Jan 2022 21:13:18 +0100 Subject: [PATCH] dont use crystalstrap anymore --- src/functions/base.rs | 11 +++++++---- src/internal/files.rs | 18 ++++++++++++++++++ src/internal/install.rs | 4 +++- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/functions/base.rs b/src/functions/base.rs index 04eafb3..be68a13 100755 --- a/src/functions/base.rs +++ b/src/functions/base.rs @@ -2,6 +2,7 @@ use crate::internal::exec::*; use crate::internal::*; pub fn install_base_packages() { + files::copy_file("/etc/pacman.conf", "/mnt/etc/pacman.conf"); install::install(vec![ "base", "linux", @@ -25,11 +26,13 @@ pub fn install_base_packages() { pub fn genfstab() { exec_eval( - exec_chroot( - "bash", + exec( + "genfstab", vec![ - String::from("-c"), - String::from("'genfstab -U /mnt >> /mnt/etc/fstab'"), + String::from("-U"), + String::from("/mnt"), + String::from(">>"), + String::from("/mnt/etc/fstab"), ], ), "Generate fstab", diff --git a/src/internal/files.rs b/src/internal/files.rs index fc0bd17..5eacf28 100755 --- a/src/internal/files.rs +++ b/src/internal/files.rs @@ -14,6 +14,24 @@ pub fn create_file(path: &str) { } } +pub fn copy_file(path: &str, destpath: &str) { + let return_code = std::fs::copy(path, destpath); + match return_code { + Ok(_) => { + log(format!( + "[ \x1b[2;1;32mOK\x1b[0m ] Copy {} to {}", + path, destpath + )); + } + Err(e) => { + crash( + format!("Copy {} to {}: Failed with error {}", path, destpath, e), + 1, + ); + } + } +} + pub fn append_file(path: &str, content: &str) -> std::io::Result<()> { log(format!( "[ \x1b[2;1;32mOK\x1b[0m ] Append '{}' to file {}", diff --git a/src/internal/install.rs b/src/internal/install.rs index 877995e..d538ef8 100755 --- a/src/internal/install.rs +++ b/src/internal/install.rs @@ -3,8 +3,10 @@ use std::process::Command; pub fn install(pkgs: Vec<&str>) { exec_eval( - Command::new("crystalstrap") + Command::new("pacstrap") .arg("/mnt") + .arg("-C") + .arg("/etc/pacman.conf") .args(&pkgs) .status(), format!("Install packages {}", pkgs.join(", ")).as_str(),