Generate locale (fix #19)

This commit is contained in:
Roey Darwish Dror 2019-05-27 14:15:40 +03:00
parent 2a987be160
commit 0492847d51
2 changed files with 21 additions and 0 deletions

View File

@ -67,6 +67,9 @@ pub enum ErrorKind {
#[fail(display = "Error closing the encrypted device")]
LuksClose,
#[fail(display = "Error setting the locale")]
Locale,
}
impl Fail for Error {

View File

@ -213,6 +213,24 @@ fn create(command: CreateCommand) -> Result<(), Error> {
)
.context(ErrorKind::PostInstallation)?;
info!("Setting locale");
fs::OpenOptions::new()
.append(true)
.write(true)
.open(mount_point.path().join("etc/locale.gen"))
.and_then(|mut locale_gen| locale_gen.write_all(b"en_US.UTF-8 UTF-8\n"))
.context(ErrorKind::Locale)?;
fs::write(
mount_point.path().join("etc/locale.conf"),
"LANG=en_US.UTF-8",
)
.context(ErrorKind::Locale)?;
arch_chroot
.execute()
.arg(mount_point.path())
.arg("locale-gen")
.run(ErrorKind::Locale)?;
info!("Generating initramfs");
fs::write(mount_point.path().join("etc/mkinitcpio.conf"), MKINITCPIO)
.context(ErrorKind::Initramfs)?;