gnome-shell/tools/toolbox/create-toolbox.sh
Florian Müllner 36e9db4fb7 tools/create-toolbox: Allow replacing existing toolbox
A toolbox created by the script can be used as the base of a pet
container that is manually updated with new dependencies over time
and accumalates additional packages; or it can be used as a deposable
container that is recreated each time the dependencies change.

To make the latter case more convenient, add a --replace option
that deletes an existing toolbox before creating the new one.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2713>
2023-05-16 18:20:42 +00:00

89 lines
1.5 KiB
Bash
Executable file

#!/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
-r, --replace Replace an existing container
-h, --help Display this help
EOF
}
die() {
echo "$@" >&2
exit 1
}
toolbox_run() {
toolbox run --container $NAME "$@"
}
TEMP=$(getopt \
--name $(basename $0) \
--options 'n:v:rh' \
--longoptions 'name:' \
--longoptions 'version:' \
--longoptions 'replace' \
--longoptions 'help' \
-- "$@")
eval set -- "$TEMP"
unset TEMP
NAME=$DEFAULT_NAME
while true; do
case "$1" in
-n|--name)
NAME="$2"
shift 2
;;
-v|--version)
VERSION="$2"
shift 2
;;
-r|--replace)
REPLACE=1
shift
;;
-h|--help)
usage
exit 0
;;
--)
shift
break
;;
esac
done
TAG=${VERSION:-main}
if podman container exists $NAME; then
[[ $REPLACE ]] ||
die "Container $NAME already exists and --replace was not specified"
toolbox rm --force $NAME
fi
podman pull $TOOLBOX_IMAGE:$TAG
toolbox create --image $TOOLBOX_IMAGE:$TAG $NAME
toolbox_run update-mutter