V8.00.000.2025.06.17
Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
This commit is contained in:
@@ -442,30 +442,21 @@ locale:
|
|||||||
layout: "de"
|
layout: "de"
|
||||||
xkb_keymap: "de"
|
xkb_keymap: "de"
|
||||||
language: "en"
|
language: "en"
|
||||||
locale: "en_US.UTF-8"
|
locale: # All locales specified via override MUST be set here, too.
|
||||||
|
- "en_US.UTF-8"
|
||||||
|
- "de_DE.UTF-8"
|
||||||
override:
|
override:
|
||||||
# Address format:
|
address: "de_DE.UTF-8" # Address format.
|
||||||
address: "de_DE.UTF-8"
|
collate: "en_US.UTF-8" # Sort order.
|
||||||
# Sort order:
|
ctype: "de_DE.UTF-8" # Character set, upper/lower case, character groups.
|
||||||
collate: "en_US.UTF-8"
|
measurement: "de_DE.UTF-8" # Metric or imperial system.
|
||||||
# Character set, upper/lower case, character groups:
|
messages: "en_US.UTF-8" # System language for error messages.
|
||||||
ctype: "de_DE.UTF-8"
|
monetary: "en_US.UTF-8" # Currency format and symbol.
|
||||||
# Metric or imperial system:
|
name: "en_US.UTF-8" # Format of personal names.
|
||||||
measurement: "de_DE.UTF-8"
|
numeric: "en_US.UTF-8" # Number formatting, decimal/thousand separators.
|
||||||
# System language for error messages:
|
paper: "de_DE.UTF-8" # Standard paper format.
|
||||||
messages: "en_US.UTF-8"
|
telephone: "en_US.UTF-8" # Format for telephone numbers.
|
||||||
# Currency format and symbol:
|
time: "de_DE.UTF-8" # Date and time format, start of week.
|
||||||
monetary: "en_US.UTF-8"
|
|
||||||
# Format of personal names:
|
|
||||||
name: "en_US.UTF-8"
|
|
||||||
# Number formatting, decimal/thousand separators:
|
|
||||||
numeric: "en_US.UTF-8"
|
|
||||||
# Standard paper format:
|
|
||||||
paper: "de_DE.UTF-8"
|
|
||||||
# Format for telephone numbers:
|
|
||||||
telephone: "en_US.UTF-8"
|
|
||||||
# Date and time format, start of week:
|
|
||||||
time: "de_DE.UTF-8"
|
|
||||||
timezone: "Europe/Lisbon"
|
timezone: "Europe/Lisbon"
|
||||||
|
|
||||||
################################################################################################################################
|
################################################################################################################################
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ guard_sourcing
|
|||||||
# Parsing './.preseed/preseed.yaml' and './.preseed/partitioning.yaml'.
|
# Parsing './.preseed/preseed.yaml' and './.preseed/partitioning.yaml'.
|
||||||
# Globals:
|
# Globals:
|
||||||
# ARY_BOOTPARAM
|
# ARY_BOOTPARAM
|
||||||
|
# ARY_LOCALE
|
||||||
# ARY_NTPSRVR
|
# ARY_NTPSRVR
|
||||||
# ARY_PACKAGES
|
# ARY_PACKAGES
|
||||||
# BASH_REMATCH
|
# BASH_REMATCH
|
||||||
@@ -31,7 +32,7 @@ guard_sourcing
|
|||||||
yaml_parser() {
|
yaml_parser() {
|
||||||
### Declare Arrays, HashMaps, and Variables.
|
### Declare Arrays, HashMaps, and Variables.
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
declare -ag ARY_BOOTPARAM=() ARY_NTPSRVR=() ARY_PACKAGES=()
|
declare -ag ARY_BOOTPARAM=() ARY_LOCALE=() ARY_NTPSRVR=() ARY_PACKAGES=()
|
||||||
declare -gix VAR_USER_MAX=0
|
declare -gix VAR_USER_MAX=0
|
||||||
declare var_index="" var_key="" var_value=""
|
declare var_index="" var_key="" var_value=""
|
||||||
|
|
||||||
@@ -39,13 +40,14 @@ yaml_parser() {
|
|||||||
|
|
||||||
yq -o=shell "${DIR_TMP}/combined.yaml" >| "${VAR_PRESEED}"
|
yq -o=shell "${DIR_TMP}/combined.yaml" >| "${VAR_PRESEED}"
|
||||||
|
|
||||||
### Generate Arrays for [Grub Parameter], [NTPSec Server FQDN], [Software Packages].
|
### Generate Arrays for [Grub Parameter], [Locales], [NTPSec Server FQDN], [Software Packages].
|
||||||
while IFS='=' read -r var_key var_value; do
|
while IFS='=' read -r var_key var_value; do
|
||||||
var_value=${var_value#\'}
|
var_value=${var_value#\'}
|
||||||
var_value=${var_value%\'}
|
var_value=${var_value%\'}
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
case "${var_key}" in
|
case "${var_key}" in
|
||||||
grub_parameter_[0-9]*) ARY_BOOTPARAM+=("${var_value}") ;;
|
grub_parameter_[0-9]*) ARY_BOOTPARAM+=("${var_value}") ;;
|
||||||
|
locale_locale_[0-9]*) ARY_LOCALE+=("${var_value}") ;;
|
||||||
ntp_server_[0-9]*) ARY_NTPSRVR+=("${var_value}") ;;
|
ntp_server_[0-9]*) ARY_NTPSRVR+=("${var_value}") ;;
|
||||||
software_[0-9]*) ARY_PACKAGES+=("${var_value}") ;;
|
software_[0-9]*) ARY_PACKAGES+=("${var_value}") ;;
|
||||||
esac
|
esac
|
||||||
@@ -62,6 +64,7 @@ yaml_parser() {
|
|||||||
|
|
||||||
### Delete the respective 'key:value'-variables in the global variable set.
|
### Delete the respective 'key:value'-variables in the global variable set.
|
||||||
sed -i '/^grub_parameter_[0-9]\+=/d' "${VAR_PRESEED}"
|
sed -i '/^grub_parameter_[0-9]\+=/d' "${VAR_PRESEED}"
|
||||||
|
sed -i '/^locale_locale_[0-9]\+=/d' "${VAR_PRESEED}"
|
||||||
sed -i '/^ntp_server_[0-9]\+=/d' "${VAR_PRESEED}"
|
sed -i '/^ntp_server_[0-9]\+=/d' "${VAR_PRESEED}"
|
||||||
sed -i '/^software_[0-9]\+=/d' "${VAR_PRESEED}"
|
sed -i '/^software_[0-9]\+=/d' "${VAR_PRESEED}"
|
||||||
|
|
||||||
|
|||||||
@@ -45,8 +45,8 @@ setup_locales() {
|
|||||||
|
|
||||||
### Give priority to '${locale_locale}' over separately configured variables '${locale_country}' and '${locale_language}'.
|
### Give priority to '${locale_locale}' over separately configured variables '${locale_country}' and '${locale_language}'.
|
||||||
### If 'locale_locale' is not set, build it from 'locale_language' and 'locale_country'.
|
### If 'locale_locale' is not set, build it from 'locale_language' and 'locale_country'.
|
||||||
if [[ -n "${locale_language:-}" && -n "${locale_country:-}" && -z "${locale_locale:-}" ]]; then
|
if [[ -n "${locale_language:-}" && -n "${locale_country:-}" && -z "${ARY_LOCALE[0]:-}" ]]; then
|
||||||
declare locale_locale="${locale_language}_${locale_country}.UTF-8"
|
ARY_LOCALE+="${locale_language}_${locale_country}.UTF-8"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
### Creat Hook in target.
|
### Creat Hook in target.
|
||||||
@@ -67,34 +67,53 @@ set -x
|
|||||||
exec 2>/tmp/locale-hook-debug.log
|
exec 2>/tmp/locale-hook-debug.log
|
||||||
set -Ceuo pipefail
|
set -Ceuo pipefail
|
||||||
|
|
||||||
echo "locales locales/locales_to_be_generated multiselect ${locale_locale:-en_US.UTF-8} UTF-8" | debconf-set-selections
|
declare -a ary_locale=()
|
||||||
echo "locales locales/default_environment_locale select ${locale_locale:-en_US.UTF-8}" | debconf-set-selections
|
declare -r locale_0=${ARY_LOCALE[0]:-en_US.UTF-8}
|
||||||
|
declare -r locale_1=${ARY_LOCALE[1]:-}
|
||||||
|
declare loc=""
|
||||||
|
|
||||||
if ! grep -qx "${locale_locale:-en_US.UTF-8} UTF-8" /etc/locale.gen; then
|
EOF
|
||||||
sed -i "s/# ${locale_locale:-en_US.UTF-8} UTF-8/${locale_locale:-en_US.UTF-8} UTF-8/" /etc/locale.gen || \
|
|
||||||
echo "${locale_locale:-en_US.UTF-8} UTF-8" >> /etc/locale.gen
|
|
||||||
fi
|
|
||||||
|
|
||||||
locale-gen --purge "${locale_locale:-en_US.UTF-8}"
|
cat << 'EOF' >> "${TARGET}${var_locale_hook}"
|
||||||
|
ary_locale+=( "${locale_0}" )
|
||||||
|
[[ -n "${locale_1}" ]] && ary_locale+=( "${locale_1}" )
|
||||||
|
|
||||||
|
for loc in "${ary_locale[@]}"; do
|
||||||
|
if ! grep -qx "${loc} UTF-8" /etc/locale.gen; then
|
||||||
|
sed -i "s/^# ${loc} UTF-8/${loc} UTF-8/" /etc/locale.gen || echo "${loc} UTF-8" >> /etc/locale.gen
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
locale-gen --purge "${ary_locale[@]}"
|
||||||
|
|
||||||
|
for loc in "${ary_locale[@]}"; do
|
||||||
|
locale_check=$(echo "${loc}" | sed 's/UTF-8/utf8/')
|
||||||
|
if ! locale -a | grep -qx "${locale_check}"; then
|
||||||
|
echo "Locale '${loc}' has not been generated successfully." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat << EOF >> "${TARGET}${var_locale_hook}"
|
||||||
update-locale \
|
update-locale \
|
||||||
LANG=${locale_locale} \
|
LANG=${ARY_LOCALE[0]} \
|
||||||
LC_ADDRESS=${locale_override_address:-${locale_locale}} \
|
LC_ADDRESS=${locale_override_address:-${ARY_LOCALE[0]}} \
|
||||||
LC_COLLATE=${locale_override_collate:-${locale_locale}} \
|
LC_COLLATE=${locale_override_collate:-${ARY_LOCALE[0]}} \
|
||||||
LC_CTYPE=${locale_override_ctype:-${locale_locale}} \
|
LC_CTYPE=${locale_override_ctype:-${ARY_LOCALE[0]}} \
|
||||||
LC_MEASUREMENT=${locale_override_measurement:-${locale_locale}} \
|
LC_MEASUREMENT=${locale_override_measurement:-${ARY_LOCALE[0]}} \
|
||||||
LC_MESSAGES=${locale_override_messages:-${locale_locale}} \
|
LC_MESSAGES=${locale_override_messages:-${ARY_LOCALE[0]}} \
|
||||||
LC_MONETARY=${locale_override_monetary:-${locale_locale}} \
|
LC_MONETARY=${locale_override_monetary:-${ARY_LOCALE[0]}} \
|
||||||
LC_NAME=${locale_override_name:-${locale_locale}} \
|
LC_NAME=${locale_override_name:-${ARY_LOCALE[0]}} \
|
||||||
LC_NUMERIC=${locale_override_numeric:-${locale_locale}} \
|
LC_NUMERIC=${locale_override_numeric:-${ARY_LOCALE[0]}} \
|
||||||
LC_PAPER=${locale_override_paper:-${locale_locale}} \
|
LC_PAPER=${locale_override_paper:-${ARY_LOCALE[0]}} \
|
||||||
LC_TELEPHONE=${locale_override_telephone:-${locale_locale}} \
|
LC_TELEPHONE=${locale_override_telephone:-${ARY_LOCALE[0]}} \
|
||||||
LC_TIME=${locale_override_time:-${locale_locale}} \
|
LC_TIME=${locale_override_time:-${ARY_LOCALE[0]}} \
|
||||||
LC_IDENTIFICATION=${locale_locale}
|
LC_IDENTIFICATION=${ARY_LOCALE[0]}
|
||||||
|
|
||||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
chmod 0700 "${TARGET}${var_locale_hook}"
|
chmod 0700 "${TARGET}${var_locale_hook}"
|
||||||
do_in_target_script "${TARGET}" "${var_locale_hook}"
|
do_in_target_script "${TARGET}" "${var_locale_hook}"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user