Improve the readability of the debug output

... by annotating the different stages of activity. This makes it
easier to understand the rest of the spew coming from buildah and
podman.

https://github.com/debarshiray/fedora-toolbox/issues/31
This commit is contained in:
Debarshi Ray 2019-01-11 14:50:02 +01:00
parent e2315f183e
commit b71609580b

View file

@ -44,10 +44,17 @@ create()
dbus_system_bus_path=$(echo $dbus_system_bus_address | cut --delimiter = --fields 2 2>&42)
dbus_system_bus_path=$(readlink --canonicalize $dbus_system_bus_path 2>&42)
echo "$0: checking if image $toolbox_image already exists" >&42
if ! $prefix_sudo buildah inspect --type image $toolbox_image >/dev/null 2>&42; then
echo "$0: trying to create working container $working_container_name" >&42
echo "$0: looking for image localhost/$base_toolbox_image" >&42
if ! $prefix_sudo buildah from \
--name $working_container_name \
localhost/$base_toolbox_image >/dev/null 2>&42; then
echo "$0: looking for image $registry/$fgc/$base_toolbox_image" >&42
if ! $prefix_sudo buildah from \
--name $working_container_name \
$registry/$fgc/$base_toolbox_image >/dev/null 2>&42; then
@ -56,6 +63,8 @@ create()
fi
fi
echo "$0: trying to configure working container $working_container_name" >&42
if ! $prefix_sudo buildah run $working_container_name -- useradd \
--no-create-home \
--shell $SHELL \
@ -118,13 +127,19 @@ create()
exit 1
fi
echo "$0: trying to create image $toolbox_image" >&42
if ! $prefix_sudo buildah commit --rm $working_container_name $toolbox_image >/dev/null 2>&42; then
$prefix_sudo buildah rm $working_container_name >/dev/null 2>&42
echo "$0: failed to create image $toolbox_image"
exit 1
fi
echo "$0: created image $toolbox_image" >&42
fi
echo "$0: checking if container $toolbox_container already exists" >&42
if $prefix_sudo podman inspect --type container $toolbox_container >/dev/null 2>&42; then
echo "$0: container $toolbox_container already exists"
exit 1
@ -139,6 +154,8 @@ create()
max_minus_uid=$((max_uid_count-UID))
uid_plus_one=$((UID+1))
echo "$0: trying to create container $toolbox_container" >&42
if ! $prefix_sudo podman create \
--group-add wheel \
--hostname toolbox \
@ -161,6 +178,8 @@ create()
echo "$0: failed to create container $toolbox_container"
exit 1
fi
echo "$0: created container $toolbox_container" >&42
)
@ -168,6 +187,8 @@ enter()
(
shell_to_exec=/bin/bash
echo "$0: trying to start container $toolbox_container" >&42
if ! $prefix_sudo podman start $toolbox_container >/dev/null 2>&42; then
echo "$0: failed to start container $toolbox_container"
exit 1
@ -177,12 +198,16 @@ enter()
set_dbus_system_bus_address="--env DBUS_SYSTEM_BUS_ADDRESS=$DBUS_SYSTEM_BUS_ADDRESS"
fi
echo "$0: looking for $SHELL in container $toolbox_container" >&42
if $prefix_sudo podman exec $toolbox_container test -f $SHELL 2>&42; then
shell_to_exec=$SHELL
else
echo "$SHELL not found in $toolbox_container; using $shell_to_exec instead" >&42
fi
echo "$0: trying to exec $shell_to_exec in container $toolbox_container" >&42
$prefix_sudo podman exec \
--env COLORTERM=$COLORTERM \
--env DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS \