tools/create-toolbox: Allow enabling additional locales

Out of the box, the container images only support US English. It
can sometimes be necessary to use a different locale, so add
a convenience flag to enable support for additional locales.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2713>
This commit is contained in:
Florian Müllner 2023-03-20 21:21:36 +01:00 committed by Marge Bot
parent d9c627cf27
commit 3ab8c5d272

View File

@ -19,6 +19,7 @@ usage() {
(like 44) instead of the main branch
-r, --replace Replace an existing container
-b, --builder Set up GNOME Builder configuration
--locales=LOCALES Enable support for additional locales LOCALES
--skip-mutter Do not build mutter
-h, --help Display this help
@ -34,6 +35,16 @@ toolbox_run() {
toolbox run --container $NAME "$@"
}
install_extra_packages() {
local -a pkgs
pkgs+=( ${LOCALES[@]/#/glibc-langpack-} )
[[ ${#pkgs[@]} > 0 ]] &&
toolbox_run su -c "dnf install -y ${pkgs[*]}"
true
}
create_builder_config() {
local container_id=$(podman container inspect --format='{{.Id}}' $NAME)
local top_srcdir=$(realpath $(dirname $0)/../..)
@ -61,6 +72,7 @@ TEMP=$(getopt \
--longoptions 'version:' \
--longoptions 'replace' \
--longoptions 'builder' \
--longoptions 'locales:' \
--longoptions 'skip-mutter' \
--longoptions 'help' \
-- "$@")
@ -69,6 +81,7 @@ eval set -- "$TEMP"
unset TEMP
NAME=$DEFAULT_NAME
LOCALES=()
while true; do
case "$1" in
@ -97,6 +110,11 @@ while true; do
shift
;;
--locales)
IFS=" ," LOCALES+=($2)
shift 2
;;
-h|--help)
usage
exit 0
@ -120,6 +138,8 @@ fi
podman pull $TOOLBOX_IMAGE:$TAG
toolbox create --image $TOOLBOX_IMAGE:$TAG $NAME
install_extra_packages
[[ $SKIP_MUTTER ]] || toolbox_run update-mutter
[[ $SETUP_BUILDER ]] && create_builder_config