@@ -2234,43 +2234,6 @@ function Get-RedHatPackageManager {
22342234 }
22352235}
22362236
2237- function Install-GlobalGem {
2238- param (
2239- [Parameter ()]
2240- [string ]
2241- $Sudo = " " ,
2242-
2243- [Parameter (Mandatory )]
2244- [string ]
2245- $GemName ,
2246-
2247- [Parameter (Mandatory )]
2248- [string ]
2249- $GemVersion
2250- )
2251- try {
2252- # We cannot guess if the user wants to run gem install as root on linux and windows,
2253- # but macOs usually requires sudo
2254- $gemsudo = ' '
2255- if ($environment.IsMacOS -or $env: TF_BUILD -or $env: GITHUB_ACTIONS ) {
2256- $gemsudo = $sudo
2257- }
2258-
2259- Start-NativeExecution ([ScriptBlock ]::Create(" $gemsudo gem install $GemName -v $GemVersion --no-document" ))
2260-
2261- } catch {
2262- Write-Warning " Installation of gem $GemName $GemVersion failed! Must resolve manually."
2263- $logs = Get-ChildItem " /var/lib/gems/*/extensions/x86_64-linux/*/$GemName -*/gem_make.out" | Select-Object - ExpandProperty FullName
2264- foreach ($log in $logs ) {
2265- Write-Verbose " Contents of: $log " - Verbose
2266- Get-Content - Raw - Path $log - ErrorAction Ignore | ForEach-Object { Write-Verbose $_ - Verbose }
2267- Write-Verbose " END Contents of: $log " - Verbose
2268- }
2269-
2270- throw
2271- }
2272- }
2273-
22742237function Start-PSBootstrap {
22752238 [CmdletBinding ()]
22762239 param (
@@ -2282,8 +2245,13 @@ function Start-PSBootstrap {
22822245 [switch ]$BuildLinuxArm ,
22832246 [switch ]$Force ,
22842247 [Parameter (Mandatory = $true )]
2285- [ValidateSet (" Package" , " DotNet" , " Both" )]
2286- [string ]$Scenario = " Package"
2248+ # Package: Install dependencies for packaging tools (rpmbuild, dpkg-deb, pkgbuild, WiX)
2249+ # DotNet: Install the .NET SDK
2250+ # Both: Package and DotNet scenarios
2251+ # Tools: Install .NET global tools (e.g., dotnet-format)
2252+ # All: Install all dependencies (packaging, .NET SDK, and tools)
2253+ [ValidateSet (" Package" , " DotNet" , " Both" , " Tools" , " All" )]
2254+ [string ]$Scenario = " Package"
22872255 )
22882256
22892257 Write-Log - message " Installing PowerShell build dependencies"
@@ -2316,7 +2284,9 @@ function Start-PSBootstrap {
23162284 elseif ($environment.IsUbuntu18 ) { $Deps += " libicu60" }
23172285
23182286 # Packaging tools
2319- if ($Scenario -eq ' Both' -or $Scenario -eq ' Package' ) { $Deps += " ruby-dev" , " groff" , " libffi-dev" , " rpm" , " g++" , " make" }
2287+ # Note: ruby-dev, libffi-dev, g++, and make are no longer needed for DEB packaging
2288+ # DEB packages now use native dpkg-deb (pre-installed)
2289+ if ($Scenario -eq ' Both' -or $Scenario -eq ' Package' ) { $Deps += " groff" , " rpm" }
23202290
23212291 # Install dependencies
23222292 # change the fontend from apt-get to noninteractive
@@ -2340,7 +2310,9 @@ function Start-PSBootstrap {
23402310 $Deps += " libicu" , " openssl-libs"
23412311
23422312 # Packaging tools
2343- if ($Scenario -eq ' Both' -or $Scenario -eq ' Package' ) { $Deps += " ruby-devel" , " rpm-build" , " groff" , ' libffi-devel' , " gcc-c++" }
2313+ # Note: ruby-devel and libffi-devel are no longer needed
2314+ # RPM packages use rpmbuild, DEB packages use dpkg-deb
2315+ if ($Scenario -eq ' Both' -or $Scenario -eq ' Package' ) { $Deps += " rpm-build" , " groff" }
23442316
23452317 $PackageManager = Get-RedHatPackageManager
23462318
@@ -2361,7 +2333,8 @@ function Start-PSBootstrap {
23612333 $Deps += " wget"
23622334
23632335 # Packaging tools
2364- if ($Scenario -eq ' Both' -or $Scenario -eq ' Package' ) { $Deps += " ruby-devel" , " rpmbuild" , " groff" , ' libffi-devel' , " gcc" }
2336+ # Note: ruby-devel and libffi-devel are no longer needed for packaging
2337+ if ($Scenario -eq ' Both' -or $Scenario -eq ' Package' ) { $Deps += " rpmbuild" , " groff" }
23652338
23662339 $PackageManager = " zypper --non-interactive install"
23672340 $baseCommand = " $sudo $PackageManager "
@@ -2400,25 +2373,31 @@ function Start-PSBootstrap {
24002373 }
24012374 }
24022375
2403- # Install [fpm](https://github.com/jordansissel/fpm)
2404- # Note: fpm is now only needed for DEB and macOS packages; RPM packages use rpmbuild directly
2405- if ($Scenario -eq ' Both' -or $Scenario -eq ' Package' ) {
2406- # Install fpm on Debian-based systems, macOS, and Mariner (where DEB packages are built)
2407- if (($environment.IsLinux -and ($environment.IsDebianFamily -or $environment.IsMariner )) -or $environment.IsMacOS ) {
2408- Install-GlobalGem - Sudo $sudo - GemName " dotenv" - GemVersion " 2.8.1"
2409- Install-GlobalGem - Sudo $sudo - GemName " ffi" - GemVersion " 1.16.3"
2410- Install-GlobalGem - Sudo $sudo - GemName " fpm" - GemVersion " 1.15.1"
2411- Install-GlobalGem - Sudo $sudo - GemName " rexml" - GemVersion " 3.2.5"
2412- }
2413-
2414- # For RPM-based systems, ensure rpmbuild is available
2376+ if ($Scenario -in ' All' , ' Both' , ' Package' ) {
2377+ # For RPM-based systems, ensure rpmbuild is available
24152378 if ($environment.IsLinux -and ($environment.IsRedHatFamily -or $environment.IsSUSEFamily -or $environment.IsMariner )) {
24162379 Write-Verbose - Verbose " Checking for rpmbuild..."
24172380 if (! (Get-Command rpmbuild - ErrorAction SilentlyContinue)) {
24182381 Write-Warning " rpmbuild not found. Installing rpm-build package..."
24192382 Start-NativeExecution - sb ([ScriptBlock ]::Create(" $sudo $PackageManager install -y rpm-build" )) - IgnoreExitcode
24202383 }
24212384 }
2385+
2386+ # For Debian-based systems and Mariner, ensure dpkg-deb is available
2387+ if ($environment.IsLinux -and ($environment.IsDebianFamily -or $environment.IsMariner )) {
2388+ Write-Verbose - Verbose " Checking for dpkg-deb..."
2389+ if (! (Get-Command dpkg- deb - ErrorAction SilentlyContinue)) {
2390+ Write-Warning " dpkg-deb not found. Installing dpkg package..."
2391+ if ($environment.IsMariner ) {
2392+ # For Mariner (Azure Linux), install the extended repo first to access dpkg.
2393+ Write-Verbose - Verbose " Installing azurelinux-repos-extended for Mariner..."
2394+ Start-NativeExecution - sb ([ScriptBlock ]::Create(" $sudo $PackageManager install -y azurelinux-repos-extended" )) - IgnoreExitcode
2395+ Start-NativeExecution - sb ([ScriptBlock ]::Create(" $sudo $PackageManager install -y dpkg" )) - IgnoreExitcode
2396+ } else {
2397+ Start-NativeExecution - sb ([ScriptBlock ]::Create(" $sudo apt-get install -y dpkg" )) - IgnoreExitcode
2398+ }
2399+ }
2400+ }
24222401 }
24232402 }
24242403
0 commit comments