Skip to content

Commit d2626e6

Browse files
committed
Add Linux package dependencies for packaging (PowerShell#16807)
1 parent f5381d5 commit d2626e6

File tree

2 files changed

+44
-17
lines changed

2 files changed

+44
-17
lines changed

build.psm1

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1894,6 +1894,43 @@ function Get-RedHatPackageManager {
18941894
}
18951895
}
18961896

1897+
function Install-GlobalGem {
1898+
param(
1899+
[Parameter()]
1900+
[string]
1901+
$Sudo = "",
1902+
1903+
[Parameter(Mandatory)]
1904+
[string]
1905+
$GemName,
1906+
1907+
[Parameter(Mandatory)]
1908+
[string]
1909+
$GemVersion
1910+
)
1911+
try {
1912+
# We cannot guess if the user wants to run gem install as root on linux and windows,
1913+
# but macOs usually requires sudo
1914+
$gemsudo = ''
1915+
if($environment.IsMacOS -or $env:TF_BUILD) {
1916+
$gemsudo = $sudo
1917+
}
1918+
1919+
Start-NativeExecution ([ScriptBlock]::Create("$gemsudo gem install $GemName -v $GemVersion --no-document"))
1920+
1921+
} catch {
1922+
Write-Warning "Installation of gem $GemName $GemVersion failed! Must resolve manually."
1923+
$logs = Get-ChildItem "/var/lib/gems/*/extensions/x86_64-linux/*/$GemName-*/gem_make.out" | Select-Object -ExpandProperty FullName
1924+
foreach ($log in $logs) {
1925+
Write-Verbose "Contents of: $log" -Verbose
1926+
Get-Content -Raw -Path $log -ErrorAction Ignore | ForEach-Object { Write-Verbose $_ -Verbose }
1927+
Write-Verbose "END Contents of: $log" -Verbose
1928+
}
1929+
1930+
throw
1931+
}
1932+
}
1933+
18971934
function Start-PSBootstrap {
18981935
[CmdletBinding()]
18991936
param(
@@ -1938,7 +1975,7 @@ function Start-PSBootstrap {
19381975
elseif ($environment.IsUbuntu18) { $Deps += "libicu60"}
19391976

19401977
# Packaging tools
1941-
if ($Package) { $Deps += "ruby-dev", "groff", "libffi-dev", "rpm" }
1978+
if ($Package) { $Deps += "ruby-dev", "groff", "libffi-dev", "rpm", "g++", "make" }
19421979

19431980
# Install dependencies
19441981
# change the fontend from apt-get to noninteractive
@@ -1962,7 +1999,7 @@ function Start-PSBootstrap {
19621999
$Deps += "libicu", "libunwind"
19632000

19642001
# Packaging tools
1965-
if ($Package) { $Deps += "ruby-devel", "rpm-build", "groff", 'libffi-devel' }
2002+
if ($Package) { $Deps += "ruby-devel", "rpm-build", "groff", 'libffi-devel', "gcc-c++" }
19662003

19672004
$PackageManager = Get-RedHatPackageManager
19682005

@@ -1983,7 +2020,7 @@ function Start-PSBootstrap {
19832020
$Deps += "wget"
19842021

19852022
# Packaging tools
1986-
if ($Package) { $Deps += "ruby-devel", "rpmbuild", "groff", 'libffi-devel' }
2023+
if ($Package) { $Deps += "ruby-devel", "rpmbuild", "groff", 'libffi-devel', "gcc" }
19872024

19882025
$PackageManager = "zypper --non-interactive install"
19892026
$baseCommand = "$sudo $PackageManager"
@@ -2024,19 +2061,9 @@ function Start-PSBootstrap {
20242061

20252062
# Install [fpm](https://github.com/jordansissel/fpm) and [ronn](https://github.com/rtomayko/ronn)
20262063
if ($Package) {
2027-
try {
2028-
# We cannot guess if the user wants to run gem install as root on linux and windows,
2029-
# but macOs usually requires sudo
2030-
$gemsudo = ''
2031-
if($environment.IsMacOS -or $env:TF_BUILD) {
2032-
$gemsudo = $sudo
2033-
}
2034-
Start-NativeExecution ([ScriptBlock]::Create("$gemsudo gem install ffi -v 1.12.0 --no-document"))
2035-
Start-NativeExecution ([ScriptBlock]::Create("$gemsudo gem install fpm -v 1.11.0 --no-document"))
2036-
Start-NativeExecution ([ScriptBlock]::Create("$gemsudo gem install ronn -v 0.7.3 --no-document"))
2037-
} catch {
2038-
Write-Warning "Installation of fpm and ronn gems failed! Must resolve manually."
2039-
}
2064+
Install-GlobalGem -Sudo $sudo -GemName "ffi" -GemVersion "1.12.0"
2065+
Install-GlobalGem -Sudo $sudo -GemName "fpm" -GemVersion "1.11.0"
2066+
Install-GlobalGem -Sudo $sudo -GemName "ronn" -GemVersion "0.7.3"
20402067
}
20412068
}
20422069

tools/releaseBuild/Images/microsoft_powershell_windowsservercore/PowerShellPackage.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ try
7777
Sync-PSTags -AddRemoteIfMissing
7878

7979
Write-Verbose "Bootstrapping powershell build..." -Verbose
80-
Start-PSBootstrap -Force -Package
80+
Start-PSBootstrap -Force -Package -ErrorAction Stop
8181

8282
if ($PSCmdlet.ParameterSetName -eq 'packageSigned')
8383
{

0 commit comments

Comments
 (0)