Skip to content

Commit 4618a94

Browse files
committed
Add Linux package dependencies for packaging (PowerShell#16807)
1 parent 3b49c7a commit 4618a94

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
@@ -1783,6 +1783,43 @@ function Get-RedHatPackageManager {
17831783
}
17841784
}
17851785

1786+
function Install-GlobalGem {
1787+
param(
1788+
[Parameter()]
1789+
[string]
1790+
$Sudo = "",
1791+
1792+
[Parameter(Mandatory)]
1793+
[string]
1794+
$GemName,
1795+
1796+
[Parameter(Mandatory)]
1797+
[string]
1798+
$GemVersion
1799+
)
1800+
try {
1801+
# We cannot guess if the user wants to run gem install as root on linux and windows,
1802+
# but macOs usually requires sudo
1803+
$gemsudo = ''
1804+
if($environment.IsMacOS -or $env:TF_BUILD) {
1805+
$gemsudo = $sudo
1806+
}
1807+
1808+
Start-NativeExecution ([ScriptBlock]::Create("$gemsudo gem install $GemName -v $GemVersion --no-document"))
1809+
1810+
} catch {
1811+
Write-Warning "Installation of gem $GemName $GemVersion failed! Must resolve manually."
1812+
$logs = Get-ChildItem "/var/lib/gems/*/extensions/x86_64-linux/*/$GemName-*/gem_make.out" | Select-Object -ExpandProperty FullName
1813+
foreach ($log in $logs) {
1814+
Write-Verbose "Contents of: $log" -Verbose
1815+
Get-Content -Raw -Path $log -ErrorAction Ignore | ForEach-Object { Write-Verbose $_ -Verbose }
1816+
Write-Verbose "END Contents of: $log" -Verbose
1817+
}
1818+
1819+
throw
1820+
}
1821+
}
1822+
17861823
function Start-PSBootstrap {
17871824
[CmdletBinding(
17881825
SupportsShouldProcess=$true,
@@ -1830,7 +1867,7 @@ function Start-PSBootstrap {
18301867
elseif ($environment.IsUbuntu18) { $Deps += "libicu60"}
18311868

18321869
# Packaging tools
1833-
if ($Package) { $Deps += "ruby-dev", "groff", "libffi-dev", "rpm" }
1870+
if ($Package) { $Deps += "ruby-dev", "groff", "libffi-dev", "rpm", "g++", "make" }
18341871

18351872
# Install dependencies
18361873
# change the fontend from apt-get to noninteractive
@@ -1854,7 +1891,7 @@ function Start-PSBootstrap {
18541891
$Deps += "libicu", "libunwind"
18551892

18561893
# Packaging tools
1857-
if ($Package) { $Deps += "ruby-devel", "rpm-build", "groff", 'libffi-devel' }
1894+
if ($Package) { $Deps += "ruby-devel", "rpm-build", "groff", 'libffi-devel', "gcc-c++" }
18581895

18591896
$PackageManager = Get-RedHatPackageManager
18601897

@@ -1875,7 +1912,7 @@ function Start-PSBootstrap {
18751912
$Deps += "wget"
18761913

18771914
# Packaging tools
1878-
if ($Package) { $Deps += "ruby-devel", "rpmbuild", "groff", 'libffi-devel' }
1915+
if ($Package) { $Deps += "ruby-devel", "rpmbuild", "groff", 'libffi-devel', "gcc" }
18791916

18801917
$PackageManager = "zypper --non-interactive install"
18811918
$baseCommand = "$sudo $PackageManager"
@@ -1916,19 +1953,9 @@ function Start-PSBootstrap {
19161953

19171954
# Install [fpm](https://github.com/jordansissel/fpm) and [ronn](https://github.com/rtomayko/ronn)
19181955
if ($Package) {
1919-
try {
1920-
# We cannot guess if the user wants to run gem install as root on linux and windows,
1921-
# but macOs usually requires sudo
1922-
$gemsudo = ''
1923-
if($environment.IsMacOS -or $env:TF_BUILD) {
1924-
$gemsudo = $sudo
1925-
}
1926-
Start-NativeExecution ([ScriptBlock]::Create("$gemsudo gem install ffi -v 1.12.0 --no-document"))
1927-
Start-NativeExecution ([ScriptBlock]::Create("$gemsudo gem install fpm -v 1.11.0 --no-document"))
1928-
Start-NativeExecution ([ScriptBlock]::Create("$gemsudo gem install ronn -v 0.7.3 --no-document"))
1929-
} catch {
1930-
Write-Warning "Installation of fpm and ronn gems failed! Must resolve manually."
1931-
}
1956+
Install-GlobalGem -Sudo $sudo -GemName "ffi" -GemVersion "1.12.0"
1957+
Install-GlobalGem -Sudo $sudo -GemName "fpm" -GemVersion "1.11.0"
1958+
Install-GlobalGem -Sudo $sudo -GemName "ronn" -GemVersion "0.7.3"
19321959
}
19331960
}
19341961

tools/releaseBuild/Images/microsoft_powershell_windowsservercore/PowerShellPackage.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ try{
7474
Sync-PSTags -AddRemoteIfMissing
7575

7676
Write-Verbose "Bootstrapping powershell build..." -Verbose
77-
Start-PSBootstrap -Force -Package
77+
Start-PSBootstrap -Force -Package -ErrorAction Stop
7878

7979
if ($PSCmdlet.ParameterSetName -eq 'packageSigned')
8080
{

0 commit comments

Comments
 (0)