Add --silent flag for installPackage()

This commit is contained in:
2021-11-24 14:20:20 -05:00
parent c59bc5726b
commit 45fd438c51

View File

@@ -298,7 +298,7 @@ getLatestVersion() {
# Use a containerized package manager # Use a containerized package manager
debug "Getting latest version using containerized apt" debug "Getting latest version using containerized apt"
[[ ! -x $(command -v buildah) ]] && installPackage buildah [[ ! -x $(command -v buildah) ]] && installPackage --silent buildah
if [[ -x $(command -v buildah) ]] && CNT=$(buildah from ubuntu:18.04); then if [[ -x $(command -v buildah) ]] && CNT=$(buildah from ubuntu:18.04); then
buildah run "$CNT" -- bash -c \ buildah run "$CNT" -- bash -c \
"echo 'deb [trusted=yes arch=amd64,i386,armhf,arm64] http://dist.jriver.com/latest/mediacenter/ buster main' > /etc/apt/sources.list 2>&1" "echo 'deb [trusted=yes arch=amd64,i386,armhf,arm64] http://dist.jriver.com/latest/mediacenter/ buster main' > /etc/apt/sources.list 2>&1"
@@ -326,17 +326,21 @@ getLatestVersion() {
# One or more package names # One or more package names
# Options: # Options:
# --noquery, -n: Do not query the package state (useful if installing a local RPM) # --noquery, -n: Do not query the package state (useful if installing a local RPM)
# --silent, -s: Do not report errors (useful if package is not strictly required)
####################################### #######################################
installPackage() { installPackage() {
debug "Running: ${FUNCNAME[0]}" "$@" debug "Running: ${FUNCNAME[0]}" "$@"
if _input=$(getopt -o +n -l noquery -- "$@"); then if _input=$(getopt -o +ns -l noquery,silent -- "$@"); then
eval set -- "$_input" eval set -- "$_input"
while true; do while true; do
case "$1" in case "$1" in
--noquery|-n) --noquery|-n)
local _noquery="true" local _noquery="true"
;; ;;
--silent|-s)
local _silent=true
;;
--) --)
shift shift
break break
@@ -370,11 +374,11 @@ installPackage() {
echo "Installing:" "${_pkg_array[@]}" echo "Installing:" "${_pkg_array[@]}"
if debug; then if debug; then
if ! pkg_install "${_pkg_array[@]}"; then if ! pkg_install "${_pkg_array[@]}"; then
err "Failed to install package. Attempting to continue..." [[ ! -v _silent ]] && err "Failed to install package. Attempting to continue..."
return 1 return 1
fi fi
elif ! pkg_install "${_pkg_array[@]}" > /dev/null 2>&1; then elif ! pkg_install "${_pkg_array[@]}" > /dev/null 2>&1; then
err "Failed to install package. Attempting to continue..." [[ ! -v _silent ]] && err "Failed to install package. Attempting to continue..."
return 1 return 1
fi fi
fi fi
@@ -384,11 +388,11 @@ installPackage() {
echo "Installing: " "${_url_pkg_array[@]}" echo "Installing: " "${_url_pkg_array[@]}"
if debug; then if debug; then
if ! pkg_install_nogpg "${_url_pkg_array[@]}"; then if ! pkg_install_nogpg "${_url_pkg_array[@]}"; then
err "Failed to install package. Attempting to continue..." [[ ! -v _silent ]] && err "Failed to install package. Attempting to continue..."
return 1 return 1
fi fi
elif ! pkg_install_nogpg "${_url_pkg_array[@]}" > /dev/null 2>&1; then elif ! pkg_install_nogpg "${_url_pkg_array[@]}" > /dev/null 2>&1; then
err "Failed to install package. Attempting to continue..." [[ ! -v _silent ]] && err "Failed to install package. Attempting to continue..."
return 1 return 1
fi fi
fi fi
@@ -424,7 +428,8 @@ installMCFromRepo() {
local _mcpkg local _mcpkg
echo "Installing JRiver Media Center $_mcversion from repo..." echo "Installing JRiver Media Center $_mcversion from repository."
echo "Future updates will be handled by your package manager."
if ! debug; then if ! debug; then
echo "This may take a few minutes to complete" echo "This may take a few minutes to complete"