From 3758a76d77998d7401ee64f42ab6a6cc884bde50 Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Wed, 12 Feb 2020 18:34:37 -0800 Subject: [PATCH 1/4] Make sure LTS packages have symlink for pwsh and pwsh-lts --- tools/packaging/packaging.psm1 | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/tools/packaging/packaging.psm1 b/tools/packaging/packaging.psm1 index ad7519a2683..0c96d130f64 100644 --- a/tools/packaging/packaging.psm1 +++ b/tools/packaging/packaging.psm1 @@ -826,8 +826,13 @@ function New-UnixPackage { } # Destination for symlink to powershell executable - $Link = Get-PwshExecutablePath -IsPreview:$IsPreview -IsLTS:$LTS + $Link = Get-PwshExecutablePath -IsPreview:$IsPreview $linkSource = "/tmp/pwsh" + $links = @($Link) + if($LTS) + { + $links += Get-PwshExecutablePath -IsPreview:$IsPreview -IsLTS:$LTS + } if ($PSCmdlet.ShouldProcess("Create package file system")) { @@ -1027,6 +1032,13 @@ function New-MacOsDistributionPackage return (Get-Item $newPackagePath) } + +Class LinkInfo +{ + [string] $Source + [string] $Destination +} + function Get-FpmArguments { param( @@ -1060,10 +1072,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({ @@ -1147,10 +1156,16 @@ function Get-FpmArguments $Arguments += @( "$Staging/=$Destination/", - "$ManGzipFile=$ManDestination", - "$LinkSource=$LinkDestination" + "$ManGzipFile=$ManDestination" ) + foreach($link in $LinkInfo) + { + $linkArgument = "$(link.Source)=$(link.Destination)" + Write-Verbose "adding link argument: $linkArgument" -Verbose + $Arguments += $linkArgument + } + if ($AppsFolder) { $Arguments += "$AppsFolder=/" From bb34f2a5b91e8ad1c7045f19e70c914c70847e9c Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Wed, 12 Feb 2020 18:51:58 -0800 Subject: [PATCH 2/4] Make sure LTS packages have symlink for pwsh and pwsh-lts --- tools/packaging/packaging.psm1 | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/packaging/packaging.psm1 b/tools/packaging/packaging.psm1 index 0c96d130f64..d0c31577d3f 100644 --- a/tools/packaging/packaging.psm1 +++ b/tools/packaging/packaging.psm1 @@ -828,10 +828,18 @@ function New-UnixPackage { # Destination for symlink to powershell executable $Link = Get-PwshExecutablePath -IsPreview:$IsPreview $linkSource = "/tmp/pwsh" + $linkInfo = [LinkInfo] @{ + Source = $linkSource + Destination = $Link + } + $links = @($Link) if($LTS) { - $links += Get-PwshExecutablePath -IsPreview:$IsPreview -IsLTS:$LTS + $links += [LinkInfo] @{ + Source = $linkSource + Destination = Get-PwshExecutablePath -IsPreview:$IsPreview -IsLTS:$LTS + } } if ($PSCmdlet.ShouldProcess("Create package file system")) @@ -904,8 +912,7 @@ function New-UnixPackage { -Destination $Destination ` -ManGzipFile $ManGzipInfo.GzipFile ` -ManDestination $ManGzipInfo.ManFile ` - -LinkSource $LinkSource ` - -LinkDestination $Link ` + -LinkInfo $Links ` -AppsFolder $AppsFolder ` -Distribution $DebDistro ` -ErrorAction Stop From 92e70076509bf45962381f716cc10dce9d7a1c8e Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Thu, 13 Feb 2020 13:39:09 -0800 Subject: [PATCH 3/4] Make sure LTS packages have symlink for pwsh and pwsh-lts --- tools/packaging/packaging.psm1 | 48 +++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/tools/packaging/packaging.psm1 b/tools/packaging/packaging.psm1 index d0c31577d3f..b3012e5995c 100644 --- a/tools/packaging/packaging.psm1 +++ b/tools/packaging/packaging.psm1 @@ -828,18 +828,12 @@ function New-UnixPackage { # Destination for symlink to powershell executable $Link = Get-PwshExecutablePath -IsPreview:$IsPreview $linkSource = "/tmp/pwsh" - $linkInfo = [LinkInfo] @{ - Source = $linkSource - Destination = $Link - } + $linkInfo = New-LinkInfo -LinkDestination $Link -LinkTarget "$Destination/pwsh" - $links = @($Link) + $links = @($LinkInfo) if($LTS) { - $links += [LinkInfo] @{ - Source = $linkSource - Destination = Get-PwshExecutablePath -IsPreview:$IsPreview -IsLTS:$LTS - } + $links += New-LinkInfo -LinkDestination (Get-PwshExecutablePath -IsPreview:$IsPreview -IsLTS:$LTS) -LinkTarget "$Destination/pwsh" } if ($PSCmdlet.ShouldProcess("Create package file system")) @@ -934,7 +928,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) { @@ -968,6 +962,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( @@ -1168,8 +1191,7 @@ function Get-FpmArguments foreach($link in $LinkInfo) { - $linkArgument = "$(link.Source)=$(link.Destination)" - Write-Verbose "adding link argument: $linkArgument" -Verbose + $linkArgument = "$($link.Source)=$($link.Destination)" $Arguments += $linkArgument } @@ -1498,7 +1520,7 @@ function Get-PwshExecutablePath $executableName = if ($IsPreview) { "pwsh-preview" - } elseif ($LTS) { + } elseif ($IsLTS) { "pwsh-lts" } else { "pwsh" From 349f8c5a6a587c5568efcf641ecb3d245c2c202a Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Thu, 13 Feb 2020 16:41:12 -0800 Subject: [PATCH 4/4] Fix the LTS package symbolic links --- tools/ci.psm1 | 2 +- tools/packaging/packaging.psm1 | 12 +++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/tools/ci.psm1 b/tools/ci.psm1 index 66df43551ef..096128566a0 100644 --- a/tools/ci.psm1 +++ b/tools/ci.psm1 @@ -441,7 +441,7 @@ function Invoke-CIFinish [string] $NuGetKey ) - if($IsLinux -or $IsMacOS) + if($PSEdition -eq 'Core' -and ($IsLinux -or $IsMacOS)) { return New-LinuxPackage -NugetKey $NugetKey } diff --git a/tools/packaging/packaging.psm1 b/tools/packaging/packaging.psm1 index b3012e5995c..268af8eb5fa 100644 --- a/tools/packaging/packaging.psm1 +++ b/tools/packaging/packaging.psm1 @@ -827,20 +827,14 @@ function New-UnixPackage { # Destination for symlink to powershell executable $Link = Get-PwshExecutablePath -IsPreview:$IsPreview - $linkSource = "/tmp/pwsh" - $linkInfo = New-LinkInfo -LinkDestination $Link -LinkTarget "$Destination/pwsh" + $links = @(New-LinkInfo -LinkDestination $Link -LinkTarget "$Destination/pwsh") - $links = @($LinkInfo) - if($LTS) - { - $links += New-LinkInfo -LinkDestination (Get-PwshExecutablePath -IsPreview:$IsPreview -IsLTS:$LTS) -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