-
Notifications
You must be signed in to change notification settings - Fork 8.3k
[release/v7.5] Replace fpm with native rpmbuild for RPM package generation #26793
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,91 @@ | ||||||||||||||||||||
| # Copyright (c) Microsoft Corporation. | ||||||||||||||||||||
| # Licensed under the MIT License. | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Describe "Linux Package Name Validation" { | ||||||||||||||||||||
| BeforeAll { | ||||||||||||||||||||
| # Determine artifacts directory (GitHub Actions or Azure DevOps) | ||||||||||||||||||||
| $artifactsDir = if ($env:GITHUB_ACTIONS -eq 'true') { | ||||||||||||||||||||
| "$env:GITHUB_WORKSPACE/../packages" | ||||||||||||||||||||
| } else { | ||||||||||||||||||||
| $env:SYSTEM_ARTIFACTSDIRECTORY | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if (-not $artifactsDir) { | ||||||||||||||||||||
| throw "Artifacts directory not found. GITHUB_WORKSPACE or SYSTEM_ARTIFACTSDIRECTORY must be set." | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Write-Verbose "Artifacts directory: $artifactsDir" -Verbose | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Context "RPM Package Names" { | ||||||||||||||||||||
| It "Should have valid RPM package names" { | ||||||||||||||||||||
| $rpmPackages = Get-ChildItem -Path $artifactsDir -Recurse -Filter *.rpm -ErrorAction SilentlyContinue | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if ($rpmPackages.Count -eq 0) { | ||||||||||||||||||||
| Set-ItResult -Skipped -Because "No RPM packages found in artifacts directory" | ||||||||||||||||||||
| return | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| $invalidPackages = @() | ||||||||||||||||||||
| # Regex pattern for valid RPM package names. | ||||||||||||||||||||
| # Breakdown: | ||||||||||||||||||||
| # ^powershell\- : Starts with 'powershell-' | ||||||||||||||||||||
| # (preview-|lts-)? : Optionally 'preview-' or 'lts-' | ||||||||||||||||||||
| # \d+\.\d+\.\d+ : Version number (e.g., 7.6.0) | ||||||||||||||||||||
| # (_[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.' | ||||||||||||||||||||
| # (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' | ||||||||||||||||||||
|
Comment on lines
+36
to
+40
|
||||||||||||||||||||
| # -1\. : Literal '-1.' | |
| # (preview\.\d+\.)? : Optional 'preview.' and digits, followed by a dot | |
| # (rh|cm)\. : Either 'rh.' or 'cm.' | |
| # (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' | |
| # -1\. : Literal '-1.' (iteration part of Release) | |
| # (rh|cm)\. : Either 'rh.' or 'cm.' (distribution part of Release) | |
| # (x86_64|aarch64)\.rpm$ : Architecture and file extension | |
| $rpmPackageNamePattern = 'powershell\-(preview-|lts-)?\d+\.\d+\.\d+(_[a-z]*\.\d+)?-1\.(rh|cm)\.(x86_64|aarch64)\.rpm' |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The regex pattern for tar.gz package names has an unescaped dot in ([a-z]*.\d+\-)?. The dot should be escaped as \. to match a literal dot (e.g., "preview.6"). Currently, [a-z]*. matches any single character, not specifically a dot. This should be ([a-z]*\.\d+\-)? to correctly match preview versions like "preview.6-" in the package name.
| if ($package.Name -notmatch 'powershell-(lts-)?\d+\.\d+\.\d+\-([a-z]*.\d+\-)?(linux|osx|linux-musl)+\-(x64\-fxdependent|x64|arm32|arm64|x64\-musl-noopt\-fxdependent)\.(tar\.gz)') { | |
| if ($package.Name -notmatch 'powershell-(lts-)?\d+\.\d+\.\d+\-([a-z]*\.\d+\-)?(linux|osx|linux-musl)+\-(x64\-fxdependent|x64|arm32|arm64|x64\-musl-noopt\-fxdependent)\.(tar\.gz)') { |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -874,16 +874,36 @@ function New-LinuxPackage | |
| $packageObj = $package | ||
| } | ||
|
|
||
| Write-Log -message "Artifacts directory: ${env:BUILD_ARTIFACTSTAGINGDIRECTORY}" | ||
| Copy-Item $packageObj.FullName -Destination "${env:BUILD_ARTIFACTSTAGINGDIRECTORY}" -Force | ||
| # Determine artifacts directory (GitHub Actions or Azure DevOps) | ||
| $artifactsDir = if ($env:GITHUB_ACTIONS -eq 'true') { | ||
| "${env:GITHUB_WORKSPACE}/../packages" | ||
| } else { | ||
| "${env:BUILD_ARTIFACTSTAGINGDIRECTORY}" | ||
| } | ||
|
|
||
| # Ensure artifacts directory exists | ||
| if (-not (Test-Path $artifactsDir)) { | ||
| New-Item -ItemType Directory -Path $artifactsDir -Force | Out-Null | ||
| } | ||
|
|
||
| Write-Log -message "Artifacts directory: $artifactsDir" | ||
| Copy-Item $packageObj.FullName -Destination $artifactsDir -Force | ||
| } | ||
|
|
||
| if ($IsLinux) | ||
| { | ||
| # Determine artifacts directory (GitHub Actions or Azure DevOps) | ||
| $artifactsDir = if ($env:GITHUB_ACTIONS -eq 'true') { | ||
| "${env:GITHUB_WORKSPACE}/../packages" | ||
| } else { | ||
| "${env:BUILD_ARTIFACTSTAGINGDIRECTORY}" | ||
| } | ||
|
Comment on lines
+895
to
+900
|
||
|
|
||
| # Create and package Raspbian .tgz | ||
| # Build must be clean for Raspbian | ||
| Start-PSBuild -PSModuleRestore -Clean -Runtime linux-arm -Configuration 'Release' | ||
| $armPackage = Start-PSPackage @packageParams -Type tar-arm -SkipReleaseChecks | ||
| Copy-Item $armPackage -Destination "${env:BUILD_ARTIFACTSTAGINGDIRECTORY}" -Force | ||
| Copy-Item $armPackage -Destination $artifactsDir -Force | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a mismatch in the Azure DevOps environment variable used for the artifacts directory. The test uses
$env:SYSTEM_ARTIFACTSDIRECTORY(line 10), but the packaging code in tools/ci.psm1 uses$env:BUILD_ARTIFACTSTAGINGDIRECTORY. In Azure DevOps, BUILD_ARTIFACTSTAGINGDIRECTORY is the standard variable for the staging directory where artifacts are placed before upload. The test should use the same variable to ensure it looks in the correct location. Change line 10 to use$env:BUILD_ARTIFACTSTAGINGDIRECTORYto match the packaging code.