Allow decoupling the toolbox's OS version from the host's

This adds a --release flag that overrides the VERSION_ID value read
from the host's /etc/os-release when creating and entering toolboxes.
This commit is contained in:
Debarshi Ray 2018-10-15 19:24:12 +02:00
parent f3eab6afca
commit 80f25c6924

View file

@ -17,18 +17,13 @@
source /etc/os-release
release=$VERSION_ID
fgc="f$VERSION_ID"
prefix_sudo=""
registry="registry.fedoraproject.org"
registry_candidate="candidate-registry.fedoraproject.org"
toolbox_container="fedora-toolbox-$USER:$VERSION_ID"
toolbox_prompt="🔹[\u@\h \W]\\$ "
base_toolbox_image="fedora-toolbox:$VERSION_ID"
toolbox_image="fedora-toolbox-$USER:$VERSION_ID"
create()
(
@ -184,8 +179,8 @@ exit_if_unrecognized_option()
usage()
{
echo "Usage: $0 [-v | --verbose] create [--candidate-registry]"
echo " or: $0 [-v | --verbose] enter"
echo "Usage: $0 [--release <release>] [-v | --verbose] create [--candidate-registry]"
echo " or: $0 [--release <release>] [-v | --verbose] enter"
echo " or: $0 --help"
}
@ -198,6 +193,25 @@ while [[ "$1" == -* ]]; do
usage
exit
;;
--release )
shift
if [ "$1" == "" ]; then
echo "$0: missing argument for '--release'"
echo "Try '$0 --help' for more information."
exit 1
fi
if ! [ $1 -eq $1 2>&42 ]; then
echo "$0: invalid argument for '--release'"
echo "Try '$0 --help' for more information."
exit 1
fi
if [ $1 -le 0 2>&42 ]; then
echo "$0: invalid argument for '--release'"
echo "Try '$0 --help' for more information."
exit 1
fi
release=$1
;;
--sudo )
prefix_sudo="sudo"
;;
@ -210,6 +224,11 @@ while [[ "$1" == -* ]]; do
shift
done
fgc="f$release"
toolbox_container="fedora-toolbox-$USER:$release"
base_toolbox_image="fedora-toolbox:$release"
toolbox_image="fedora-toolbox-$USER:$release"
if [ "$1" == "" ]; then
echo "$0: missing command"
echo "Try '$0 --help' for more information."