From 3ab8c5d272bde3eba62f9929bb2bb7fa3b406b6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Mon, 20 Mar 2023 21:21:36 +0100 Subject: [PATCH] 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: --- tools/toolbox/create-toolbox.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tools/toolbox/create-toolbox.sh b/tools/toolbox/create-toolbox.sh index 400290103..c63c49e56 100755 --- a/tools/toolbox/create-toolbox.sh +++ b/tools/toolbox/create-toolbox.sh @@ -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