Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 43 additions & 16 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1894,6 +1894,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()]
param(
Expand Down Expand Up @@ -1938,7 +1975,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 @@ -1962,7 +1999,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 @@ -1983,7 +2020,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 @@ -2024,19 +2061,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 @@ -77,7 +77,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