Skip to content

Commit a1a0998

Browse files
CopilotKaniska244
andauthored
Handle PowerShell RC versions in preview install path (#1608)
* Fix powershell preview/RC version installation failure - Add -rc. version checks alongside preview checks in routing conditions so RC versions go directly to GitHub install instead of apt/dnf - Update find_preview_version_from_git_tags() to match -rc.X git tags - Fix typo googlegit_cmd_name -> git_cmd_name - Update preview test scripts to match both preview and rc.X patterns Co-authored-by: Kaniska244 <[email protected]> Agent-Logs-Url: https://github.com/devcontainers/features/sessions/03fd0565-a230-4bd9-80f7-92b8ce74a1bb * Version bump: powershell feature 2.0.1 → 2.0.2 Co-authored-by: Kaniska244 <[email protected]> Agent-Logs-Url: https://github.com/devcontainers/features/sessions/98f1f7bd-4d93-4641-85d8-287b218c1eb8 * Remove ubuntu:focal and debian:11 from arm64 test matrix PowerShell 7.6.0 requires GLIBC_2.33+ which is unavailable on these older platforms. ubuntu:focal is already obsolete and debian:11 reaches EOL in Aug 2026. Agent-Logs-Url: https://github.com/devcontainers/features/sessions/6a803744-ae1d-4c84-8e04-5bb2c0df1523 Co-authored-by: Kaniska244 <[email protected]> * Add comment explaining ubuntu:focal and debian:11 removal from arm64 matrix Agent-Logs-Url: https://github.com/devcontainers/features/sessions/071d8550-7b74-4436-91de-5933b6711bc3 Co-authored-by: Kaniska244 <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Kaniska244 <[email protected]> Co-authored-by: Kaniska <[email protected]>
1 parent 3df3aed commit a1a0998

6 files changed

Lines changed: 21 additions & 15 deletions

File tree

.github/workflows/test-pr-arm64.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,12 @@ jobs:
3131
strategy:
3232
matrix:
3333
features: ${{ fromJSON(needs.detect-changes.outputs.features) }}
34+
# NOTE: ubuntu:focal and debian:11 are excluded because they ship
35+
# GLIBC 2.31, but PowerShell >= 7.6.0 requires GLIBC 2.33+ on arm64.
36+
# ubuntu:focal reached EOL Apr 2025; debian:11 reaches EOL Aug 2026.
3437
baseImage:
3538
[
36-
"ubuntu:focal",
3739
"ubuntu:jammy",
38-
"debian:11",
3940
"debian:12",
4041
"mcr.microsoft.com/devcontainers/base:ubuntu",
4142
"mcr.microsoft.com/devcontainers/base:debian",

src/powershell/devcontainer-feature.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "powershell",
3-
"version": "2.0.1",
3+
"version": "2.0.2",
44
"name": "PowerShell",
55
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/powershell",
66
"description": "Installs PowerShell along with needed dependencies. Useful for base Dockerfiles that often are missing required install dependencies like gpg.",

src/powershell/install.sh

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ find_preview_version_from_git_tags() {
126126
local requested_version=${!variable_name}
127127
local repository_url=$2
128128

129-
if [ -z "${googlegit_cmd_name}" ]; then
129+
if [ -z "${git_cmd_name}" ]; then
130130
if type git > /dev/null 2>&1; then
131131
git_cmd_name="git"
132132
else
@@ -135,22 +135,22 @@ find_preview_version_from_git_tags() {
135135
fi
136136
fi
137137

138-
# Fetch tags from remote repository
138+
# Fetch tags from remote repository (match both -preview.X and -rc.X tags)
139139
local tags
140-
tags=$(git ls-remote --tags "${repository_url}" 2>/dev/null | grep -oP 'refs/tags/v\K[0-9]+\.[0-9]+\.[0-9]+-preview\.[0-9]+' | sort -V)
140+
tags=$(git ls-remote --tags "${repository_url}" 2>/dev/null | grep -oP 'refs/tags/v\K[0-9]+\.[0-9]+\.[0-9]+-(preview|rc)\.[0-9]+' | sort -V)
141141

142142
if [ -z "${tags}" ]; then
143-
echo "No preview tags found in repository."
143+
echo "No preview/rc tags found in repository."
144144
return 1
145145
fi
146146

147147
local version=""
148148

149149
if [ "${requested_version}" = "preview" ] || [ "${requested_version}" = "latest" ]; then
150-
# Get the latest preview version
150+
# Get the latest preview/rc version
151151
version=$(echo "${tags}" | tail -n 1)
152152
elif [[ "${requested_version}" =~ ^[0-9]+\.[0-9]+$ ]]; then
153-
# Partial version provided (e.g., "7.6"), find latest preview matching that major.minor
153+
# Partial version provided (e.g., "7.6"), find latest preview/rc matching that major.minor
154154
version=$(echo "${tags}" | grep "^${requested_version}\." | tail -n 1)
155155
elif [[ "${requested_version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+-preview$ ]]; then
156156
# Version like "7.6.0-preview" provided, find latest preview for that version
@@ -161,6 +161,11 @@ find_preview_version_from_git_tags() {
161161
if echo "${tags}" | grep -q "^${requested_version}$"; then
162162
version="${requested_version}"
163163
fi
164+
elif [[ "${requested_version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+-rc\.[0-9]+$ ]]; then
165+
# Exact RC version provided, verify it exists
166+
if echo "${tags}" | grep -q "^${requested_version}$"; then
167+
version="${requested_version}"
168+
fi
164169
fi
165170

166171
if [ -z "${version}" ]; then
@@ -382,7 +387,7 @@ install_using_github() {
382387
fi
383388
pwsh_url="https://github.com/PowerShell/PowerShell"
384389
# Check if we need to find a preview version or stable version
385-
if [[ "${POWERSHELL_VERSION}" == *"preview"* ]] || [ "${POWERSHELL_VERSION}" = "preview" ]; then
390+
if [[ "${POWERSHELL_VERSION}" == *"preview"* ]] || [ "${POWERSHELL_VERSION}" = "preview" ] || [[ "${POWERSHELL_VERSION}" == *"-rc."* ]]; then
386391
echo "Finding preview version..."
387392
find_preview_version_from_git_tags POWERSHELL_VERSION "${pwsh_url}"
388393
else
@@ -446,9 +451,9 @@ if ! type pwsh >/dev/null 2>&1; then
446451
POWERSHELL_ARCHIVE_ARCHITECTURES="${POWERSHELL_ARCHIVE_ARCHITECTURES_ALMALINUX}"
447452
fi
448453

449-
if [[ "${POWERSHELL_ARCHIVE_ARCHITECTURES}" = *"${POWERSHELL_ARCHIVE_ARCHITECTURES_UBUNTU}"* ]] && [[ "${POWERSHELL_ARCHIVE_VERSION_CODENAMES}" = *"${VERSION_CODENAME}"* ]] && [[ "${POWERSHELL_VERSION}" != *"preview"* ]]; then
454+
if [[ "${POWERSHELL_ARCHIVE_ARCHITECTURES}" = *"${POWERSHELL_ARCHIVE_ARCHITECTURES_UBUNTU}"* ]] && [[ "${POWERSHELL_ARCHIVE_VERSION_CODENAMES}" = *"${VERSION_CODENAME}"* ]] && [[ "${POWERSHELL_VERSION}" != *"preview"* ]] && [[ "${POWERSHELL_VERSION}" != *"-rc."* ]]; then
450455
install_using_apt || use_github="true"
451-
elif [[ "${POWERSHELL_ARCHIVE_ARCHITECTURES}" = *"${POWERSHELL_ARCHIVE_ARCHITECTURES_ALMALINUX}"* ]] && [[ "${POWERSHELL_VERSION}" != *"preview"* ]]; then
456+
elif [[ "${POWERSHELL_ARCHIVE_ARCHITECTURES}" = *"${POWERSHELL_ARCHIVE_ARCHITECTURES_ALMALINUX}"* ]] && [[ "${POWERSHELL_VERSION}" != *"preview"* ]] && [[ "${POWERSHELL_VERSION}" != *"-rc."* ]]; then
452457
install_using_dnf && install_powershell_dnf || use_github="true"
453458
else
454459
use_github="true"

test/powershell/powershell_preview_version.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ source dev-container-features-test-lib
77

88
# Test preview version installation
99
check "pwsh is installed" bash -c "command -v pwsh"
10-
check "pwsh version is preview" bash -c "pwsh --version | grep -i 'preview'"
10+
check "pwsh version is preview" bash -c "pwsh --version | grep -iE 'preview|rc\.[0-9]+'"
1111
check "pwsh can execute basic command" bash -c "pwsh -Command 'Write-Output Hello'"
1212

1313
# Report result

test/powershell/powershell_preview_version_almalinux.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ source dev-container-features-test-lib
77

88
# Test preview version installation on AlmaLinux
99
check "pwsh is installed" bash -c "command -v pwsh"
10-
check "pwsh version is preview" bash -c "pwsh --version | grep -i 'preview'"
10+
check "pwsh version is preview" bash -c "pwsh --version | grep -iE 'preview|rc\.[0-9]+'"
1111
check "pwsh can execute basic command" bash -c "pwsh -Command 'Write-Output Hello'"
1212

1313
# Report result

test/powershell/powershell_preview_version_debian.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ source dev-container-features-test-lib
77

88
# Test preview version installation on Debian
99
check "pwsh is installed" bash -c "command -v pwsh"
10-
check "pwsh version is preview" bash -c "pwsh --version | grep -i 'preview'"
10+
check "pwsh version is preview" bash -c "pwsh --version | grep -iE 'preview|rc\.[0-9]+'"
1111
check "pwsh can execute basic command" bash -c "pwsh -Command 'Write-Output Hello'"
1212

1313
# Report result

0 commit comments

Comments
 (0)