Commit 9d4bd376 authored by udeved's avatar udeved

mkchroot: simplify locale handling

parent 2ec2daaf
......@@ -109,7 +109,7 @@ basestrap "${basestrap_args[@]}" "$working_dir" ${cache_dirs[@]/#/--cachedir=} "
echo "$version" > "$working_dir/.manjaro-tools"
set_locale "$working_dir"
default_locale "set" "$working_dir"
chroot_args=(${pacman_conf:+-C "$pacman_conf"} ${makepkg_conf:+-M "$makepkg_conf"} ${cache_dir:+-c "$cache_dir"})
${nosetarch} && chroot_args+=(${nosetarch:+-s})
......
......@@ -44,25 +44,26 @@ subvolume_delete_recursive() {
return 0
}
set_locale(){
local mnt="$1"
if [[ ! -f "$mnt/etc/locale.gen.bak" ]] && [[ ! -f "$mnt/etc/locale.conf.bak" ]];then
info "Setting locale ..."
mv "$mnt/etc/locale.gen" "$mnt/etc/locale.gen.bak"
mv "$mnt/etc/locale.conf" "$mnt/etc/locale.conf.bak"
printf '%s.UTF-8 UTF-8\n' en_US > "$mnt/etc/locale.gen"
printf 'LANG=%s.UTF-8\n' en_US > "$mnt/etc/locale.conf"
printf 'LC_MESSAGES=C\n' >> "$mnt/etc/locale.conf"
default_locale(){
local action="$1" mnt="$2"
if [[ $action == "set" ]];then
if [[ ! -f "$mnt/etc/locale.gen.bak" ]] && [[ ! -f "$mnt/etc/locale.conf.bak" ]];then
info "Setting locale ..."
mv "$mnt/etc/locale.gen" "$mnt/etc/locale.gen.bak"
mv "$mnt/etc/locale.conf" "$mnt/etc/locale.conf.bak"
printf '%s.UTF-8 UTF-8\n' en_US > "$mnt/etc/locale.gen"
printf 'LANG=%s.UTF-8\n' en_US > "$mnt/etc/locale.conf"
printf 'LC_MESSAGES=C\n' >> "$mnt/etc/locale.conf"
fi
elif [[ $action == "reset" ]];then
if [[ -f "$mnt/etc/locale.gen.bak" ]] && [[ -f "$mnt/etc/locale.conf.bak" ]];then
info "Resetting locale ..."
mv "$mnt/etc/locale.gen.bak" "$mnt/etc/locale.gen"
mv "$mnt/etc/locale.conf.bak" "$mnt/etc/locale.conf"
fi
fi
}
reset_locale(){
local mnt="$1"
info "Resetting locale ..."
[[ -f "$mnt/etc/locale.gen.bak" ]] && mv "$mnt/etc/locale.gen.bak" "$mnt/etc/locale.gen"
[[ -f "$mnt/etc/locale.conf.bak" ]] && mv "$mnt/etc/locale.conf.bak" "$mnt/etc/locale.conf"
}
create_chroot(){
local timer=$(get_timer)
setarch "${target_arch}" \
......
......@@ -169,7 +169,7 @@ clean_up_image(){
find "$path" -mindepth 0 -delete &> /dev/null
fi
else
reset_locale "$mnt"
default_locale "reset" "$mnt"
path=$mnt/boot
if [[ -d "$path" ]]; then
find "$path" -name 'initramfs*.img' -delete &> /dev/null
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment