Compare commits
18 commits
7c181c84fb
...
781d907b07
Author | SHA1 | Date | |
---|---|---|---|
781d907b07 | |||
b847d77ae3 | |||
cf521c52d2 | |||
55ba36326c | |||
8a3986f2b1 | |||
a9c7fa01a7 | |||
5d9100a39b | |||
aac5e65650 | |||
1773608215 | |||
dc51f1eba6 | |||
44f68bcca2 | |||
56b9215ef3 | |||
84c0885f1f | |||
d592c30ffd | |||
194ff1b177 | |||
e42561f3c1 | |||
05ccc94e9c | |||
18de897329 |
2 changed files with 142 additions and 101 deletions
|
@ -221,6 +221,7 @@ Handle project workflows in a unified way:
|
|||
|
||||
#### Shell
|
||||
|
||||
* command to echo & run
|
||||
* comment
|
||||
* handle errors
|
||||
* packages
|
||||
|
@ -235,7 +236,10 @@ Handle project workflows in a unified way:
|
|||
* opensuse
|
||||
* opensuse
|
||||
* disable & enable https
|
||||
* persist locales
|
||||
* locales
|
||||
* persist
|
||||
* restrict LC_* variables set for alpine
|
||||
* test LC_* variables
|
||||
* test
|
||||
|
||||
#### Shell → Python
|
||||
|
|
|
@ -377,81 +377,6 @@ spcd_txt_get() {
|
|||
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 │
|
||||
# ╰──────╯
|
||||
|
@ -479,7 +404,7 @@ SPCD_PM_ZYPPER="zypper"
|
|||
# │ step │ environment │
|
||||
# ╰──────┴─────────────╯
|
||||
|
||||
spcd_step__environment_defaults_print() {
|
||||
spcd_step__environment_print() {
|
||||
spcd_ca "list"
|
||||
spcd_dns "list"
|
||||
set -- \
|
||||
|
@ -936,6 +861,128 @@ spcd_query_package() {
|
|||
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 │
|
||||
# ╰──────┴─────╯
|
||||
|
@ -1178,6 +1225,17 @@ spcd_step__packages_install_tools() {
|
|||
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 │
|
||||
# ╰──────┴────╯
|
||||
|
@ -1241,25 +1299,6 @@ spcd_step__packages_verify_https() {
|
|||
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 "Upgrade system"
|
||||
case "${SPCD_PM}" in
|
||||
|
@ -1459,15 +1498,13 @@ ${SPCD_PYTHON_ALIAS} / ${name}"
|
|||
|
||||
spcd_main() {
|
||||
# environment
|
||||
spcd_txt_locale
|
||||
#
|
||||
spcd_step_in "Environment"
|
||||
spcd_step_in "Defaults"
|
||||
spcd_step "Print defined"
|
||||
spcd_step__environment_defaults_print
|
||||
spcd_step__environment_print
|
||||
spcd_step__environment_defaults_set
|
||||
spcd_step "Print effective"
|
||||
spcd_step__environment_defaults_print
|
||||
spcd_step__environment_print
|
||||
spcd_step_out
|
||||
spcd_step__environment_set_variables
|
||||
spcd_step__environment_list_workspace
|
||||
|
@ -1481,6 +1518,7 @@ spcd_main() {
|
|||
spcd_step__packages_trust_https
|
||||
spcd_step__packages_update_catalog
|
||||
spcd_step__packages_install_tools
|
||||
spcd_step__packages_install_locales
|
||||
spcd_step_out
|
||||
# ca
|
||||
spcd_step_in "CA"
|
||||
|
@ -1491,7 +1529,6 @@ spcd_main() {
|
|||
# packages
|
||||
spcd_step_in "Packages"
|
||||
spcd_step__packages_verify_https
|
||||
spcd_step__packages_install_locales
|
||||
spcd_step__packages_update_catalog
|
||||
spcd_step__packages_upgrade_system
|
||||
spcd_step__packages_install_dos2unix
|
||||
|
|
Loading…
Reference in a new issue