Compare commits

..

No commits in common. "781d907b078ae3006828b09cb11e8a1c31dc3783" and "7c181c84fb39f08fdc7d8a845b4ac269fc1045dd" have entirely different histories.

2 changed files with 101 additions and 142 deletions

View file

@ -221,7 +221,6 @@ Handle project workflows in a unified way:
#### Shell #### Shell
* command to echo & run
* comment * comment
* handle errors * handle errors
* packages * packages
@ -236,10 +235,7 @@ Handle project workflows in a unified way:
* opensuse * opensuse
* opensuse * opensuse
* disable & enable https * disable & enable https
* locales * persist locales
* persist
* restrict LC_* variables set for alpine
* test LC_* variables
* test * test
#### Shell → Python #### Shell → Python

View file

@ -377,6 +377,81 @@ spcd_txt_get() {
esac esac
} }
spcd_txt_locale() {
locale
spcd_split
local value name
if [ -n "${1}" ]; then
value="${1}"
else
value="${_SPCD_TXT_LOCALE_DEFAULT}"
fi
value="${value}.${_SPCD_TXT_CHARSET}"
set -- \
"LANG" \
"LC_CTYPE" \
"LC_NUMERIC" \
"LC_TIME" \
"LC_COLLATE" \
"LC_MONETARY" \
"LC_MESSAGES" \
"LC_PAPER" \
"LC_NAME" \
"LC_ADDRESS" \
"LC_TELEPHONE" \
"LC_MEASUREMENT" \
"LC_IDENTIFICATION"
for name in "${@}"; do
export "${name}=${value}"
done
spcd_split
locale
}
spcd_txt_locales_echo() {
case "${1}" in
"LANGUAGE") spcd_os_printenv "LANGUAGE" ;;
*) locale -a ;;
esac
}
spcd_txt_locales() {
set -- \
"${SPCD_TXT_LOCALE_ENGLISH}" \
"${SPCD_TXT_LOCALE_FRENCH}"
local language locale text
spcd_txt_locales_echo
spcd_split
for locale in "${@}"; do
case "${1}" in
"glibc-langpack-")
language="$(echo "${locale}" | cut -d _ -f 1)"
spcd_install_package "glibc-langpack-${language}"
;;
"LANGUAGE")
if [ -n "${text}" ]; then
text="${text}:${locale}"
else
text="${locale}"
fi
;;
"locale.gen")
text="${text}\
${locale}.${_SPCD_TXT_CHARSET} ${_SPCD_TXT_CHARSET}
"
;;
*) ;;
esac
done
case "${1}" in
"LANGUAGE") export LANGUAGE="${text}" ;;
"locale.gen") spcd_os_write "/etc/locale.gen" "${text}" ;;
*) ;;
esac
spcd_split
spcd_txt_locales_echo
}
# ╭──────╮ # ╭──────╮
# │ step │ # │ step │
# ╰──────╯ # ╰──────╯
@ -404,7 +479,7 @@ SPCD_PM_ZYPPER="zypper"
# │ step │ environment │ # │ step │ environment │
# ╰──────┴─────────────╯ # ╰──────┴─────────────╯
spcd_step__environment_print() { spcd_step__environment_defaults_print() {
spcd_ca "list" spcd_ca "list"
spcd_dns "list" spcd_dns "list"
set -- \ set -- \
@ -861,128 +936,6 @@ spcd_query_package() {
esac esac
} }
spcd_txt_locale() {
local action="${1}"
local chosen="${2}"
set -- \
"LANG" \
"LC_CTYPE" \
"LC_NUMERIC" \
"LC_TIME" \
"LC_COLLATE" \
"LC_MONETARY" \
"LC_MESSAGES"
case "${SPCD_OS_ID}" in
"${SPCD_OS_ALPINE}") ;;
*)
set -- \
"${@}" \
"LANGUAGE" \
"LC_PAPER" \
"LC_NAME" \
"LC_ADDRESS" \
"LC_TELEPHONE" \
"LC_MEASUREMENT" \
"LC_IDENTIFICATION"
;;
esac
local name
case "${action}" in
"list")
if ! locale; then
for name in "${@}"; do
spcd_os_printenv "${name}"
done
fi
;;
"set")
spcd_txt_locale "list"
spcd_split
local locale long
if [ -n "${chosen}" ]; then
locale="${chosen}"
else
locale="${_SPCD_TXT_LOCALE_DEFAULT}"
fi
long="${locale}.${_SPCD_TXT_CHARSET}"
for name in "${@}"; do
if [ "${name}" != "LANGUAGE" ]; then
export "${name}=${long}"
else
export "${name}=$(spcd_txt_locales language "${chosen}")"
fi
done
spcd_split
spcd_txt_locale "list"
;;
*) ;;
esac
}
spcd_txt_locales() {
local action="${1}"
local chosen="${2}"
set -- \
"${SPCD_TXT_LOCALE_ENGLISH}" \
"${SPCD_TXT_LOCALE_FRENCH}"
local name
case "${action}" in
"install")
spcd_txt_locales "list"
spcd_split
case "${SPCD_PM}" in
"${SPCD_PM_APK}")
spcd_install_package "musl-locales"
export MUSL_LOCPATH="/usr/share/i18n/locales/musl"
;;
"${SPCD_PM_APT}")
local text
for name in "${@}"; do
text="${text}\
${name}.${_SPCD_TXT_CHARSET} ${_SPCD_TXT_CHARSET}
"
done
spcd_os_write "/etc/locale.gen" "${text}"
spcd_install_package "locales"
;;
"${SPCD_PM_DNF}")
local language
for name in "${@}"; do
language="$(echo "${name}" | cut -d _ -f 1)"
spcd_install_package "glibc-langpack-${language}"
done
;;
"${SPCD_PM_PACMAN}") spcd_install_package "glibc-locales" ;;
"${SPCD_PM_ZYPPER}") spcd_install_package "glibc-locale" ;;
*) ;;
esac
spcd_split
spcd_txt_locales "list"
;;
"language")
local text
if [ -n "${chosen}" ]; then
text="${chosen}"
fi
for name in "${@}"; do
if [ "${name}" != "${chosen}" ]; then
if [ -n "${text}" ]; then
text="${text}:${name}"
else
text="${name}"
fi
fi
done
;;
"list")
if ! locale --all-locales; then
echo "No locales yet!"
fi
;;
*) ;;
esac
}
# ╭──────┬─────╮ # ╭──────┬─────╮
# │ step │ dns │ # │ step │ dns │
# ╰──────┴─────╯ # ╰──────┴─────╯
@ -1225,17 +1178,6 @@ spcd_step__packages_install_tools() {
esac esac
} }
spcd_step__packages_install_locales() {
spcd_step_in "Locales"
spcd_step "Install"
spcd_txt_locales "install"
spcd_step "Set"
spcd_txt_locale "set" "${SPCD_TXT_LOCALE}"
spcd_step "Test"
date
spcd_step_out
}
# ╭──────┬────╮ # ╭──────┬────╮
# │ step │ ca │ # │ step │ ca │
# ╰──────┴────╯ # ╰──────┴────╯
@ -1299,6 +1241,25 @@ spcd_step__packages_verify_https() {
fi fi
} }
spcd_step__packages_install_locales() {
spcd_step "Install locales"
case "${SPCD_PM}" in
"${SPCD_PM_APK}") spcd_install_package "musl-locales" ;;
"${SPCD_PM_APT}")
spcd_txt_locales "locale.gen"
spcd_install_package "locales"
;;
"${SPCD_PM_DNF}")
spcd_txt_locales "glibc-langpack-"
;;
"${SPCD_PM_PACMAN}") spcd_install_package "glibc-locales" ;;
"${SPCD_PM_ZYPPER}") spcd_install_package "glibc-locale" ;;
*) ;;
esac
spcd_txt_locales "LANGUAGE"
spcd_txt_locale "${SPCD_TXT_LOCALE}"
}
spcd_step__packages_upgrade_system() { spcd_step__packages_upgrade_system() {
spcd_step "Upgrade system" spcd_step "Upgrade system"
case "${SPCD_PM}" in case "${SPCD_PM}" in
@ -1498,13 +1459,15 @@ ${SPCD_PYTHON_ALIAS} / ${name}"
spcd_main() { spcd_main() {
# environment # environment
spcd_txt_locale
#
spcd_step_in "Environment" spcd_step_in "Environment"
spcd_step_in "Defaults" spcd_step_in "Defaults"
spcd_step "Print defined" spcd_step "Print defined"
spcd_step__environment_print spcd_step__environment_defaults_print
spcd_step__environment_defaults_set spcd_step__environment_defaults_set
spcd_step "Print effective" spcd_step "Print effective"
spcd_step__environment_print spcd_step__environment_defaults_print
spcd_step_out spcd_step_out
spcd_step__environment_set_variables spcd_step__environment_set_variables
spcd_step__environment_list_workspace spcd_step__environment_list_workspace
@ -1518,7 +1481,6 @@ spcd_main() {
spcd_step__packages_trust_https spcd_step__packages_trust_https
spcd_step__packages_update_catalog spcd_step__packages_update_catalog
spcd_step__packages_install_tools spcd_step__packages_install_tools
spcd_step__packages_install_locales
spcd_step_out spcd_step_out
# ca # ca
spcd_step_in "CA" spcd_step_in "CA"
@ -1529,6 +1491,7 @@ spcd_main() {
# packages # packages
spcd_step_in "Packages" spcd_step_in "Packages"
spcd_step__packages_verify_https spcd_step__packages_verify_https
spcd_step__packages_install_locales
spcd_step__packages_update_catalog spcd_step__packages_update_catalog
spcd_step__packages_upgrade_system spcd_step__packages_upgrade_system
spcd_step__packages_install_dos2unix spcd_step__packages_install_dos2unix