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
2 changes: 1 addition & 1 deletion tools/ci.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ function Invoke-CIFinish
[string] $NuGetKey
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@daxian-dbw, your last commit had 1 failures in PowerShell-CI-linux
Invoke-WebRequest tests.Denial of service.Charset Parsing

Expected the actual value to be greater than 5, but got 0.32999946773053.
at <ScriptBlock>, /home/vsts/work/1/s/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1: line 1961
1961:             $pathologicalRatio | Should -BeGreaterThan 5

)

if($IsLinux -or $IsMacOS)
if($PSEdition -eq 'Core' -and ($IsLinux -or $IsMacOS))
{
return New-LinuxPackage -NugetKey $NugetKey
}
Expand Down
68 changes: 53 additions & 15 deletions tools/packaging/packaging.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -826,14 +826,15 @@ function New-UnixPackage {
}

# Destination for symlink to powershell executable
$Link = Get-PwshExecutablePath -IsPreview:$IsPreview -IsLTS:$LTS
$linkSource = "/tmp/pwsh"
$Link = Get-PwshExecutablePath -IsPreview:$IsPreview
$links = @(New-LinkInfo -LinkDestination $Link -LinkTarget "$Destination/pwsh")

if($LTS) {
$links += New-LinkInfo -LinkDestination (Get-PwshExecutablePath -IsLTS:$LTS) -LinkTarget "$Destination/pwsh"
}

if ($PSCmdlet.ShouldProcess("Create package file system"))
{
# refers to executable, does not vary by channel
New-Item -Force -ItemType SymbolicLink -Path $linkSource -Target "$Destination/pwsh" > $null

# Generate After Install and After Remove scripts
$AfterScriptInfo = New-AfterScripts -Link $Link -Distribution $DebDistro
New-PSSymbolicLinks -Distribution $DebDistro -Staging $Staging
Expand Down Expand Up @@ -899,8 +900,7 @@ function New-UnixPackage {
-Destination $Destination `
-ManGzipFile $ManGzipInfo.GzipFile `
-ManDestination $ManGzipInfo.ManFile `
-LinkSource $LinkSource `
-LinkDestination $Link `
-LinkInfo $Links `
-AppsFolder $AppsFolder `
-Distribution $DebDistro `
-ErrorAction Stop
Expand All @@ -922,7 +922,7 @@ function New-UnixPackage {
# this is continuation of a fpm hack for a weird bug
if (Test-Path $hack_dest) {
Write-Warning "Move $hack_dest to $symlink_dest (fpm utime bug)"
Start-NativeExecution ([ScriptBlock]::Create("$sudo mv $hack_dest $symlink_dest"))
Start-NativeExecution -sb ([ScriptBlock]::Create("$sudo mv $hack_dest $symlink_dest")) -VerboseOutputOnError
}
}
if ($AfterScriptInfo.AfterInstallScript) {
Expand Down Expand Up @@ -956,6 +956,35 @@ function New-UnixPackage {
}
}

Function New-LinkInfo
{
[CmdletBinding(SupportsShouldProcess=$true)]
param(
[Parameter(Mandatory)]
[string]
$LinkDestination,
[Parameter(Mandatory)]
[string]
$linkTarget
)

$linkDir = Join-Path -path '/tmp' -ChildPath ([System.IO.Path]::GetRandomFileName())
$null = New-Item -ItemType Directory -Path $linkDir
$linkSource = Join-Path -Path $linkDir -ChildPath 'pwsh'

Write-Log "Creating link to target '$LinkTarget', with a temp source of '$LinkSource' and a Package Destination of '$LinkDestination'"
if ($PSCmdlet.ShouldProcess("Create package symbolic from $linkDestination to $linkTarget"))
{
# refers to executable, does not vary by channel
New-Item -Force -ItemType SymbolicLink -Path $linkSource -Target $LinkTarget > $null
}

[LinkInfo] @{
Source = $linkSource
Destination = $LinkDestination
}
}

function New-MacOsDistributionPackage
{
param(
Expand Down Expand Up @@ -1027,6 +1056,13 @@ function New-MacOsDistributionPackage

return (Get-Item $newPackagePath)
}

Class LinkInfo
{
[string] $Source
[string] $Destination
}

function Get-FpmArguments
{
param(
Expand Down Expand Up @@ -1060,10 +1096,7 @@ function Get-FpmArguments
[String]$ManDestination,

[Parameter(Mandatory,HelpMessage='Symlink to powershell executable')]
[String]$LinkSource,

[Parameter(Mandatory,HelpMessage='Destination for symlink to powershell executable')]
[String]$LinkDestination,
[LinkInfo[]]$LinkInfo,

[Parameter(HelpMessage='Packages required to install this package. Not applicable for MacOS.')]
[ValidateScript({
Expand Down Expand Up @@ -1147,10 +1180,15 @@ function Get-FpmArguments

$Arguments += @(
"$Staging/=$Destination/",
"$ManGzipFile=$ManDestination",
"$LinkSource=$LinkDestination"
"$ManGzipFile=$ManDestination"
)

foreach($link in $LinkInfo)
{
$linkArgument = "$($link.Source)=$($link.Destination)"
$Arguments += $linkArgument
}

if ($AppsFolder)
{
$Arguments += "$AppsFolder=/"
Expand Down Expand Up @@ -1476,7 +1514,7 @@ function Get-PwshExecutablePath

$executableName = if ($IsPreview) {
"pwsh-preview"
} elseif ($LTS) {
} elseif ($IsLTS) {
"pwsh-lts"
} else {
"pwsh"
Expand Down