2023-03-17 00:07:56 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# vi: sw=2 ts=4
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
TOOLBOX_IMAGE=registry.gitlab.gnome.org/gnome/gnome-shell/toolbox
|
|
|
|
DEFAULT_NAME=gnome-shell-devel
|
|
|
|
|
|
|
|
usage() {
|
|
|
|
cat <<-EOF
|
|
|
|
Usage: $(basename $0) [OPTION…]
|
|
|
|
|
|
|
|
Create a toolbox for gnome-shell development
|
|
|
|
|
|
|
|
Options:
|
|
|
|
-n, --name=NAME Create container as NAME instead of the
|
|
|
|
default "$DEFAULT_NAME"
|
|
|
|
-v, --version=VERSION Create container for stable version VERSION
|
|
|
|
(like 44) instead of the main branch
|
2023-03-20 14:09:25 +00:00
|
|
|
-r, --replace Replace an existing container
|
2023-03-17 09:32:33 +00:00
|
|
|
-b, --builder Set up GNOME Builder configuration
|
2023-03-20 20:21:36 +00:00
|
|
|
--locales=LOCALES Enable support for additional locales LOCALES
|
2023-03-18 03:45:26 +00:00
|
|
|
--skip-mutter Do not build mutter
|
2023-03-17 00:07:56 +00:00
|
|
|
-h, --help Display this help
|
|
|
|
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
die() {
|
|
|
|
echo "$@" >&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
toolbox_run() {
|
|
|
|
toolbox run --container $NAME "$@"
|
|
|
|
}
|
|
|
|
|
2023-03-20 20:21:36 +00:00
|
|
|
install_extra_packages() {
|
|
|
|
local -a pkgs
|
|
|
|
|
|
|
|
pkgs+=( ${LOCALES[@]/#/glibc-langpack-} )
|
|
|
|
|
|
|
|
[[ ${#pkgs[@]} > 0 ]] &&
|
|
|
|
toolbox_run su -c "dnf install -y ${pkgs[*]}"
|
|
|
|
true
|
|
|
|
}
|
|
|
|
|
2023-03-17 09:32:33 +00:00
|
|
|
create_builder_config() {
|
|
|
|
local container_id=$(podman container inspect --format='{{.Id}}' $NAME)
|
|
|
|
local top_srcdir=$(realpath $(dirname $0)/../..)
|
|
|
|
local wayland_display=builder-wayland-0
|
|
|
|
|
|
|
|
cat >> $top_srcdir/.buildconfig <<-EOF
|
|
|
|
|
|
|
|
[toolbox-$NAME]
|
|
|
|
name=$NAME Toolbox
|
|
|
|
runtime=podman:$container_id
|
|
|
|
prefix=/usr
|
|
|
|
run-command=dbus-run-session gnome-shell --nested --wayland-display=$wayland_display
|
|
|
|
|
|
|
|
[toolbox-$NAME.runtime_environment]
|
|
|
|
WAYLAND_DISPLAY=$wayland_display
|
|
|
|
G_MESSAGES_DEBUG=GNOME Shell
|
|
|
|
XDG_DATA_DIRS=${XDG_DATA_DIRS:-/usr/local/share:/usr/share}
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
2023-03-17 00:07:56 +00:00
|
|
|
TEMP=$(getopt \
|
|
|
|
--name $(basename $0) \
|
2023-03-17 09:32:33 +00:00
|
|
|
--options 'n:v:rbh' \
|
2023-03-17 00:07:56 +00:00
|
|
|
--longoptions 'name:' \
|
|
|
|
--longoptions 'version:' \
|
2023-03-20 14:09:25 +00:00
|
|
|
--longoptions 'replace' \
|
2023-03-17 09:32:33 +00:00
|
|
|
--longoptions 'builder' \
|
2023-03-20 20:21:36 +00:00
|
|
|
--longoptions 'locales:' \
|
2023-03-18 03:45:26 +00:00
|
|
|
--longoptions 'skip-mutter' \
|
2023-03-17 00:07:56 +00:00
|
|
|
--longoptions 'help' \
|
|
|
|
-- "$@")
|
|
|
|
|
|
|
|
eval set -- "$TEMP"
|
|
|
|
unset TEMP
|
|
|
|
|
|
|
|
NAME=$DEFAULT_NAME
|
2023-03-20 20:21:36 +00:00
|
|
|
LOCALES=()
|
2023-03-17 00:07:56 +00:00
|
|
|
|
|
|
|
while true; do
|
|
|
|
case "$1" in
|
|
|
|
-n|--name)
|
|
|
|
NAME="$2"
|
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
|
|
|
|
-v|--version)
|
|
|
|
VERSION="$2"
|
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
|
2023-03-20 14:09:25 +00:00
|
|
|
-r|--replace)
|
|
|
|
REPLACE=1
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
|
2023-03-17 09:32:33 +00:00
|
|
|
-b|--builder)
|
|
|
|
SETUP_BUILDER=1
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
|
2023-03-18 03:45:26 +00:00
|
|
|
--skip-mutter)
|
|
|
|
SKIP_MUTTER=1
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
|
2023-03-20 20:21:36 +00:00
|
|
|
--locales)
|
|
|
|
IFS=" ," LOCALES+=($2)
|
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
|
2023-03-17 00:07:56 +00:00
|
|
|
-h|--help)
|
|
|
|
usage
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
--)
|
|
|
|
shift
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
TAG=${VERSION:-main}
|
|
|
|
|
|
|
|
if podman container exists $NAME; then
|
2023-03-20 14:09:25 +00:00
|
|
|
[[ $REPLACE ]] ||
|
|
|
|
die "Container $NAME already exists and --replace was not specified"
|
|
|
|
toolbox rm --force $NAME
|
2023-03-17 00:07:56 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
podman pull $TOOLBOX_IMAGE:$TAG
|
|
|
|
|
|
|
|
toolbox create --image $TOOLBOX_IMAGE:$TAG $NAME
|
2023-03-20 20:21:36 +00:00
|
|
|
install_extra_packages
|
|
|
|
|
2023-03-18 03:45:26 +00:00
|
|
|
[[ $SKIP_MUTTER ]] || toolbox_run update-mutter
|
2023-03-17 09:32:33 +00:00
|
|
|
|
|
|
|
[[ $SETUP_BUILDER ]] && create_builder_config
|