Skip to content

Commit 0f54799

Browse files
authored
fix(rust): support Azure Linux base images (#1685)
1 parent 6c375f1 commit 0f54799

6 files changed

Lines changed: 50 additions & 8 deletions

File tree

src/rust/NOTES.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
## OS Support
44

5-
This Feature should work on recent versions of Debian/Ubuntu, RedHat Enterprise Linux, Fedora, Alma, RockyLinux
6-
and Mariner distributions with the `apt`, `yum`, `dnf`, `microdnf` and `tdnf` package manager installed.
5+
This Feature should work on recent versions of Debian/Ubuntu, RedHat Enterprise Linux, Fedora, Alma, RockyLinux,
6+
Mariner and Azure Linux distributions with the `apt`, `yum`, `dnf`, `microdnf` and `tdnf` package manager installed.
77

88

99
**Note:** Alpine is not supported because the rustup-init binary requires glibc to run, but Alpine Linux does not include `glibc`

src/rust/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ Installs Rust, common Rust utilities, and their required dependencies
3232

3333
## OS Support
3434

35-
This Feature should work on recent versions of Debian/Ubuntu, RedHat Enterprise Linux, Fedora, Alma, RockyLinux
36-
and Mariner distributions with the `apt`, `yum`, `dnf`, `microdnf` and `tdnf` package manager installed.
35+
This Feature should work on recent versions of Debian/Ubuntu, RedHat Enterprise Linux, Fedora, Alma, RockyLinux,
36+
Mariner and Azure Linux distributions with the `apt`, `yum`, `dnf`, `microdnf` and `tdnf` package manager installed.
3737

3838

3939
**Note:** Alpine is not supported because the rustup-init binary requires glibc to run, but Alpine Linux does not include `glibc`

src/rust/devcontainer-feature.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "rust",
3-
"version": "1.5.0",
3+
"version": "1.5.1",
44
"name": "Rust",
55
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/rust",
66
"description": "Installs Rust, common Rust utilities, and their required dependencies",

src/rust/install.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ if [ "${ID}" = "debian" ] || [ "${ID_LIKE}" = "debian" ]; then
3030
ADJUSTED_ID="debian"
3131
elif [ "${ID}" = "alpine" ]; then
3232
ADJUSTED_ID="alpine"
33-
elif [[ "${ID}" = "rhel" || "${ID}" = "fedora" || "${ID}" = "mariner" || "${ID_LIKE}" = *"rhel"* || "${ID_LIKE}" = *"fedora"* || "${ID_LIKE}" = *"mariner"* ]]; then
33+
elif [[ "${ID}" = "rhel" || "${ID}" = "fedora" || "${ID}" = "azurelinux" || "${ID}" = "mariner" || "${ID_LIKE}" = *"rhel"* || "${ID_LIKE}" = *"fedora"* || "${ID_LIKE}" = *"azurelinux"* || "${ID_LIKE}" = *"mariner"* ]]; then
3434
ADJUSTED_ID="rhel"
3535
VERSION_CODENAME="${ID}${VERSION_ID}"
3636
else
@@ -264,6 +264,7 @@ check_packages() {
264264
"python3-minimal") packages[$i]="python3" ;;
265265
"libpython3.*") packages[$i]="python3-devel" ;;
266266
"gnupg2") packages[$i]="gnupg" ;;
267+
"passwd") packages[$i]="shadow-utils" ;;
267268
esac
268269
;;
269270
esac
@@ -303,7 +304,7 @@ export DEBIAN_FRONTEND=noninteractive
303304

304305
# Install curl, lldb, python3-minimal,libpython and rust dependencies if missing
305306
echo "Installing required dependencies..."
306-
check_packages curl ca-certificates gcc libc6-dev gnupg2 git
307+
check_packages curl ca-certificates gcc libc6-dev gnupg2 git passwd
307308

308309
# Install optional dependencies (continue if they fail)
309310
case "$PKG_MANAGER" in
@@ -315,7 +316,7 @@ case "$PKG_MANAGER" in
315316
;;
316317
tdnf)
317318
check_packages python3 python3-devel || true
318-
# LLDB might not be available in Photon/Mariner
319+
# LLDB might not be available in Photon/Mariner/Azure Linux
319320
;;
320321
esac
321322

test/rust/rust_with_azurelinux.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Optional: Import test library
6+
source dev-container-features-test-lib
7+
8+
# Helper function to check component is installed
9+
check_component_installed() {
10+
local component=$1
11+
if rustup component list | grep -q "${component}.*installed"; then
12+
return 0 # Component is installed (success)
13+
else
14+
return 1 # Component is not installed (failure)
15+
fi
16+
}
17+
18+
# Definition specific tests
19+
check "cargo version" cargo --version
20+
check "rustc version" rustc --version
21+
check "correct rust version" rustup target list | grep aarch64-unknown-linux-gnu
22+
23+
# Check that all specified extended components are installed
24+
check "rust-analyzer is installed" check_component_installed "rust-analyzer"
25+
check "rust-src is installed" check_component_installed "rust-src"
26+
check "rustfmt is installed" check_component_installed "rustfmt"
27+
check "clippy is installed" check_component_installed "clippy"
28+
check "rust-docs is installed" check_component_installed "rust-docs"
29+
30+
# Report result
31+
reportResults

test/rust/scenarios.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,5 +134,15 @@
134134
"components": "rust-analyzer,rust-src,rustfmt,clippy,rust-docs"
135135
}
136136
}
137+
},
138+
"rust_with_azurelinux": {
139+
"image": "mcr.microsoft.com/azurelinux/base/core:3.0",
140+
"features": {
141+
"rust": {
142+
"version": "latest",
143+
"targets": "aarch64-unknown-linux-gnu",
144+
"components": "rust-analyzer,rust-src,rustfmt,clippy,rust-docs"
145+
}
146+
}
137147
}
138148
}

0 commit comments

Comments
 (0)