client: lib_docker: add CLI version for all platforms

Prints meaningful output of all dependencies and their respective versions.
This commit is contained in:
2024-06-19 16:16:39 -07:00
parent 00d4a8fa77
commit dddd8a90a2
4 changed files with 248 additions and 0 deletions

View File

@@ -320,4 +320,94 @@ function lib_docker::__edit()
$EDITOR "${_paths[@]}"
}
function lib_docker::__version()
{
[ -z "${DOCKER_FINANCE_VERSION}" ] && lib_utils::die_fatal
[ -z "${DOCKER_FINANCE_CLIENT_REPO}" ] && lib_utils::die_fatal
#
# `docker-finance` version
#
local _hash
if pushd "$DOCKER_FINANCE_CLIENT_REPO" 1>/dev/null; then
_hash="$(git log --pretty='format:%h' -n 1)"
popd 1>/dev/null || lib_utils::die_fatal
else
lib_utils::die_fatal
fi
echo
echo -e "docker-finance v${DOCKER_FINANCE_VERSION} | commit: $_hash"
echo -e "───────────────────────────────────────"
#
# Client dependencies
#
echo
echo "client.system:"
echo -e \\t"$(uname -rmo)"
echo -e \\t"$(bash --version | head -n1)"
echo -e \\t"$(sed --version | head -n1)"
echo
echo "client.docker:"
echo -e \\t"$(docker compose version)"
docker version \
| while read _line; do
echo -e \\t"${_line}"
done
#
# Container dependencies
#
[ -z "$global_platform" ] && lib_utils::die_fatal
# Feed dependency manifest (client is not bind-mounted for security reasons)
local _manifest
_manifest="$(<${DOCKER_FINANCE_CLIENT_REPO}/client/docker-finance.yaml)"
case "$global_platform" in
# NOTE: uses variable "callback"
archlinux)
_platform="$global_platform"
_image="finance"
_pkg="pacman -Q \$_package"
;;
ubuntu | dev-tools)
if [[ "$global_platform" =~ ^ubuntu$|^dev-tools$ ]]; then
_platform="ubuntu"
_image="finance"
[[ "$global_platform" == "dev-tools" ]] && _image="dev-tools"
fi
_pkg="dpkg -s \$_package | grep -E \"(^Package:|^Version:)\" | cut -d' ' -f2 | paste -s | awk '{print \$1 \" \" \$2}'"
;;
*)
lib_utils::die_fatal "unsupported platform"
;;
esac
lib_docker::__run "
echo '${_manifest}' \\
| shyaml keys container.${_platform}.${_image} \\
| while read _key; do
echo -e \\\ncontainer.${_platform}.${_image}.\${_key}:
echo '${_manifest}' | shyaml get-values container.${_platform}.${_image}.\${_key}.packages 2>/dev/null \\
| while read _package; do
echo -e \\\t\$($_pkg)
done
echo '${_manifest}' | shyaml get-values container.${_platform}.${_image}.\${_key}.commands 2>/dev/null \\
| while read _command; do
echo -e \\\t\$(\$_command)
done
done
echo"
return $?
}
# vim: sw=2 sts=2 si ai et