Skip to content

Change packaging to produce LTS packages #11772

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 5, 2020
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
88 changes: 72 additions & 16 deletions tools/packaging/packaging.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ function Start-PSPackage {

[Switch] $SkipReleaseChecks,

[switch] $NoSudo
[switch] $NoSudo,

[switch] $LTS
)

DynamicParam {
Expand Down Expand Up @@ -304,6 +306,7 @@ function Start-PSPackage {
PackageNameSuffix = 'fxdependent'
Version = $Version
Force = $Force
LTS = $LTS
}

if ($PSCmdlet.ShouldProcess("Create tar.gz Package")) {
Expand Down Expand Up @@ -366,6 +369,7 @@ function Start-PSPackage {
Name = $Name
Version = $Version
Force = $Force
LTS = $LTS
}

if ($PSCmdlet.ShouldProcess("Create tar.gz Package")) {
Expand All @@ -380,6 +384,7 @@ function Start-PSPackage {
Force = $Force
Architecture = "arm32"
ExcludeSymbolicLinks = $true
LTS = $LTS
}

if ($PSCmdlet.ShouldProcess("Create tar.gz Package")) {
Expand All @@ -394,6 +399,7 @@ function Start-PSPackage {
Force = $Force
Architecture = "arm64"
ExcludeSymbolicLinks = $true
LTS = $LTS
}

if ($PSCmdlet.ShouldProcess("Create tar.gz Package")) {
Expand All @@ -408,6 +414,7 @@ function Start-PSPackage {
Force = $Force
Architecture = "alpine-x64"
ExcludeSymbolicLinks = $true
LTS = $LTS
}

if ($PSCmdlet.ShouldProcess("Create tar.gz Package")) {
Expand All @@ -422,6 +429,7 @@ function Start-PSPackage {
Version = $Version
Force = $Force
NoSudo = $NoSudo
LTS = $LTS
}
foreach ($Distro in $Script:DebianDistributions) {
$Arguments["Distribution"] = $Distro
Expand All @@ -438,6 +446,7 @@ function Start-PSPackage {
Version = $Version
Force = $Force
NoSudo = $NoSudo
LTS = $LTS
}
foreach ($Distro in $Script:RedhatDistributions) {
$Arguments["Distribution"] = $Distro
Expand All @@ -454,6 +463,7 @@ function Start-PSPackage {
Version = $Version
Force = $Force
NoSudo = $NoSudo
LTS = $LTS
}

if ($PSCmdlet.ShouldProcess("Create $_ Package")) {
Expand Down Expand Up @@ -492,13 +502,20 @@ function New-TarballPackage {

[switch] $Force,

[switch] $ExcludeSymbolicLinks
[switch] $ExcludeSymbolicLinks,

[switch] $LTS
)

if ($PackageNameSuffix) {
$packageName = "$Name-$Version-{0}-$Architecture-$PackageNameSuffix.tar.gz"
} else {
$packageName = "$Name-$Version-{0}-$Architecture.tar.gz"
$packageName = if ($LTS) {
"$Name-lts-$Version-{0}-$Architecture.tar.gz"
}
else {
"$Name-$Version-{0}-$Architecture.tar.gz"
}
}

if ($Environment.IsWindows) {
Expand All @@ -520,8 +537,11 @@ function New-TarballPackage {
}
}

$Staging = "$PSScriptRoot/staging"
New-StagingFolder -StagingPath $Staging

if (-not $ExcludeSymbolicLinks.IsPresent) {
New-PSSymbolicLinks -Distribution 'ubuntu.16.04' -Staging $PackageSourcePath
New-PSSymbolicLinks -Distribution 'ubuntu.16.04' -Staging $Staging
}

if (Get-Command -Name tar -CommandType Application -ErrorAction Ignore) {
Expand All @@ -533,7 +553,7 @@ function New-TarballPackage {
}

try {
Push-Location -Path $PackageSourcePath
Push-Location -Path $Staging
tar $options $packagePath .
} finally {
Pop-Location
Expand Down Expand Up @@ -681,7 +701,10 @@ function New-UnixPackage {
$Force,

[switch]
$NoSudo
$NoSudo,

[switch]
$LTS
)

DynamicParam {
Expand Down Expand Up @@ -767,7 +790,15 @@ function New-UnixPackage {
$IsPreview = Test-IsPreview -Version $Version

# Preview versions have preview in the name
$Name = if ($IsPreview) { "powershell-preview" } else { "powershell" }
$Name = if($LTS) {
"powershell-lts"
}
elseif ($IsPreview) {
"powershell-preview"
}
else {
"powershell"
}

# Verify dependencies are installed and in the path
Test-Dependencies
Expand All @@ -779,7 +810,7 @@ function New-UnixPackage {
$MajorVersion = $VersionMatch.Groups[1].Value

# Suffix is used for side-by-side preview/release package installation
$Suffix = if ($IsPreview) { $MajorVersion + "-preview" } else { $MajorVersion }
$Suffix = if ($IsPreview) { $MajorVersion + "-preview" } elseif ($LTS) { $MajorVersion + "-lts" } else { $MajorVersion }

# Setup staging directory so we don't change the original source directory
$Staging = "$PSScriptRoot/staging"
Expand All @@ -795,11 +826,7 @@ function New-UnixPackage {
}

# Destination for symlink to powershell executable
$Link = if ($Environment.IsLinux) {
if ($IsPreview) { "/usr/bin/pwsh-preview" } else { "/usr/bin/pwsh" }
} elseif ($Environment.IsMacOS) {
if ($IsPreview) { "/usr/local/bin/pwsh-preview" } else { "/usr/local/bin/pwsh" }
}
$Link = Get-PwshExecutablePath -IsPreview:$IsPreview -IsLTS:$LTS
$linkSource = "/tmp/pwsh"

if ($PSCmdlet.ShouldProcess("Create package file system"))
Expand Down Expand Up @@ -1382,14 +1409,16 @@ function New-MacOSLauncher
{
param(
[Parameter(Mandatory)]
[String]$Version
[String]$Version,

[switch]$LTS
)

$IsPreview = Test-IsPreview -Version $Version
$packageId = Get-MacOSPackageId -IsPreview:$IsPreview

# Define folder for launcher application.
$suffix = if ($IsPreview) { "-preview" }
$suffix = if ($IsPreview) { "-preview" } elseif ($LTS) { "-lts" }
$macosapp = "$PSScriptRoot/macos/launcher/ROOT/Applications/PowerShell$suffix.app"

# Create folder structure for launcher application.
Expand All @@ -1416,7 +1445,7 @@ function New-MacOSLauncher
$plistcontent | Out-File -Force -Path $plist -Encoding utf8

# Create shell script.
$executablepath = if ($IsPreview) { "/usr/local/bin/pwsh-preview" } else { "/usr/local/bin/pwsh" }
$executablepath = Get-PwshExecutablePath -IsPreview:$IsPreview -IsLTS:$LTS
$shellscript = "$macosapp/Contents/MacOS/PowerShell.sh"
$shellscriptcontent = $packagingStrings.MacOSLauncherScript -f $executablepath
$shellscriptcontent | Out-File -Force -Path $shellscript -Encoding utf8
Expand All @@ -1433,6 +1462,33 @@ function New-MacOSLauncher
return $appsfolder
}

function Get-PwshExecutablePath
{
param(
[switch] $IsPreview,
[switch] $IsLTS
)

if ($IsPreview -and $IsLTS)
{
throw "Cannot be LTS and Preview"
}

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

if ($Environment.IsLinux) {
"/usr/bin/$executableName"
} elseif ($Environment.IsMacOS) {
"/usr/local/bin/$executableName"
}
}

function Clear-MacOSLauncher
{
# This is needed to prevent installer from picking up
Expand Down
112 changes: 67 additions & 45 deletions tools/releaseBuild/Images/GenericLinuxFiles/PowerShellPackage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,55 +28,77 @@ if ($ReleaseTag)
$releaseTagParam = @{ 'ReleaseTag' = $ReleaseTag }
}

Push-Location
try {
Set-Location $location
Import-Module "$location/build.psm1"
Import-Module "$location/tools/packaging"

Start-PSBootstrap -Package -NoSudo

$buildParams = @{ Configuration = 'Release'; PSModuleRestore = $true}

if($FxDependent.IsPresent) {
$projectAssetsZipName = 'linuxFxDependantProjectAssetssymbols.zip'
$buildParams.Add("Runtime", "fxdependent")
} elseif ($Alpine.IsPresent) {
$projectAssetsZipName = 'linuxAlpineProjectAssetssymbols.zip'
$buildParams.Add("Runtime", 'alpine-x64')
} else {
# make the artifact name unique
$projectAssetsZipName = "linuxProjectAssets-$((get-date).Ticks)-symbols.zip"
$buildParams.Add("Crossgen", $true)
}

Start-PSBuild @buildParams @releaseTagParam
#Remove the initial 'v' from the ReleaseTag
$version = $ReleaseTag -replace '^v'
$semVersion = [System.Management.Automation.SemanticVersion] $version

## All even minor versions are LTS
$LTS = if ( $semVersion.PreReleaseLabel -eq $null -and $semVersion.Minor % 2 -eq 0) {
$true
} else {
$false
}

if($FxDependent) {
Start-PSPackage -Type 'fxdependent' @releaseTagParam
} elseif ($Alpine) {
Start-PSPackage -Type 'tar-alpine' @releaseTagParam
} else {
Start-PSPackage @releaseTagParam
function BuildPackages {
param(
[switch] $LTS
)

Push-Location
try {
Set-Location $location
Import-Module "$location/build.psm1"
Import-Module "$location/tools/packaging"

Start-PSBootstrap -Package -NoSudo

$buildParams = @{ Configuration = 'Release'; PSModuleRestore = $true; Restore = $true }

if ($FxDependent.IsPresent) {
$projectAssetsZipName = 'linuxFxDependantProjectAssetssymbols.zip'
$buildParams.Add("Runtime", "fxdependent")
} elseif ($Alpine.IsPresent) {
$projectAssetsZipName = 'linuxAlpineProjectAssetssymbols.zip'
$buildParams.Add("Runtime", 'alpine-x64')
} else {
# make the artifact name unique
$projectAssetsZipName = "linuxProjectAssets-$((get-date).Ticks)-symbols.zip"
$buildParams.Add("Crossgen", $true)
}

Start-PSBuild @buildParams @releaseTagParam

if ($FxDependent) {
Start-PSPackage -Type 'fxdependent' @releaseTagParam -LTS:$LTS
} elseif ($Alpine) {
Start-PSPackage -Type 'tar-alpine' @releaseTagParam -LTS:$LTS
} else {
Start-PSPackage @releaseTagParam -LTS:$LTS
}

if ($TarX64) { Start-PSPackage -Type tar @releaseTagParam -LTS:$LTS }

if ($TarArm) {
## Build 'linux-arm' and create 'tar.gz' package for it.
## Note that 'linux-arm' can only be built on Ubuntu environment.
Start-PSBuild -Configuration Release -Restore -Runtime linux-arm -PSModuleRestore @releaseTagParam
Start-PSPackage -Type tar-arm @releaseTagParam -LTS:$LTS
}

if ($TarArm64) {
Start-PSBuild -Configuration Release -Restore -Runtime linux-arm64 -PSModuleRestore @releaseTagParam
Start-PSPackage -Type tar-arm64 @releaseTagParam -LTS:$LTS
}
} finally {
Pop-Location
}
}

if ($TarX64) { Start-PSPackage -Type tar @releaseTagParam }
BuildPackages

if ($TarArm) {
## Build 'linux-arm' and create 'tar.gz' package for it.
## Note that 'linux-arm' can only be built on Ubuntu environment.
Start-PSBuild -Configuration Release -Restore -Runtime linux-arm -PSModuleRestore @releaseTagParam
Start-PSPackage -Type tar-arm @releaseTagParam
}

if ($TarArm64) {
Start-PSBuild -Configuration Release -Restore -Runtime linux-arm64 -PSModuleRestore @releaseTagParam
Start-PSPackage -Type tar-arm64 @releaseTagParam
}
}
finally
{
Pop-Location
if ($LTS) {
Write-Verbose -Verbose "Packaging LTS"
BuildPackages -LTS
}

$linuxPackages = Get-ChildItem "$location/powershell*" -Include *.deb,*.rpm,*.tar.gz
Expand Down
1 change: 1 addition & 0 deletions tools/releaseBuild/azureDevOps/templates/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:

- powershell: |
tools/releaseBuild/vstsbuild.ps1 -ReleaseTag $(ReleaseTagVar) -Name '$(build)'

displayName: 'Build and package'
condition: and(succeeded(), ne(variables['SkipBuild'], 'true'))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,20 @@ jobs:
$zipFile = "$(Build.StagingDirectory)\macos\powershell-$(Version)-osx-x64.zip"
Compress-Archive -Path "$(System.ArtifactsDirectory)\results\powershell-$(Version)-osx-x64.pkg" -Destination $zipFile
Write-Host $zipFile

$ltsPkgPath = "$(System.ArtifactsDirectory)\results\powershell-lts-$(Version)-osx-x64.pkg"

if(Test-Path $ltsPkgPath)
{
$ltsZipFile = "$(Build.StagingDirectory)\macos\powershell-lts-$(Version)-osx-x64.zip"
Compress-Archive -Path $ltsPkgPath -Destination $ltsZipFile
Write-Host $ltsZipFile
}
displayName: 'Compress macOS Package'

- powershell: |
tools/releaseBuild/generatePackgeSigning.ps1 -MacDeveloperFiles "$(Build.StagingDirectory)\macos\powershell-$(Version)-osx-x64.zip" -path "$(System.ArtifactsDirectory)\package.xml"
$pkgFiles = "$(Build.StagingDirectory)\macos\powershell-$(Version)-osx-x64.zip", "$(Build.StagingDirectory)\macos\powershell-lts-$(Version)-osx-x64.zip"
tools/releaseBuild/generatePackgeSigning.ps1 -MacDeveloperFiles $pkgFiles -path "$(System.ArtifactsDirectory)\package.xml"
displayName: 'Generate macOS Package Signing Xml'

- powershell: |
Expand Down Expand Up @@ -68,7 +78,7 @@ jobs:
$destination = "$(System.ArtifactsDirectory)\azureMacOs"
New-Item -Path $destination -Type Directory
$zipPath = dir "$(Build.StagingDirectory)\signedMacOSPackages\powershell-*.zip" -Recurse | select-object -expandproperty fullname
Expand-Archive -Path $zipPath -DestinationPath $destination
foreach ($z in $zipPath) { Expand-Archive -Path $z -DestinationPath $destination }
$targzPath = dir "$(System.ArtifactsDirectory)\*.tar.gz" -Recurse | select-object -expandproperty fullname
Copy-Item -Path $targzPath -Destination $destination
displayName: 'Extract and copy macOS artifacts for upload'
Expand Down
Loading