From 1a3d33525679157d7e291be1947a4ecce29ed69c Mon Sep 17 00:00:00 2001 From: sireeshajonnalagadda Date: Thu, 6 Mar 2025 08:27:55 +0000 Subject: [PATCH 01/15] rremoved shell envwhich defaults to the shell /bin/bash --- .../configure_zsh_as_default_shell/Dockerfile | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 test/common-utils/configure_zsh_as_default_shell/Dockerfile diff --git a/test/common-utils/configure_zsh_as_default_shell/Dockerfile b/test/common-utils/configure_zsh_as_default_shell/Dockerfile new file mode 100644 index 000000000..2ab3a8973 --- /dev/null +++ b/test/common-utils/configure_zsh_as_default_shell/Dockerfile @@ -0,0 +1,103 @@ +#------------------------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. +#------------------------------------------------------------------------------------------------------------- + + FROM ubuntu:focal + + COPY first-run-notice.txt /tmp/scripts/ + + RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + # Restore man command + && yes | unminimize 2>&1 + + ENV LANG="C.UTF-8" + + # Install basic build tools + RUN apt-get update \ + && apt-get upgrade -y \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + make \ + unzip \ + # The tools in this package are used when installing packages for Python + build-essential \ + swig3.0 \ + # Required for Microsoft SQL Server + unixodbc-dev \ + # Required for PostgreSQL + libpq-dev \ + # Required for mysqlclient + default-libmysqlclient-dev \ + # Required for ts + moreutils \ + rsync \ + zip \ + libgdiplus \ + jq \ + # By default pip is not available in the buildpacks image + python-pip-whl \ + python3-pip \ + #.NET Core related pre-requisites + libc6 \ + libgcc1 \ + libgssapi-krb5-2 \ + libncurses5 \ + liblttng-ust0 \ + libssl-dev \ + libstdc++6 \ + zlib1g \ + libuuid1 \ + libunwind8 \ + sqlite3 \ + libsqlite3-dev \ + software-properties-common \ + tk-dev \ + uuid-dev \ + curl \ + gettext \ + inotify-tools \ + && rm -rf /var/lib/apt/lists/* \ + # This is the folder containing 'links' to benv and build script generator + && apt-get update \ + && apt-get upgrade -y \ + && add-apt-repository universe \ + && rm -rf /var/lib/apt/lists/* + + # Verify expected build and debug tools are present + RUN apt-get update \ + && apt-get -y install build-essential cmake cppcheck valgrind clang lldb llvm gdb python3-dev \ + # Install tools and shells not in common script + && apt-get install -yq vim vim-doc xtail software-properties-common libsecret-1-dev \ + # Install additional tools (useful for 'puppeteer' project) + && apt-get install -y --no-install-recommends libnss3 libnspr4 libatk-bridge2.0-0 libatk1.0-0 libx11-6 libpangocairo-1.0-0 \ + libx11-xcb1 libcups2 libxcomposite1 libxdamage1 libxfixes3 libpango-1.0-0 libgbm1 libgtk-3-0 \ + # Clean up + && apt-get autoremove -y && apt-get clean -y \ + # Move first run notice to right spot + && mkdir -p "/usr/local/etc/vscode-dev-containers/" \ + && mv -f /tmp/scripts/first-run-notice.txt /usr/local/etc/vscode-dev-containers/ + + # Default to bash shell (other shells available at /usr/bin/fish and /usr/bin/zsh) + ENV DOCKER_BUILDKIT=1 + + # Install and setup fish + RUN apt-get install -yq fish \ + && FISH_PROMPT="function fish_prompt\n set_color green\n echo -n (whoami)\n set_color normal\n echo -n \":\"\n set_color blue\n echo -n (pwd)\n set_color normal\n echo -n \"> \"\nend\n" \ + && printf "$FISH_PROMPT" >> /etc/fish/functions/fish_prompt.fish \ + && printf "if type code-insiders > /dev/null 2>&1; and not type code > /dev/null 2>&1\n alias code=code-insiders\nend" >> /etc/fish/conf.d/code_alias.fish + + # Remove scripts now that we're done with them + RUN apt-get clean -y && rm -rf /tmp/scripts + + # Mount for docker-in-docker + VOLUME [ "/var/lib/docker" ] + + CMD [ "sleep", "infinity" ] + + # [Optional] Install debugger for development of Codespaces - Not in resulting image by default + ARG DeveloperBuild + RUN if [ -z $DeveloperBuild ]; then \ + echo "not including debugger" ; \ + else \ + curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l /vsdbg ; \ + fi \ No newline at end of file From 75556a8a0016e6f03f6e0426915e3bb577bf9705 Mon Sep 17 00:00:00 2001 From: sireeshajonnalagadda Date: Fri, 21 Mar 2025 08:35:18 +0000 Subject: [PATCH 02/15] adding powershell support for alma linux9 --- src/powershell/install.sh | 137 ++++++++++++++++++++--- test/powershell/powershell_alma_linux.sh | 12 ++ test/powershell/scenarios.json | 6 + 3 files changed, 141 insertions(+), 14 deletions(-) create mode 100644 test/powershell/powershell_alma_linux.sh diff --git a/src/powershell/install.sh b/src/powershell/install.sh index 4953a49d8..d1eb93d3d 100755 --- a/src/powershell/install.sh +++ b/src/powershell/install.sh @@ -17,18 +17,86 @@ POWERSHELL_MODULES="${MODULES:-""}" POWERSHELL_PROFILE_URL="${POWERSHELLPROFILEURL}" MICROSOFT_GPG_KEYS_URI="https://packages.microsoft.com/keys/microsoft.asc" -POWERSHELL_ARCHIVE_ARCHITECTURES="amd64" +#MICROSOFT_GPG_KEYS_URI=$(curl https://packages.microsoft.com/keys/microsoft.asc -o /usr/share/keyrings/microsoft-archive-keyring.gpg) +POWERSHELL_ARCHIVE_ARCHITECTURES_UBUNTU="amd64" +POWERSHELL_ARCHIVE_ARCHITECTURES_ALMALINUX="x86_64" POWERSHELL_ARCHIVE_VERSION_CODENAMES="stretch buster bionic focal bullseye jammy bookworm noble" GPG_KEY_SERVERS="keyserver hkp://keyserver.ubuntu.com keyserver hkp://keyserver.ubuntu.com:80 keyserver hkps://keys.openpgp.org -keyserver hkp://keyserver.pgp.com" +keyserver hkp://keyserver.pgp.com +keyserver hkp://keyserver.fedoraproject.org +keyserver hkps://keys.openpgp.org +keyserver hkp://pgp.mit.edu +keyserver hkp://keyserver.redhat.com" + if [ "$(id -u)" -ne 0 ]; then echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' exit 1 fi +# Clean up package manager cache +clean_cache() { + if [ -d "/var/cache/apt" ]; then + apt-get clean + fi + if [ -d "/var/cache/dnf" ]; then + rm -rf /var/cache/dnf/* + fi +} +# Install dependencies for RHEL/CentOS/AlmaLinux (DNF-based systems) +install_using_dnf() { + dnf remove -y curl-minimal + dnf install -y curl gnupg2 ca-certificates dnf-plugins-core + dnf clean all + dnf makecache + curl --version +} + +# Install PowerShell on RHEL/CentOS/AlmaLinux-based systems (DNF) +install_powershell_dnf() { + # Install wget, if not already installed + dnf install -y wget + + # Download Microsoft GPG key + curl https://packages.microsoft.com/keys/microsoft.asc -o /usr/share/keyrings/microsoft-archive-keyring.gpg + ls -l /usr/share/keyrings/microsoft-archive-keyring.gpg + + # Install necessary dependencies + dnf install -y krb5-libs libicu openssl-libs zlib + + # Add Microsoft PowerShell repository + curl "https://packages.microsoft.com/config/rhel/9.0/prod.repo" > /etc/yum.repos.d/microsoft.repo + + # Install PowerShell + dnf install --assumeyes powershell +} + + +# Detect the package manager and OS +detect_package_manager() { + if [ -f /etc/os-release ]; then + . /etc/os-release + if [[ "$ID" == "ubuntu" || "$ID" == "debian" ]]; then + echo "Detected Debian/Ubuntu-based system" + install_using_apt + install_pwsh + elif [[ "$ID" == "centos" || "$ID" == "rhel" || "$ID" == "almalinux" ]]; then + echo "Detected RHEL/CentOS/AlmaLinux-based system" + install_using_dnf + install_powershell_dnf + install_pwsh + else + echo "Unsupported Linux distribution: $ID" + exit 1 + fi + else + echo "Could not detect OS" + exit 1 + fi +} + # Figure out correct version of a three part version number is not passed find_version_from_git_tags() { local variable_name=$1 @@ -72,10 +140,31 @@ apt_get_update() } # Checks if packages are installed and installs them if not -check_packages() { - if ! dpkg -s "$@" > /dev/null 2>&1; then - apt_get_update - apt-get -y install --no-install-recommends "$@" + check_packages() { + if command -v dpkg > /dev/null 2>&1; then + # If dpkg exists, assume APT-based system (Debian/Ubuntu) + for package in "$@"; do + if ! dpkg -s "$package" > /dev/null 2>&1; then + echo "Package $package not installed. Installing using apt-get..." + sudo apt-get update + sudo apt-get install -y --no-install-recommends "$package" + else + echo "Package $package is already installed (APT)." + fi + done + elif command -v rpm > /dev/null 2>&1 && command -v dnf > /dev/null 2>&1; then + # If rpm and dnf exist, assume DNF-based system (RHEL/AlmaLinux) + for package in "$@"; do + if ! rpm -q "$package" > /dev/null 2>&1; then + echo "Package $package not installed. Installing using dnf..." + dnf install -y "$package" + else + echo "Package $package is already installed (DNF)." + fi + done + else + echo "Unsupported package manager. Neither APT nor DNF found." + return 1 fi } @@ -83,8 +172,10 @@ install_using_apt() { # Install dependencies check_packages apt-transport-https curl ca-certificates gnupg2 dirmngr # Import key safely (new 'signed-by' method rather than deprecated apt-key approach) and install + curl -sSL ${MICROSOFT_GPG_KEYS_URI} | gpg --dearmor > /usr/share/keyrings/microsoft-archive-keyring.gpg echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/repos/microsoft-${ID}-${VERSION_CODENAME}-prod ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/microsoft.list + # Update lists apt-get update -yq @@ -202,7 +293,12 @@ install_using_github() { check_packages git fi if [ "${architecture}" = "amd64" ]; then + architecture="amd64" + elif [ "${architecture}" = "x86_64"]; then + architecture="x86_64" + else architecture="x64" + fi pwsh_url="https://github.com/PowerShell/PowerShell" find_version_from_git_tags POWERSHELL_VERSION $pwsh_url @@ -212,7 +308,12 @@ install_using_github() { fi # Ugly - but only way to get sha256 is to parse release HTML. Remove newlines and tags, then look for filename followed by 64 hex characters. - curl -sSL -o "release.html" "https://github.com/PowerShell/PowerShell/releases/tag/v${POWERSHELL_VERSION}" + #curl -sSL -o "release.html" "https://github.com/PowerShell/PowerShell/releases/tag/v${POWERSHELL_VERSION}" + wget https://github.com/PowerShell/PowerShell/releases/download/v${POWERSHELL_VERSION}/${powershell_filename} + mkdir ~/powershell + tar -xvf powershell-${POWERSHELL_VERSION}-linux-x64.tar.gz -C ~/powershell + + powershell_archive_sha256="$(cat release.html | tr '\n' ' ' | sed 's|<[^>]*>||g' | grep -oP "${powershell_filename}\s+\K[0-9a-fA-F]{64}" || echo '')" if [ -z "${powershell_archive_sha256}" ]; then echo "(!) WARNING: Failed to retrieve SHA256 for archive. Skipping validaiton." @@ -233,14 +334,22 @@ if ! type pwsh >/dev/null 2>&1; then # Source /etc/os-release to get OS info . /etc/os-release - architecture="$(dpkg --print-architecture)" + architecture="$(uname -m)" + if [[ "$ID" == "ubuntu" || "$ID" == "debian" ]]; then + POWERSHELL_ARCHIVE_ARCHITECTURES="${POWERSHELL_ARCHIVE_ARCHITECTURES_UBUNTU}" + elif [[ "$ID" == "centos" || "$ID" == "rhel" || "$ID" == "almalinux" ]]; then + POWERSHELL_ARCHIVE_ARCHITECTURES="${POWERSHELL_ARCHIVE_ARCHITECTURES_ALMALINUX}" + fi - if [[ "${POWERSHELL_ARCHIVE_ARCHITECTURES}" = *"${architecture}"* ]] && [[ "${POWERSHELL_ARCHIVE_VERSION_CODENAMES}" = *"${VERSION_CODENAME}"* ]]; then + if [[ "${POWERSHELL_ARCHIVE_ARCHITECTURES}" = *"${POWERSHELL_ARCHIVE_ARCHITECTURES_UBUNTU}"* ]] && [[ "${POWERSHELL_ARCHIVE_VERSION_CODENAMES}" = *"${VERSION_CODENAME}"* ]]; then install_using_apt || use_github="true" - else - use_github="true" - fi + elif [[ "${POWERSHELL_ARCHIVE_ARCHITECTURES}" = *"${POWERSHELL_ARCHIVE_ARCHITECTURES_ALMALINUX}"* ]]; then + install_using_dnf && install_powershell_dnf || use_github="true" + else + use_github="true" + fi + if [ "${use_github}" = "true" ]; then echo "Attempting install from GitHub release..." install_using_github @@ -276,10 +385,10 @@ if [ -n "$POWERSHELL_PROFILE_URL" ]; then echo "Downloading PowerShell Profile from: $POWERSHELL_PROFILE_URL" # Get profile path from currently installed pwsh profilePath=$(pwsh -noni -c '$PROFILE.AllUsersAllHosts') - sudo -E curl -sSL -o "$profilePath" "$POWERSHELL_PROFILE_URL" + -E curl -sSL -o "$profilePath" "$POWERSHELL_PROFILE_URL" fi # Clean up rm -rf /var/lib/apt/lists/* -echo "Done!" +echo "Done!" \ No newline at end of file diff --git a/test/powershell/powershell_alma_linux.sh b/test/powershell/powershell_alma_linux.sh new file mode 100644 index 000000000..b9e171624 --- /dev/null +++ b/test/powershell/powershell_alma_linux.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# Run PowerShell command to check installation +pwsh --version &> /dev/null + +# Check if the command was successful +if [ $? -eq 0 ]; then + echo "PowerShell is installed." +else + echo "PowerShell is not installed." + exit 1 +fi \ No newline at end of file diff --git a/test/powershell/scenarios.json b/test/powershell/scenarios.json index 87a5b9d16..781ebaf86 100644 --- a/test/powershell/scenarios.json +++ b/test/powershell/scenarios.json @@ -30,5 +30,11 @@ "features": { "powershell": {} } + }, + "powershell_alma_linux": { + "image": "almalinux:9", + "features": { + "powershell": {} + } } } From f4c2765da0b1a28f007542d0489ad5f6aa5f94cf Mon Sep 17 00:00:00 2001 From: sireeshajonnalagadda Date: Fri, 21 Mar 2025 10:29:13 +0000 Subject: [PATCH 03/15] modifications to the test cases --- test/powershell/powershell_alma_linux.sh | 26 +++++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/test/powershell/powershell_alma_linux.sh b/test/powershell/powershell_alma_linux.sh index b9e171624..8b653afe5 100644 --- a/test/powershell/powershell_alma_linux.sh +++ b/test/powershell/powershell_alma_linux.sh @@ -1,12 +1,18 @@ #!/bin/bash -# Run PowerShell command to check installation -pwsh --version &> /dev/null - -# Check if the command was successful -if [ $? -eq 0 ]; then - echo "PowerShell is installed." -else - echo "PowerShell is not installed." - exit 1 -fi \ No newline at end of file +set -e + +# Import test library for `check` command +source dev-container-features-test-lib + +# Extension-specific tests +check "pwsh file is symlink" bash -c "[ -L /usr/bin/pwsh ]" +check "pwsh symlink is registered as shell" bash -c "[ $(grep -c '/usr/bin/pwsh' /etc/shells) -ge 1 ]" +check "pwsh target is correct" bash -c "[ $(readlink /usr/bin/pwsh) = /opt/microsoft/powershell/7/pwsh ]" +check "pwsh owner is root" bash -c "[ $(stat -c %U /opt/microsoft/powershell/7/pwsh) = root ]" +check "pwsh group is root" bash -c "[ $(stat -c %G /opt/microsoft/powershell/7/pwsh) = root ]" +check "pwsh file mode is -rwxr-xr-x" bash -c "[ $(stat -c '%A' /opt/microsoft/powershell/7/pwsh) = '-rwxr-xr-x' ]" +check "pwsh is in PATH" bash -c "command -v pwsh" + +# Report result +reportResults \ No newline at end of file From 5742821b26240bb69887236a3490bdba9efa1216 Mon Sep 17 00:00:00 2001 From: sireeshajonnalagadda Date: Fri, 21 Mar 2025 16:27:03 +0530 Subject: [PATCH 04/15] Delete test/common-utils/configure_zsh_as_default_shell/Dockerfile Deleting the file as it is no longer needed No modifications needed inside the Dockerfile set the containerEnv to work with default shell --- .../configure_zsh_as_default_shell/Dockerfile | 103 ------------------ 1 file changed, 103 deletions(-) delete mode 100644 test/common-utils/configure_zsh_as_default_shell/Dockerfile diff --git a/test/common-utils/configure_zsh_as_default_shell/Dockerfile b/test/common-utils/configure_zsh_as_default_shell/Dockerfile deleted file mode 100644 index 2ab3a8973..000000000 --- a/test/common-utils/configure_zsh_as_default_shell/Dockerfile +++ /dev/null @@ -1,103 +0,0 @@ -#------------------------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. -#------------------------------------------------------------------------------------------------------------- - - FROM ubuntu:focal - - COPY first-run-notice.txt /tmp/scripts/ - - RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ - # Restore man command - && yes | unminimize 2>&1 - - ENV LANG="C.UTF-8" - - # Install basic build tools - RUN apt-get update \ - && apt-get upgrade -y \ - && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - make \ - unzip \ - # The tools in this package are used when installing packages for Python - build-essential \ - swig3.0 \ - # Required for Microsoft SQL Server - unixodbc-dev \ - # Required for PostgreSQL - libpq-dev \ - # Required for mysqlclient - default-libmysqlclient-dev \ - # Required for ts - moreutils \ - rsync \ - zip \ - libgdiplus \ - jq \ - # By default pip is not available in the buildpacks image - python-pip-whl \ - python3-pip \ - #.NET Core related pre-requisites - libc6 \ - libgcc1 \ - libgssapi-krb5-2 \ - libncurses5 \ - liblttng-ust0 \ - libssl-dev \ - libstdc++6 \ - zlib1g \ - libuuid1 \ - libunwind8 \ - sqlite3 \ - libsqlite3-dev \ - software-properties-common \ - tk-dev \ - uuid-dev \ - curl \ - gettext \ - inotify-tools \ - && rm -rf /var/lib/apt/lists/* \ - # This is the folder containing 'links' to benv and build script generator - && apt-get update \ - && apt-get upgrade -y \ - && add-apt-repository universe \ - && rm -rf /var/lib/apt/lists/* - - # Verify expected build and debug tools are present - RUN apt-get update \ - && apt-get -y install build-essential cmake cppcheck valgrind clang lldb llvm gdb python3-dev \ - # Install tools and shells not in common script - && apt-get install -yq vim vim-doc xtail software-properties-common libsecret-1-dev \ - # Install additional tools (useful for 'puppeteer' project) - && apt-get install -y --no-install-recommends libnss3 libnspr4 libatk-bridge2.0-0 libatk1.0-0 libx11-6 libpangocairo-1.0-0 \ - libx11-xcb1 libcups2 libxcomposite1 libxdamage1 libxfixes3 libpango-1.0-0 libgbm1 libgtk-3-0 \ - # Clean up - && apt-get autoremove -y && apt-get clean -y \ - # Move first run notice to right spot - && mkdir -p "/usr/local/etc/vscode-dev-containers/" \ - && mv -f /tmp/scripts/first-run-notice.txt /usr/local/etc/vscode-dev-containers/ - - # Default to bash shell (other shells available at /usr/bin/fish and /usr/bin/zsh) - ENV DOCKER_BUILDKIT=1 - - # Install and setup fish - RUN apt-get install -yq fish \ - && FISH_PROMPT="function fish_prompt\n set_color green\n echo -n (whoami)\n set_color normal\n echo -n \":\"\n set_color blue\n echo -n (pwd)\n set_color normal\n echo -n \"> \"\nend\n" \ - && printf "$FISH_PROMPT" >> /etc/fish/functions/fish_prompt.fish \ - && printf "if type code-insiders > /dev/null 2>&1; and not type code > /dev/null 2>&1\n alias code=code-insiders\nend" >> /etc/fish/conf.d/code_alias.fish - - # Remove scripts now that we're done with them - RUN apt-get clean -y && rm -rf /tmp/scripts - - # Mount for docker-in-docker - VOLUME [ "/var/lib/docker" ] - - CMD [ "sleep", "infinity" ] - - # [Optional] Install debugger for development of Codespaces - Not in resulting image by default - ARG DeveloperBuild - RUN if [ -z $DeveloperBuild ]; then \ - echo "not including debugger" ; \ - else \ - curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l /vsdbg ; \ - fi \ No newline at end of file From 5f1ce528ad21ff3de9f46d6377234e3b2b62eee8 Mon Sep 17 00:00:00 2001 From: sireeshajonnalagadda Date: Fri, 21 Mar 2025 11:02:13 +0000 Subject: [PATCH 05/15] remove sudo --- src/powershell/install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/powershell/install.sh b/src/powershell/install.sh index d1eb93d3d..9c66cb5e4 100755 --- a/src/powershell/install.sh +++ b/src/powershell/install.sh @@ -146,8 +146,8 @@ apt_get_update() for package in "$@"; do if ! dpkg -s "$package" > /dev/null 2>&1; then echo "Package $package not installed. Installing using apt-get..." - sudo apt-get update - sudo apt-get install -y --no-install-recommends "$package" + apt-get update + apt-get install -y --no-install-recommends "$package" else echo "Package $package is already installed (APT)." fi From b34156235811268fbdc328f583bd59c8652494bf Mon Sep 17 00:00:00 2001 From: sireeshajonnalagadda Date: Mon, 24 Mar 2025 04:55:45 +0000 Subject: [PATCH 06/15] made changes --- src/powershell/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/powershell/install.sh b/src/powershell/install.sh index 9c66cb5e4..f4c6a3dda 100755 --- a/src/powershell/install.sh +++ b/src/powershell/install.sh @@ -385,7 +385,7 @@ if [ -n "$POWERSHELL_PROFILE_URL" ]; then echo "Downloading PowerShell Profile from: $POWERSHELL_PROFILE_URL" # Get profile path from currently installed pwsh profilePath=$(pwsh -noni -c '$PROFILE.AllUsersAllHosts') - -E curl -sSL -o "$profilePath" "$POWERSHELL_PROFILE_URL" + curl -sSL -o "$profilePath" "$POWERSHELL_PROFILE_URL" fi # Clean up From 8aa22b29a7ee9dbe2e38e5a765eac36730946585 Mon Sep 17 00:00:00 2001 From: sireeshajonnalagadda Date: Mon, 24 Mar 2025 06:18:02 +0000 Subject: [PATCH 07/15] adding -E to preserve env variables --- src/powershell/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/powershell/install.sh b/src/powershell/install.sh index f4c6a3dda..ce31e49fe 100755 --- a/src/powershell/install.sh +++ b/src/powershell/install.sh @@ -385,7 +385,7 @@ if [ -n "$POWERSHELL_PROFILE_URL" ]; then echo "Downloading PowerShell Profile from: $POWERSHELL_PROFILE_URL" # Get profile path from currently installed pwsh profilePath=$(pwsh -noni -c '$PROFILE.AllUsersAllHosts') - curl -sSL -o "$profilePath" "$POWERSHELL_PROFILE_URL" + sudo -E curl -sSL -o "$profilePath" "$POWERSHELL_PROFILE_URL" fi # Clean up From c5613bea9400c8bd24903f250e61b6b78343e70d Mon Sep 17 00:00:00 2001 From: sireeshajonnalagadda Date: Mon, 24 Mar 2025 06:25:02 +0000 Subject: [PATCH 08/15] correcting errors --- src/powershell/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/powershell/install.sh b/src/powershell/install.sh index ce31e49fe..a184cba64 100755 --- a/src/powershell/install.sh +++ b/src/powershell/install.sh @@ -294,7 +294,7 @@ install_using_github() { fi if [ "${architecture}" = "amd64" ]; then architecture="amd64" - elif [ "${architecture}" = "x86_64"]; then + elif [ "${architecture}" = "x86_64" ]; then architecture="x86_64" else architecture="x64" From 05c37d442d9f26436832b5c98c048591a13aafa3 Mon Sep 17 00:00:00 2001 From: sireeshajonnalagadda Date: Tue, 25 Mar 2025 07:38:58 +0000 Subject: [PATCH 09/15] made the requested changes --- src/powershell/install.sh | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/powershell/install.sh b/src/powershell/install.sh index a184cba64..39ab2b351 100755 --- a/src/powershell/install.sh +++ b/src/powershell/install.sh @@ -21,6 +21,9 @@ MICROSOFT_GPG_KEYS_URI="https://packages.microsoft.com/keys/microsoft.asc" POWERSHELL_ARCHIVE_ARCHITECTURES_UBUNTU="amd64" POWERSHELL_ARCHIVE_ARCHITECTURES_ALMALINUX="x86_64" POWERSHELL_ARCHIVE_VERSION_CODENAMES="stretch buster bionic focal bullseye jammy bookworm noble" + +#These key servers are used to verify the authenticity of packages and repositories. +#keyservers for ubuntu and almalinux are different so we need to specify both GPG_KEY_SERVERS="keyserver hkp://keyserver.ubuntu.com keyserver hkp://keyserver.ubuntu.com:80 keyserver hkps://keys.openpgp.org @@ -292,13 +295,10 @@ install_using_github() { if ! type git > /dev/null 2>&1; then check_packages git fi - if [ "${architecture}" = "amd64" ]; then + if [ "${architecture}" = "x86_64" ]; then architecture="amd64" - elif [ "${architecture}" = "x86_64" ]; then - architecture="x86_64" else - architecture="x64" - + architecture="x64" fi pwsh_url="https://github.com/PowerShell/PowerShell" find_version_from_git_tags POWERSHELL_VERSION $pwsh_url @@ -306,9 +306,7 @@ install_using_github() { if grep -q "Not Found" "${powershell_filename}"; then install_prev_pwsh $pwsh_url fi - - # Ugly - but only way to get sha256 is to parse release HTML. Remove newlines and tags, then look for filename followed by 64 hex characters. - #curl -sSL -o "release.html" "https://github.com/PowerShell/PowerShell/releases/tag/v${POWERSHELL_VERSION}" + wget https://github.com/PowerShell/PowerShell/releases/download/v${POWERSHELL_VERSION}/${powershell_filename} mkdir ~/powershell tar -xvf powershell-${POWERSHELL_VERSION}-linux-x64.tar.gz -C ~/powershell From 1a1ce827b3e07132a6691dc780608050383e5ab0 Mon Sep 17 00:00:00 2001 From: sireeshajonnalagadda Date: Wed, 26 Mar 2025 12:04:31 +0000 Subject: [PATCH 10/15] using dnf to check the packages --- src/powershell/install.sh | 30 ++++++++++--------- test/common-utils/alma-8_for_powershell.sh | 12 ++++++++ .../.devcontainer/Dockerfile | 1 + .../alma-8_for_powershell/powershell.sh | 10 +++++++ test/nvidia-cuda/install_cuda_12.4_smi.sh | 18 +++++++++++ 5 files changed, 57 insertions(+), 14 deletions(-) create mode 100644 test/common-utils/alma-8_for_powershell.sh create mode 100644 test/common-utils/alma-8_for_powershell/.devcontainer/Dockerfile create mode 100644 test/common-utils/alma-8_for_powershell/powershell.sh create mode 100644 test/nvidia-cuda/install_cuda_12.4_smi.sh diff --git a/src/powershell/install.sh b/src/powershell/install.sh index 39ab2b351..fec57d2f4 100755 --- a/src/powershell/install.sh +++ b/src/powershell/install.sh @@ -155,20 +155,21 @@ apt_get_update() echo "Package $package is already installed (APT)." fi done - elif command -v rpm > /dev/null 2>&1 && command -v dnf > /dev/null 2>&1; then - # If rpm and dnf exist, assume DNF-based system (RHEL/AlmaLinux) - for package in "$@"; do - if ! rpm -q "$package" > /dev/null 2>&1; then - echo "Package $package not installed. Installing using dnf..." - dnf install -y "$package" - else - echo "Package $package is already installed (DNF)." - fi - done - else - echo "Unsupported package manager. Neither APT nor DNF found." - return 1 - fi + elif command -v dnf > /dev/null 2>&1; then + for package in "$@"; do + if ! dnf list installed "$package" > /dev/null 2>&1; then + echo "Package $package not installed. Installing using dnf..." + dnf install -y "$package" + else + echo "Package $package is already installed (DNF)." + fi + done +else + echo "Unsupported package manager. Neither APT nor DNF found." + return 1 +fi + + } install_using_apt() { @@ -307,6 +308,7 @@ install_using_github() { install_prev_pwsh $pwsh_url fi + # downlaod the latest version of powershell and extracting the file to powershell directory wget https://github.com/PowerShell/PowerShell/releases/download/v${POWERSHELL_VERSION}/${powershell_filename} mkdir ~/powershell tar -xvf powershell-${POWERSHELL_VERSION}-linux-x64.tar.gz -C ~/powershell diff --git a/test/common-utils/alma-8_for_powershell.sh b/test/common-utils/alma-8_for_powershell.sh new file mode 100644 index 000000000..b9e171624 --- /dev/null +++ b/test/common-utils/alma-8_for_powershell.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# Run PowerShell command to check installation +pwsh --version &> /dev/null + +# Check if the command was successful +if [ $? -eq 0 ]; then + echo "PowerShell is installed." +else + echo "PowerShell is not installed." + exit 1 +fi \ No newline at end of file diff --git a/test/common-utils/alma-8_for_powershell/.devcontainer/Dockerfile b/test/common-utils/alma-8_for_powershell/.devcontainer/Dockerfile new file mode 100644 index 000000000..948936034 --- /dev/null +++ b/test/common-utils/alma-8_for_powershell/.devcontainer/Dockerfile @@ -0,0 +1 @@ +FROM almalinux \ No newline at end of file diff --git a/test/common-utils/alma-8_for_powershell/powershell.sh b/test/common-utils/alma-8_for_powershell/powershell.sh new file mode 100644 index 000000000..b812380b3 --- /dev/null +++ b/test/common-utils/alma-8_for_powershell/powershell.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +dnf install -y wget +wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq && chmod +x /usr/bin/yq +dnf install -y krb5-libs libicu openssl-libs zlib +# Problem: conflicting requests +# - nothing provides krb5 needed by powershell-7.5.0-1.cm.aarch64 from @commandline +latest_release=$(curl -s https://api.github.com/repos/PowerShell/PowerShell/releases/latest) && \ + sudo rpmlink=$(echo "$latest_release" | arch=$(arch) yq -r '[.assets[] | select(.name == ("*" + strenv(arch) + ".rpm")) | .browser_download_url'][0]) && \ + sudo dnf install -y $rpmlink \ No newline at end of file diff --git a/test/nvidia-cuda/install_cuda_12.4_smi.sh b/test/nvidia-cuda/install_cuda_12.4_smi.sh new file mode 100644 index 000000000..c82af4847 --- /dev/null +++ b/test/nvidia-cuda/install_cuda_12.4_smi.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Check installation of cuda-nvtx-12-4 (12.4) +check "cuda-12-4+nvtx" test -e '/usr/local/cuda-12.4/targets/x86_64-linux/include/nvtx3/' + +# Verify CUDA toolkit installation +check "nvcc" nvcc --version + +# Verify PATH environment variable +check "cuda-path" echo $PATH | grep -q "/usr/local/cuda-12.4/bin" + +# Report result +reportResults From 3662f0f79221dd83a7007aa9a2b68366067d374b Mon Sep 17 00:00:00 2001 From: sireeshajonnalagadda Date: Wed, 26 Mar 2025 12:06:54 +0000 Subject: [PATCH 11/15] using dnf to check the packages --- test/nvidia-cuda/install_cuda_12.4_smi.sh | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 test/nvidia-cuda/install_cuda_12.4_smi.sh diff --git a/test/nvidia-cuda/install_cuda_12.4_smi.sh b/test/nvidia-cuda/install_cuda_12.4_smi.sh deleted file mode 100644 index c82af4847..000000000 --- a/test/nvidia-cuda/install_cuda_12.4_smi.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -set -e - -# Optional: Import test library -source dev-container-features-test-lib - -# Check installation of cuda-nvtx-12-4 (12.4) -check "cuda-12-4+nvtx" test -e '/usr/local/cuda-12.4/targets/x86_64-linux/include/nvtx3/' - -# Verify CUDA toolkit installation -check "nvcc" nvcc --version - -# Verify PATH environment variable -check "cuda-path" echo $PATH | grep -q "/usr/local/cuda-12.4/bin" - -# Report result -reportResults From 648095f2ba92572b96922de03d950ab2efe36c33 Mon Sep 17 00:00:00 2001 From: sireeshajonnalagadda Date: Fri, 28 Mar 2025 06:09:25 +0000 Subject: [PATCH 12/15] bumping up the version --- src/powershell/devcontainer-feature.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/powershell/devcontainer-feature.json b/src/powershell/devcontainer-feature.json index 585e34630..e8b0ab372 100644 --- a/src/powershell/devcontainer-feature.json +++ b/src/powershell/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "powershell", - "version": "1.5.0", + "version": "1.6.0", "name": "PowerShell", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/powershell", "description": "Installs PowerShell along with needed dependencies. Useful for base Dockerfiles that often are missing required install dependencies like gpg.", From 2dace01ace8240ae58dc882abab3fc539cef852e Mon Sep 17 00:00:00 2001 From: sireeshajonnalagadda Date: Fri, 28 Mar 2025 06:22:44 +0000 Subject: [PATCH 13/15] bump up the powershell version for Almalinux support --- src/powershell/devcontainer-feature.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/powershell/devcontainer-feature.json b/src/powershell/devcontainer-feature.json index e8b0ab372..82dbb603b 100644 --- a/src/powershell/devcontainer-feature.json +++ b/src/powershell/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "powershell", - "version": "1.6.0", + "version": "1.5.1", "name": "PowerShell", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/powershell", "description": "Installs PowerShell along with needed dependencies. Useful for base Dockerfiles that often are missing required install dependencies like gpg.", From 909b1c695cd8ef09b2c52188d16a0332b69f3534 Mon Sep 17 00:00:00 2001 From: sireeshajonnalagadda Date: Mon, 31 Mar 2025 08:53:51 +0000 Subject: [PATCH 14/15] removal of x86_64 --- src/powershell/install.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/powershell/install.sh b/src/powershell/install.sh index fec57d2f4..3da7a231b 100755 --- a/src/powershell/install.sh +++ b/src/powershell/install.sh @@ -296,10 +296,9 @@ install_using_github() { if ! type git > /dev/null 2>&1; then check_packages git fi - if [ "${architecture}" = "x86_64" ]; then - architecture="amd64" - else - architecture="x64" + + if [ "${architecture}" = "amd64" ]; then + architecture="x64" fi pwsh_url="https://github.com/PowerShell/PowerShell" find_version_from_git_tags POWERSHELL_VERSION $pwsh_url From 275dbda52d2f19da2d10b5eab20b5bc020936749 Mon Sep 17 00:00:00 2001 From: sireeshajonnalagadda Date: Mon, 31 Mar 2025 09:37:47 +0000 Subject: [PATCH 15/15] local tests files not required for this PR --- test/common-utils/alma-8_for_powershell.sh | 12 ------------ .../alma-8_for_powershell/.devcontainer/Dockerfile | 1 - .../common-utils/alma-8_for_powershell/powershell.sh | 10 ---------- 3 files changed, 23 deletions(-) delete mode 100644 test/common-utils/alma-8_for_powershell.sh delete mode 100644 test/common-utils/alma-8_for_powershell/.devcontainer/Dockerfile delete mode 100644 test/common-utils/alma-8_for_powershell/powershell.sh diff --git a/test/common-utils/alma-8_for_powershell.sh b/test/common-utils/alma-8_for_powershell.sh deleted file mode 100644 index b9e171624..000000000 --- a/test/common-utils/alma-8_for_powershell.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -# Run PowerShell command to check installation -pwsh --version &> /dev/null - -# Check if the command was successful -if [ $? -eq 0 ]; then - echo "PowerShell is installed." -else - echo "PowerShell is not installed." - exit 1 -fi \ No newline at end of file diff --git a/test/common-utils/alma-8_for_powershell/.devcontainer/Dockerfile b/test/common-utils/alma-8_for_powershell/.devcontainer/Dockerfile deleted file mode 100644 index 948936034..000000000 --- a/test/common-utils/alma-8_for_powershell/.devcontainer/Dockerfile +++ /dev/null @@ -1 +0,0 @@ -FROM almalinux \ No newline at end of file diff --git a/test/common-utils/alma-8_for_powershell/powershell.sh b/test/common-utils/alma-8_for_powershell/powershell.sh deleted file mode 100644 index b812380b3..000000000 --- a/test/common-utils/alma-8_for_powershell/powershell.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -dnf install -y wget -wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq && chmod +x /usr/bin/yq -dnf install -y krb5-libs libicu openssl-libs zlib -# Problem: conflicting requests -# - nothing provides krb5 needed by powershell-7.5.0-1.cm.aarch64 from @commandline -latest_release=$(curl -s https://api.github.com/repos/PowerShell/PowerShell/releases/latest) && \ - sudo rpmlink=$(echo "$latest_release" | arch=$(arch) yq -r '[.assets[] | select(.name == ("*" + strenv(arch) + ".rpm")) | .browser_download_url'][0]) && \ - sudo dnf install -y $rpmlink \ No newline at end of file