Add native Azure Linux 4 RPM packaging (#28107)

Co-authored-by: Justin Chung <chungjustin@microsoft.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2026-10-06 15:52:04 -05:00
1 parent 6116e14622
commit b95da22ffb
5 files changed
+245 -14

No files matched your search

@@ -15,9 +15,37 @@ Describe "Linux Package Name Validation" {
}
Write-Verbose "Artifacts directory: $artifactsDir" -Verbose
# Keep this pattern aligned with the release validation pipeline.
$rpmPackageNamePattern = '^powershell-(preview-|lts-)?\d+\.\d+\.\d+(_[a-z]*\.\d+)?-1\.(preview\.\d+\.)?(rh|cm|azl4)\.(x86_64|aarch64)\.rpm$'
}
Context "RPM Package Names" {
It "Should accept the Azure Linux 4 <Architecture> package name" -TestCases @(
@{
Architecture = "x86_64"
Name = "powershell-preview-7.7.0_preview.5-1.azl4.x86_64.rpm"
}
@{
Architecture = "aarch64"
Name = "powershell-preview-7.7.0_preview.5-1.azl4.aarch64.rpm"
}
) {
param($Name)
$Name | Should -Match $rpmPackageNamePattern
}
It "Should reject malformed RPM package name <Name>" -TestCases @(
@{ Name = "prefix-powershell-preview-7.7.0_preview.5-1.azl4.x86_64.rpm" }
@{ Name = "powershell-preview-7.7.0_preview.5-1Xazl4.x86_64.rpm" }
@{ Name = "powershell-preview-7.7.0_preview.5-1.azl4.x86_64.rpm.backup" }
) {
param($Name)
$Name | Should -Not -Match $rpmPackageNamePattern
}
It "Should have valid RPM package names" {
$rpmPackages = Get-ChildItem -Path $artifactsDir -Recurse -Filter *.rpm -ErrorAction SilentlyContinue
@@ -32,9 +60,8 @@ Describe "Linux Package Name Validation" {
# (_[a-z]*\.\d+)? : Optional underscore, letters, dot, and digits (e.g., _alpha.1)
# -1\. : Literal '-1.'
# (preview\.\d+\.)? : Optional 'preview.' and digits, followed by a dot
# (rh|cm)\. : Either 'rh.' or 'cm.'
# (rh|cm|azl4)\. : RPM distribution suffix
# (x86_64|aarch64)\.rpm$ : Architecture and file extension
$rpmPackageNamePattern = 'powershell\-(preview-|lts-)?\d+\.\d+\.\d+(_[a-z]*\.\d+)?-1\.(preview\.\d+\.)?(rh|cm)\.(x86_64|aarch64)\.rpm'
foreach ($package in $rpmPackages) {
if ($package.Name -notmatch $rpmPackageNamePattern) {
+153
View File
@@ -24,6 +24,159 @@ Describe "Packaging Module Functions" {
}
}
Context "Azure Linux RPM packaging" {
BeforeAll {
$afterInstallScript = Join-Path $TestDrive "after-install.sh"
$afterRemoveScript = Join-Path $TestDrive "after-remove.sh"
"echo installed" | Set-Content -Path $afterInstallScript
"echo removed" | Set-Content -Path $afterRemoveScript
$linkInfo = & (Get-Module packaging) {
[LinkInfo] @{
Source = "/tmp/pwsh"
Destination = "/usr/bin/pwsh"
}
}
}
It "Should target Azure Linux 3 and 4 for framework-dependent RPMs" {
$distributions = & (Get-Module packaging) { $Script:RedhatFddDistributions }
$distributions | Should -Be @("cm", "azl4")
}
It "Should generate an Azure Linux 4 RPM file name for <HostArchitecture>" -TestCases @(
@{
HostArchitecture = "x86_64"
Expected = "powershell-preview-7.7.0_preview.5-1.azl4.x86_64.rpm"
}
@{
HostArchitecture = "aarch64"
Expected = "powershell-preview-7.7.0_preview.5-1.azl4.aarch64.rpm"
}
) {
param($HostArchitecture, $Expected)
Get-RpmPackageFileName `
-Name "powershell-preview" `
-Version "7.7.0-preview.5" `
-Iteration "1" `
-Distribution "azl4" `
-HostArchitecture $HostArchitecture |
Should -BeExactly $Expected
}
It "Should write the Azure Linux 4 RPM Release metadata for <HostArchitecture>" -TestCases @(
@{ HostArchitecture = "x86_64" }
@{ HostArchitecture = "aarch64" }
) {
param($HostArchitecture)
$spec = New-RpmSpec `
-Name "powershell-preview" `
-Version "7.7.0-preview.5" `
-Iteration "1" `
-Description "PowerShell test package" `
-Staging "/tmp/staging" `
-Destination "/opt/microsoft/powershell/7-preview" `
-ManGzipFile "/tmp/pwsh.1.gz" `
-ManDestination "/usr/share/man/man1/pwsh-preview.1.gz" `
-LinkInfo $linkInfo `
-Dependencies @("glibc") `
-AfterInstallScript $afterInstallScript `
-AfterRemoveScript $afterRemoveScript `
-Distribution "azl4" `
-HostArchitecture $HostArchitecture
$spec | Should -Match "(?m)^Release:\s+1\.azl4\r?$"
$spec | Should -Match "(?m)^\* .+ - 7\.7\.0_preview\.5-1\.azl4\r?$"
}
It "Should select the current master dependencies for <Distribution> with runtime <Runtime>" -TestCases @(
@{ Distribution = "cm"; Runtime = "linux-x64"; IncludeDotnetRuntime = $false }
@{ Distribution = "azl4"; Runtime = "linux-arm64"; IncludeDotnetRuntime = $false }
@{ Distribution = "cm"; Runtime = "fxdependent-linux-x64"; IncludeDotnetRuntime = $true }
@{ Distribution = "azl4"; Runtime = "fxdependent-linux-arm64"; IncludeDotnetRuntime = $true }
) {
param($Distribution, $Runtime, $IncludeDotnetRuntime)
$dependencies = & (Get-Module packaging) {
param($Distribution, $Runtime)
$previousOptions = $Script:Options
try {
$Script:Options = [pscustomobject] @{ Runtime = $Runtime }
@(Get-PackageDependencies -Distribution $Distribution)
}
finally {
$Script:Options = $previousOptions
}
} $Distribution $Runtime
$expectedDependencies = @(
"ca-certificates"
"glibc"
"icu"
"libgcc"
"libstdc++"
"openssl-libs"
"tzdata"
)
if ($IncludeDotnetRuntime) {
$expectedDependencies += "dotnet-runtime-11.0"
}
$dependencies | Should -BeExactly $expectedDependencies
}
}
Context "Azure Linux PMC mappings" {
BeforeAll {
$mappingPath = Join-Path $PSScriptRoot "../../tools/packages.microsoft.com/mapping.json"
$mapping = Get-Content -Path $mappingPath -Raw | ConvertFrom-Json
}
It "Should map <Channel> <Architecture> packages to <Url>" -TestCases @(
@{
Channel = "preview"
Architecture = "x86_64"
Url = "azurelinux-4-preview-microsoft-x86_64"
}
@{
Channel = "preview"
Architecture = "aarch64"
Url = "azurelinux-4-preview-microsoft-aarch64"
}
@{
Channel = "stable"
Architecture = "x86_64"
Url = "azurelinux-4-prod-microsoft-x86_64"
}
@{
Channel = "stable"
Architecture = "aarch64"
Url = "azurelinux-4-prod-microsoft-aarch64"
}
) {
param($Channel, $Architecture, $Url)
$mappedPackage = @($mapping.Packages | Where-Object url -EQ $Url)
$mappedPackage.Count | Should -Be 1
$mappedPackage[0].channel | Should -BeExactly $Channel
$mappedPackage[0].distribution | Should -BeExactly @("azl")
$mappedPackage[0].PackageFormat |
Should -BeExactly "PACKAGE_NAME-POWERSHELL_RELEASE-1.azl4.$Architecture.rpm"
}
It "Should remove the Azure Linux 4 beta mappings" {
@($mapping.Packages | Where-Object url -Like "azurelinux-4.0-beta-*").Count | Should -Be 0
}
It "Should retain all Azure Linux 3 .cm mappings" {
$azureLinux3Mappings = @($mapping.Packages | Where-Object url -Like "azurelinux-3.0-*")
$azureLinux3Mappings.Count | Should -Be 4
$azureLinux3Mappings.PackageFormat | Should -Match "\.cm\.(x86_64|aarch64)\.rpm$"
}
}
Context "Get-MacOSPackageIdentifierInfo function (New-MacOSPackage logic)" {
It "Should detect preview builds and return preview identifier" {
$result = Get-MacOSPackageIdentifierInfo -Version "7.6.0-preview.6" -LTS:$false