From aed343a2c98cbac8796181a6776df502defe200a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Wed, 3 Nov 2021 21:54:25 +0100 Subject: [PATCH] Use apt instead of apt-get for updating the package cache if available MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- automated install/basic-install.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index babb8213..4634ca69 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -266,8 +266,13 @@ if is_command apt-get ; then # Set some global variables here # We don't set them earlier since the installed package manager might be rpm, so these values would be different PKG_MANAGER="apt-get" - # A variable to store the command used to update the package cache - UPDATE_PKG_CACHE="${PKG_MANAGER} update" + # A variable to store the command used to update the package cache. If apt is available use this as we have seen it + # gives more user-friendly (interactive) advice, else fall-back to apt-get + if is_command apt ; then + UPDATE_PKG_CACHE="apt update" + else + UPDATE_PKG_CACHE="${PKG_MANAGER} update" + fi # The command we will use to actually install packages PKG_INSTALL=("${PKG_MANAGER}" -qq --no-install-recommends install) # grep -c will return 1 if there are no matches. This is an acceptable condition, so we OR TRUE to prevent set -e exiting the script.