From 2c1528da5004cc4edb83187825e6da7622bc2c1b Mon Sep 17 00:00:00 2001 From: Patrick Carlo-Hickman Date: Wed, 25 Jan 2023 16:52:27 +0000 Subject: [PATCH] Add a function to ensure that a specific package can be installed. --- setup/common.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/setup/common.sh b/setup/common.sh index ac19c3b..6e70bcd 100755 --- a/setup/common.sh +++ b/setup/common.sh @@ -169,6 +169,13 @@ function ensure_variable_set { fi } +function ensure_package_available { + if [[ -z "$(apt-cache search --names-only "^${1}")" ]]; then + log_error "Package ${1} was not found as an installable package." + exit 1 + fi +} + function is_mysql_installed { dpkg -l | egrep "ii\s*mysql-server\S*\s+" > /dev/null