From 3e0c0ae17831b21f93a929e7264710456e37c684 Mon Sep 17 00:00:00 2001 From: Jeff Putsch <150963136+jdputschadi@users.noreply.github.com> Date: Fri, 26 Jan 2024 15:38:39 -0800 Subject: [PATCH] allow common-utils to be installed on "minimal" RHEL-based distributions (#811) * allow common-utils to be installed on "minimal" RHEL-based distributions. * bump version to reflect bug fix * add missing test scripts for alma scenarios --------- Co-authored-by: Jeff Putsch --- src/common-utils/devcontainer-feature.json | 4 +- src/common-utils/main.sh | 9 +++-- test/common-utils/alma-8-minimal.sh | 16 ++++++++ test/common-utils/alma-8.sh | 16 ++++++++ test/common-utils/alma-9-minimal.sh | 16 ++++++++ test/common-utils/alma-9.sh | 16 ++++++++ test/common-utils/rocky-8-minimal.sh | 16 ++++++++ test/common-utils/rocky-9-minimal.sh | 16 ++++++++ test/common-utils/scenarios.json | 44 +++++++++++++++++++++- 9 files changed, 147 insertions(+), 6 deletions(-) create mode 100755 test/common-utils/alma-8-minimal.sh create mode 100755 test/common-utils/alma-8.sh create mode 100755 test/common-utils/alma-9-minimal.sh create mode 100755 test/common-utils/alma-9.sh create mode 100755 test/common-utils/rocky-8-minimal.sh create mode 100755 test/common-utils/rocky-9-minimal.sh diff --git a/src/common-utils/devcontainer-feature.json b/src/common-utils/devcontainer-feature.json index de0d02d29..44f9b32b4 100644 --- a/src/common-utils/devcontainer-feature.json +++ b/src/common-utils/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "common-utils", - "version": "2.4.0", + "version": "2.4.1", "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.", @@ -66,4 +66,4 @@ "description": "Add packages from non-free Debian repository? (Debian only)" } } -} +} \ No newline at end of file diff --git a/src/common-utils/main.sh b/src/common-utils/main.sh index 4f3dcf8e8..0eec1ecb9 100644 --- a/src/common-utils/main.sh +++ b/src/common-utils/main.sh @@ -155,9 +155,12 @@ install_debian_packages() { install_redhat_packages() { local package_list="" local remove_epel="false" - local install_cmd=dnf - if ! type dnf > /dev/null 2>&1; then - install_cmd=yum + local install_cmd=microdnf + if ! type microdnf > /dev/null 2>&1; then + install_cmd=dnf + if ! type dnf > /dev/null 2>&1; then + install_cmd=yum + fi fi if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then diff --git a/test/common-utils/alma-8-minimal.sh b/test/common-utils/alma-8-minimal.sh new file mode 100755 index 000000000..d08731824 --- /dev/null +++ b/test/common-utils/alma-8-minimal.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Definition specific tests +. /etc/os-release +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 \ No newline at end of file diff --git a/test/common-utils/alma-8.sh b/test/common-utils/alma-8.sh new file mode 100755 index 000000000..d08731824 --- /dev/null +++ b/test/common-utils/alma-8.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Definition specific tests +. /etc/os-release +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 \ No newline at end of file diff --git a/test/common-utils/alma-9-minimal.sh b/test/common-utils/alma-9-minimal.sh new file mode 100755 index 000000000..cb2b339e1 --- /dev/null +++ b/test/common-utils/alma-9-minimal.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Definition specific tests +. /etc/os-release +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 \ No newline at end of file diff --git a/test/common-utils/alma-9.sh b/test/common-utils/alma-9.sh new file mode 100755 index 000000000..cb2b339e1 --- /dev/null +++ b/test/common-utils/alma-9.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Definition specific tests +. /etc/os-release +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 \ No newline at end of file diff --git a/test/common-utils/rocky-8-minimal.sh b/test/common-utils/rocky-8-minimal.sh new file mode 100755 index 000000000..d08731824 --- /dev/null +++ b/test/common-utils/rocky-8-minimal.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Definition specific tests +. /etc/os-release +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 \ No newline at end of file diff --git a/test/common-utils/rocky-9-minimal.sh b/test/common-utils/rocky-9-minimal.sh new file mode 100755 index 000000000..cb2b339e1 --- /dev/null +++ b/test/common-utils/rocky-9-minimal.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Definition specific tests +. /etc/os-release +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 \ No newline at end of file diff --git a/test/common-utils/scenarios.json b/test/common-utils/scenarios.json index eef2bffcd..2e357bc2b 100644 --- a/test/common-utils/scenarios.json +++ b/test/common-utils/scenarios.json @@ -41,6 +41,34 @@ "common-utils": {} } }, + "alma-8": { + "image": "almalinux:8", + "remoteUser": "devcontainer", + "features": { + "common-utils": {} + } + }, + "alma-9": { + "image": "almalinux:9", + "remoteUser": "devcontainer", + "features": { + "common-utils": {} + } + }, + "alma-8-minimal": { + "image": "almalinux:8-minimal", + "remoteUser": "devcontainer", + "features": { + "common-utils": {} + } + }, + "alma-9-minimal": { + "image": "almalinux:9-minimal", + "remoteUser": "devcontainer", + "features": { + "common-utils": {} + } + }, "rocky-8": { "image": "rockylinux:8", "remoteUser": "devcontainer", @@ -55,6 +83,20 @@ "common-utils": {} } }, + "rocky-8-minimal": { + "image": "rockylinux:8-minimal", + "remoteUser": "devcontainer", + "features": { + "common-utils": {} + } + }, + "rocky-9-minimal": { + "image": "rockylinux:9-minimal", + "remoteUser": "devcontainer", + "features": { + "common-utils": {} + } + }, "fedora": { "image": "fedora", "remoteUser": "devcontainer", @@ -209,4 +251,4 @@ "common-utils": {} } } -} +} \ No newline at end of file