mirror of
https://github.com/PowerShell/PowerShell.git
synced 2024-11-23 17:53:58 +08:00
Make mariner packages Framework dependent (#17425)
This commit is contained in:
parent
3cfa8eb258
commit
865394022e
20
build.psm1
20
build.psm1
@ -269,6 +269,8 @@ function Test-IsReleaseCandidate
|
||||
return $false
|
||||
}
|
||||
|
||||
$optimizedFddRegex = 'fxdependent-(linux|alpine|win|win7|osx)-(x64|x86|arm64|arm)'
|
||||
|
||||
function Start-PSBuild {
|
||||
[CmdletBinding(DefaultParameterSetName="Default")]
|
||||
param(
|
||||
@ -303,6 +305,7 @@ function Start-PSBuild {
|
||||
# If this parameter is not provided it will get determined automatically.
|
||||
[ValidateSet("alpine-x64",
|
||||
"fxdependent",
|
||||
"fxdependent-linux-x64",
|
||||
"fxdependent-win-desktop",
|
||||
"linux-arm",
|
||||
"linux-arm64",
|
||||
@ -457,7 +460,7 @@ Fix steps:
|
||||
# Framework Dependent builds do not support ReadyToRun as it needs a specific runtime to optimize for.
|
||||
# The property is set in Powershell.Common.props file.
|
||||
# We override the property through the build command line.
|
||||
if($Options.Runtime -like 'fxdependent*' -or $ForMinimalSize) {
|
||||
if(($Options.Runtime -like 'fxdependent*' -or $ForMinimalSize) -and $Options.Runtime -notmatch $optimizedFddRegex) {
|
||||
$Arguments += "/property:PublishReadyToRun=false"
|
||||
}
|
||||
|
||||
@ -472,6 +475,9 @@ Fix steps:
|
||||
if (-not $SMAOnly -and $Options.Runtime -notlike 'fxdependent*') {
|
||||
# libraries should not have runtime
|
||||
$Arguments += "--runtime", $Options.Runtime
|
||||
} elseif ($Options.Runtime -match $optimizedFddRegex) {
|
||||
$runtime = $Options.Runtime -replace 'fxdependent-', ''
|
||||
$Arguments += "--runtime", $runtime
|
||||
}
|
||||
|
||||
if ($ReleaseTag) {
|
||||
@ -495,7 +501,12 @@ Fix steps:
|
||||
|
||||
# Handle TypeGen
|
||||
# .inc file name must be different for Windows and Linux to allow build on Windows and WSL.
|
||||
$incFileName = "powershell_$($Options.Runtime).inc"
|
||||
$runtime = $Options.Runtime
|
||||
if ($Options.Runtime -match $optimizedFddRegex) {
|
||||
$runtime = $Options.Runtime -replace 'fxdependent-', ''
|
||||
}
|
||||
|
||||
$incFileName = "powershell_$runtime.inc"
|
||||
if ($TypeGen -or -not (Test-Path "$PSScriptRoot/src/TypeCatalogGen/$incFileName")) {
|
||||
Write-Log -message "Run TypeGen (generating CorePsTypeCatalog.cs)"
|
||||
Start-TypeGen -IncFileName $incFileName
|
||||
@ -513,7 +524,8 @@ Fix steps:
|
||||
# Relative paths do not work well if cwd is not changed to project
|
||||
Push-Location $Options.Top
|
||||
|
||||
if ($Options.Runtime -notlike 'fxdependent*') {
|
||||
if ($Options.Runtime -notlike 'fxdependent*' -or $Options.Runtime -match $optimizedFddRegex) {
|
||||
Write-Verbose "Building without shim" -Verbose
|
||||
$sdkToUse = 'Microsoft.NET.Sdk'
|
||||
if ($Options.Runtime -like 'win7-*' -and !$ForMinimalSize) {
|
||||
## WPF/WinForm and the PowerShell GraphicalHost assemblies are included
|
||||
@ -527,6 +539,7 @@ Fix steps:
|
||||
Start-NativeExecution { dotnet $Arguments }
|
||||
Write-Log -message "PowerShell output: $($Options.Output)"
|
||||
} else {
|
||||
Write-Verbose "Building with shim" -Verbose
|
||||
$globalToolSrcFolder = Resolve-Path (Join-Path $Options.Top "../Microsoft.PowerShell.GlobalTool.Shim") | Select-Object -ExpandProperty Path
|
||||
|
||||
if ($Options.Runtime -eq 'fxdependent') {
|
||||
@ -809,6 +822,7 @@ function New-PSOptions {
|
||||
[ValidateSet("",
|
||||
"alpine-x64",
|
||||
"fxdependent",
|
||||
"fxdependent-linux-x64",
|
||||
"fxdependent-win-desktop",
|
||||
"linux-arm",
|
||||
"linux-arm64",
|
||||
|
@ -14,6 +14,11 @@
|
||||
"url": "microsoft-rhel7.3-prod",
|
||||
"distribution" : ["trusty"],
|
||||
"PackageFormat" : "PACKAGE_NAME-POWERSHELL_RELEASE-1.rh.x86_64.rpm"
|
||||
},
|
||||
{
|
||||
"url": "cbl-mariner-2.0-prod-Microsoft-x86_64-rpms",
|
||||
"distribution" : ["bionic"],
|
||||
"PackageFormat" : "PACKAGE_NAME-POWERSHELL_RELEASE-1.cm1.x86_64.rpm"
|
||||
},
|
||||
{
|
||||
"distribution" : ["stretch"],
|
||||
|
@ -7,7 +7,11 @@ $RepoRoot = (Resolve-Path -Path "$PSScriptRoot/../..").Path
|
||||
$packagingStrings = Import-PowerShellDataFile "$PSScriptRoot\packaging.strings.psd1"
|
||||
Import-Module "$PSScriptRoot\..\Xml" -ErrorAction Stop -Force
|
||||
$DebianDistributions = @("deb")
|
||||
$RedhatDistributions = @("rh","cm1")
|
||||
$RedhatFullDistributions = @("rh")
|
||||
$RedhatFddDistributions = @("cm1")
|
||||
$RedhatDistributions = @()
|
||||
$RedhatDistributions += $RedhatFullDistributions
|
||||
$RedhatDistributions += $RedhatFddDistributions
|
||||
$AllDistributions = @()
|
||||
$AllDistributions += $DebianDistributions
|
||||
$AllDistributions += $RedhatDistributions
|
||||
@ -33,7 +37,7 @@ function Start-PSPackage {
|
||||
[string]$Name = "powershell",
|
||||
|
||||
# Ubuntu, CentOS, Fedora, macOS, and Windows packages are supported
|
||||
[ValidateSet("msix", "deb", "osxpkg", "rpm", "msi", "zip", "zip-pdb", "nupkg", "tar", "tar-arm", "tar-arm64", "tar-alpine", "fxdependent", "fxdependent-win-desktop", "min-size")]
|
||||
[ValidateSet("msix", "deb", "osxpkg", "rpm", "rpm-fxdependent", "msi", "zip", "zip-pdb", "nupkg", "tar", "tar-arm", "tar-arm64", "tar-alpine", "fxdependent", "fxdependent-win-desktop", "min-size")]
|
||||
[string[]]$Type,
|
||||
|
||||
# Generate windows downlevel package
|
||||
@ -91,6 +95,8 @@ function Start-PSPackage {
|
||||
} else {
|
||||
New-PSOptions -Configuration "Release" -Runtime "Linux-ARM64" -WarningAction SilentlyContinue | ForEach-Object { $_.Runtime, $_.Configuration }
|
||||
}
|
||||
} elseif ($Type.Count -eq 1 -and $Type[0] -eq "rpm-fxdependent") {
|
||||
New-PSOptions -Configuration "Release" -Runtime 'fxdependent-linux-x64' -WarningAction SilentlyContinue | ForEach-Object { $_.Runtime, $_.Configuration }
|
||||
} else {
|
||||
New-PSOptions -Configuration "Release" -WarningAction SilentlyContinue | ForEach-Object { $_.Runtime, $_.Configuration }
|
||||
}
|
||||
@ -501,7 +507,25 @@ function Start-PSPackage {
|
||||
NoSudo = $NoSudo
|
||||
LTS = $LTS
|
||||
}
|
||||
foreach ($Distro in $Script:RedhatDistributions) {
|
||||
foreach ($Distro in $Script:RedhatFullDistributions) {
|
||||
$Arguments["Distribution"] = $Distro
|
||||
if ($PSCmdlet.ShouldProcess("Create RPM Package for $Distro")) {
|
||||
Write-Verbose -Verbose "Creating RPM Package for $Distro"
|
||||
New-UnixPackage @Arguments
|
||||
}
|
||||
}
|
||||
}
|
||||
'rpm-fxdependent' {
|
||||
$Arguments = @{
|
||||
Type = 'rpm'
|
||||
PackageSourcePath = $Source
|
||||
Name = $Name
|
||||
Version = $Version
|
||||
Force = $Force
|
||||
NoSudo = $NoSudo
|
||||
LTS = $LTS
|
||||
}
|
||||
foreach ($Distro in $Script:RedhatFddDistributions) {
|
||||
$Arguments["Distribution"] = $Distro
|
||||
if ($PSCmdlet.ShouldProcess("Create RPM Package for $Distro")) {
|
||||
Write-Verbose -Verbose "Creating RPM Package for $Distro"
|
||||
@ -788,7 +812,7 @@ function New-UnixPackage {
|
||||
)
|
||||
|
||||
DynamicParam {
|
||||
if ($Type -eq "deb" -or $Type -eq 'rpm') {
|
||||
if ($Type -eq "deb" -or $Type -like 'rpm*') {
|
||||
# Add a dynamic parameter '-Distribution' when the specified package type is 'deb'.
|
||||
# The '-Distribution' parameter can be used to indicate which Debian distro this pacakge is targeting.
|
||||
$ParameterAttr = New-Object "System.Management.Automation.ParameterAttribute"
|
||||
@ -1342,6 +1366,11 @@ function Get-PackageDependencies
|
||||
"icu"
|
||||
"openssl-libs"
|
||||
)
|
||||
if($Script:Options.Runtime -like 'fx*') {
|
||||
$Dependencies += @(
|
||||
"dotnet-runtime-7.0"
|
||||
)
|
||||
}
|
||||
} elseif ($Distribution -eq 'macOS') {
|
||||
# do nothing
|
||||
} else {
|
||||
@ -4211,6 +4240,7 @@ ${mainLinuxBuildFolder} = 'pwshLinuxBuild'
|
||||
${minSizeLinuxBuildFolder} = 'pwshLinuxBuildMinSize'
|
||||
${arm32LinuxBuildFolder} = 'pwshLinuxBuildArm32'
|
||||
${arm64LinuxBuildFolder} = 'pwshLinuxBuildArm64'
|
||||
${amd64MarinerBuildFolder} = 'pwshMarinerBuildAmd64'
|
||||
|
||||
<#
|
||||
Used in Azure DevOps Yaml to package all the linux packages for a channel.
|
||||
@ -4276,6 +4306,14 @@ function Invoke-AzDevOpsLinuxPackageCreation {
|
||||
## Note that 'linux-arm64' can only be built on Ubuntu environment.
|
||||
Restore-PSOptions -PSOptionsPath "${env:SYSTEM_ARTIFACTSDIRECTORY}\${arm64LinuxBuildFolder}-meta\psoptions.json"
|
||||
Start-PSPackage -Type tar-arm64 @releaseTagParam -LTS:$LTS
|
||||
} elseif ($BuildType -eq 'rpm') {
|
||||
Restore-PSOptions -PSOptionsPath "${env:SYSTEM_ARTIFACTSDIRECTORY}\${amd64MarinerBuildFolder}-meta\psoptions.json"
|
||||
|
||||
Write-Verbose -Verbose "---- rpm-fxdependent ----"
|
||||
Write-Verbose -Verbose "options.Output: $($options.Output)"
|
||||
Write-Verbose -Verbose "options.Top $($options.Top)"
|
||||
|
||||
Start-PSPackage -Type rpm-fxdependent @releaseTagParam -LTS:$LTS
|
||||
}
|
||||
}
|
||||
catch {
|
||||
@ -4355,6 +4393,23 @@ function Invoke-AzDevOpsLinuxPackageBuild {
|
||||
Start-PSBuild -Configuration Release -Restore -Runtime linux-arm64 -PSModuleRestore @releaseTagParam -Output $buildFolder -PSOptionsPath "${buildFolder}-meta/psoptions.json"
|
||||
# Remove symbol files.
|
||||
Remove-Item "${buildFolder}\*.pdb" -Force
|
||||
} elseif ($BuildType -eq 'rpm') {
|
||||
## Build 'min-size'
|
||||
$options = Get-PSOptions
|
||||
Write-Verbose -Verbose "---- Min-Size ----"
|
||||
Write-Verbose -Verbose "options.Output: $($options.Output)"
|
||||
Write-Verbose -Verbose "options.Top $($options.Top)"
|
||||
$binDir = Join-Path -Path $options.Top -ChildPath 'bin'
|
||||
if (Test-Path -Path $binDir) {
|
||||
Write-Verbose -Verbose "Remove $binDir, to get a clean build for min-size package"
|
||||
Remove-Item -Path $binDir -Recurse -Force
|
||||
}
|
||||
|
||||
$buildParams['Runtime'] = 'fxdependent-linux-x64'
|
||||
$buildFolder = "${env:SYSTEM_ARTIFACTSDIRECTORY}/${amd64MarinerBuildFolder}"
|
||||
Start-PSBuild -Clean @buildParams @releaseTagParam -Output $buildFolder -PSOptionsPath "${buildFolder}-meta/psoptions.json"
|
||||
# Remove symbol files, xml document files.
|
||||
Remove-Item "${buildFolder}\*.pdb", "${buildFolder}\*.xml" -Force
|
||||
}
|
||||
}
|
||||
catch {
|
||||
|
Loading…
Reference in New Issue
Block a user