aboutsummaryrefslogtreecommitdiff
path: root/src/common-utils/main.sh
diff options
context:
space:
mode:
authorSamruddhi Khandale <skhandale@microsoft.com>2023-08-15 02:12:47 +0300
committerGitHub <noreply@github.com>2023-08-15 02:12:47 +0300
commitf90cb26c7f15659f3e2be8061295997df2bb76cc (patch)
tree12bde00a8072d9b2ee83273d6238a9571edd11f5 /src/common-utils/main.sh
parent8b6f08825643e2d5835ed3138dee5301a4db4ffa (diff)
Common-utils: Fixes "No package jq available" errors for CentOS (#644)feature_common-utils_2.1.1
* add checks for "jq" * install epel-release if necessary * clean up epel-release post installation of "jq"
Diffstat (limited to 'src/common-utils/main.sh')
-rw-r--r--src/common-utils/main.sh18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/common-utils/main.sh b/src/common-utils/main.sh
index d3f7ef2..3731994 100644
--- a/src/common-utils/main.sh
+++ b/src/common-utils/main.sh
@@ -175,6 +175,11 @@ install_redhat_packages() {
man-db \
strace"
+ local install_cmd=dnf
+ if ! type dnf > /dev/null 2>&1; then
+ install_cmd=yum
+ fi
+
# rockylinux:9 installs 'curl-minimal' which clashes with 'curl'
# Install 'curl' for every OS except this rockylinux:9
if [[ "${ID}" = "rocky" ]] && [[ "${VERSION}" != *"9."* ]]; then
@@ -201,16 +206,23 @@ install_redhat_packages() {
package_list="${package_list} zsh"
fi
- local install_cmd=dnf
- if ! type dnf > /dev/null 2>&1; then
- install_cmd=yum
+ # Install EPEL repository if needed (required to install 'jq' for CentOS)
+ local remove_epel="false"
+ if ! ${install_cmd} -q list jq >/dev/null 2>&1; then
+ ${install_cmd} -y install epel-release
+ remove_epel="true"
fi
+
${install_cmd} -y install ${package_list}
# Get to latest versions of all packages
if [ "${UPGRADE_PACKAGES}" = "true" ]; then
${install_cmd} upgrade -y
fi
+
+ if [[ "${remove_epel}" = "true" ]]; then
+ ${install_cmd} -y remove epel-release
+ fi
}
# Alpine Linux packages