Skip to content

Commit

Permalink
Add Linux package dependencies for packaging (PowerShell#16807)
Browse files Browse the repository at this point in the history
  • Loading branch information
TravisEz13 committed Mar 8, 2022
1 parent 3b49c7a commit 4618a94
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 17 deletions.
59 changes: 43 additions & 16 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1783,6 +1783,43 @@ function Get-RedHatPackageManager {
}
}

function Install-GlobalGem {
param(
[Parameter()]
[string]
$Sudo = "",

[Parameter(Mandatory)]
[string]
$GemName,

[Parameter(Mandatory)]
[string]
$GemVersion
)
try {
# We cannot guess if the user wants to run gem install as root on linux and windows,
# but macOs usually requires sudo
$gemsudo = ''
if($environment.IsMacOS -or $env:TF_BUILD) {
$gemsudo = $sudo
}

Start-NativeExecution ([ScriptBlock]::Create("$gemsudo gem install $GemName -v $GemVersion --no-document"))

} catch {
Write-Warning "Installation of gem $GemName $GemVersion failed! Must resolve manually."
$logs = Get-ChildItem "/var/lib/gems/*/extensions/x86_64-linux/*/$GemName-*/gem_make.out" | Select-Object -ExpandProperty FullName
foreach ($log in $logs) {
Write-Verbose "Contents of: $log" -Verbose
Get-Content -Raw -Path $log -ErrorAction Ignore | ForEach-Object { Write-Verbose $_ -Verbose }
Write-Verbose "END Contents of: $log" -Verbose
}

throw
}
}

function Start-PSBootstrap {
[CmdletBinding(
SupportsShouldProcess=$true,
Expand Down Expand Up @@ -1830,7 +1867,7 @@ function Start-PSBootstrap {
elseif ($environment.IsUbuntu18) { $Deps += "libicu60"}

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

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

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

$PackageManager = Get-RedHatPackageManager

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

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

$PackageManager = "zypper --non-interactive install"
$baseCommand = "$sudo $PackageManager"
Expand Down Expand Up @@ -1916,19 +1953,9 @@ function Start-PSBootstrap {

# Install [fpm](https://github.com/jordansissel/fpm) and [ronn](https://github.com/rtomayko/ronn)
if ($Package) {
try {
# We cannot guess if the user wants to run gem install as root on linux and windows,
# but macOs usually requires sudo
$gemsudo = ''
if($environment.IsMacOS -or $env:TF_BUILD) {
$gemsudo = $sudo
}
Start-NativeExecution ([ScriptBlock]::Create("$gemsudo gem install ffi -v 1.12.0 --no-document"))
Start-NativeExecution ([ScriptBlock]::Create("$gemsudo gem install fpm -v 1.11.0 --no-document"))
Start-NativeExecution ([ScriptBlock]::Create("$gemsudo gem install ronn -v 0.7.3 --no-document"))
} catch {
Write-Warning "Installation of fpm and ronn gems failed! Must resolve manually."
}
Install-GlobalGem -Sudo $sudo -GemName "ffi" -GemVersion "1.12.0"
Install-GlobalGem -Sudo $sudo -GemName "fpm" -GemVersion "1.11.0"
Install-GlobalGem -Sudo $sudo -GemName "ronn" -GemVersion "0.7.3"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ try{
Sync-PSTags -AddRemoteIfMissing

Write-Verbose "Bootstrapping powershell build..." -Verbose
Start-PSBootstrap -Force -Package
Start-PSBootstrap -Force -Package -ErrorAction Stop

if ($PSCmdlet.ParameterSetName -eq 'packageSigned')
{
Expand Down

0 comments on commit 4618a94

Please sign in to comment.