Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Common-utils: Fixes "No package jq available" errors for CentOS #644

Merged
merged 4 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/common-utils/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "common-utils",
"version": "2.0.11",
"version": "2.0.12",
"name": "Common Utilities",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/common-utils",
"description": "Installs a set of common command line utilities, Oh My Zsh!, and sets up a non-root user.",
Expand Down
18 changes: 15 additions & 3 deletions src/common-utils/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,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
Expand All @@ -200,16 +205,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
Expand Down
1 change: 1 addition & 0 deletions test/common-utils/centos-7.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ source dev-container-features-test-lib
. /etc/os-release
check "non-root user" test "$(whoami)" = "devcontainer"
check "distro" test "${VERSION_ID}" = "7"
check "jq" jq --version

# Report result
reportResults
1 change: 1 addition & 0 deletions test/common-utils/fedora.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ source dev-container-features-test-lib
. /etc/os-release
check "non-root user" test "$(whoami)" = "devcontainer"
check "distro" test "${ID}" = "fedora"
check "jq" jq --version

# Report result
reportResults
1 change: 1 addition & 0 deletions test/common-utils/mariner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ source dev-container-features-test-lib
. /etc/os-release
check "non-root user" test "$(whoami)" = "devcontainer"
check "distro" test "${ID}" = "mariner"
check "jq" jq --version

# Report result
reportResults
1 change: 1 addition & 0 deletions test/common-utils/rocky-8.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ source dev-container-features-test-lib
check "non-root user" test "$(whoami)" = "devcontainer"
check "distro" test "${PLATFORM_ID}" = "platform:el8"
check "curl" curl --version
check "jq" jq --version

# Report result
reportResults
1 change: 1 addition & 0 deletions test/common-utils/rocky-9.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ source dev-container-features-test-lib
check "non-root user" test "$(whoami)" = "devcontainer"
check "distro" test "${PLATFORM_ID}" = "platform:el9"
check "curl" curl --version
check "jq" jq --version

# Report result
reportResults