Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Commit

Permalink
locale: Fixed locale
Browse files Browse the repository at this point in the history
yeah, the timezone link should of never been ran on the host system as
that means your timezone wont work as /mnt/usr/share/zoneinfo won't
exist on the installed system

and i fixed up the set_locale function so it actually uses the locale
you gave to it instead of using the hardcoded en_US.UTF-8 value
  • Loading branch information
Fries committed Sep 15, 2022
1 parent 7914d49 commit 0d88af4
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/functions/locale.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ use crate::internal::*;

pub fn set_timezone(timezone: &str) {
exec_eval(
exec(
// Remember this should run in a chroot
// not on the host, as linking to /mnt/usr/share/zoneinfo
// is a bad idea as your timezone wont work
exec_chroot(
"ln",
vec![
"-sf".to_string(),
format!("/mnt/usr/share/zoneinfo/{}", timezone),
"/mnt/etc/localtime".to_string(),
format!("/usr/share/zoneinfo/{}", timezone),
"/etc/localtime".to_string(),
],
),
"Set timezone",
Expand All @@ -20,29 +23,26 @@ pub fn set_timezone(timezone: &str) {
}

pub fn set_locale(locale: String) {
files_eval(
files::append_file("/mnt/etc/locale.gen", "en_US.UTF-8 UTF-8\n"),
"add en_US.UTF-8 UTF-8 to locale.gen",
);
// TODO: Refactor this
for i in (0..locale.split(' ').count()).step_by(2) {
files_eval(
files::append_file(
"/mnt/etc/locale.gen",
format!(
&format!(
"{} {}\n",
locale.split(' ').collect::<Vec<&str>>()[i],
locale.split(' ').collect::<Vec<&str>>()[i + 1]
)
.as_str(),
),
),
"add locales to locale.gen",
);
}
exec_eval(exec_chroot("locale-gen", vec![]), "generate locales");
files::create_file("/mnt/etc/locale.conf");
files_eval(
files::append_file("/mnt/etc/locale.conf", "LANG=en_US.UTF-8"),
files::append_file(
"/mnt/etc/locale.conf",
&format!("LANG={}", locale.split(' ').collect::<Vec<&str>>()[0]),
),
"edit locale.conf",
);
}
Expand Down

0 comments on commit 0d88af4

Please sign in to comment.