This commit is contained in:
JMARyA 2024-12-28 05:14:29 +01:00
parent 17a137e47c
commit 4a70ffa906
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
6 changed files with 49 additions and 21 deletions

View file

@ -1,31 +1,49 @@
// GENFSTAB
use crate::{config::GeneralConfig, run_command};
use crate::{config::GeneralConfig, print_status, run_command};
use super::{str_vec, uncomment_first_value_of};
pub fn genfstab() {
print_status("Generating fstab");
let (stdout, _) = run_command(&str_vec(vec!["genfstab", "-U", "/mnt"]), None, false);
std::fs::write("/mnt/etc/fstab", stdout).unwrap();
}
pub fn first_boot_values(conf: &GeneralConfig) {
// CHROOT
run_command(
&vec![
"arch-chroot".into(),
"/mnt".into(),
"systemd-firstboot".into(),
format!("--locale={}", conf.locale),
format!("--keymap={}", conf.keymap),
format!("--timezone={}", conf.timezone),
format!("--hostname={}", conf.hostname),
],
None,
false,
);
// Locale
print_status(&format!("Setting locale {}", conf.locale));
std::fs::write(
"/mnt/etc/locale.conf",
format!("LANG=\"{}\"\n", conf.locale),
)
.unwrap();
// Timezone
print_status(&format!("Setting timezone {}", conf.timezone));
let tz_paths = conf.timezone.split('/').collect::<Vec<&str>>();
let mut tz_link = std::path::PathBuf::from("/usr/share/zoneinfo/");
for path in tz_paths {
tz_link.push(path);
}
std::os::unix::fs::symlink(tz_link, "/mnt/etc/localtime").unwrap();
// Keymap
print_status("Writing /etc/vconsole.conf");
std::fs::write(
"/mnt/etc/vconsole.conf",
format!("KEYMAP=\"{}\"", conf.keymap),
)
.unwrap();
// Hostname
print_status("Writing /etc/hostname");
std::fs::write("/mnt/etc/hostname", format!("{}\n", conf.hostname)).unwrap();
// LOCALE
print_status("Setting locale");
uncomment_first_value_of(&conf.locale, "/mnt/etc/locale.gen");
run_command(
&str_vec(vec!["arch-chroot", "/mnt", "locale-gen"]),