diff --git a/build.psm1 b/build.psm1 index f528ee8210..aa6741ed0c 100644 --- a/build.psm1 +++ b/build.psm1 @@ -308,6 +308,7 @@ function Start-PSBuild { [ValidateSet("alpine-x64", "fxdependent", "fxdependent-linux-x64", + "fxdependent-linux-arm64", "fxdependent-win-desktop", "linux-arm", "linux-arm64", @@ -426,6 +427,7 @@ Fix steps: PSModuleRestore=$PSModuleRestore ForMinimalSize=$ForMinimalSize } + $script:Options = New-PSOptions @OptionsArguments if ($StopDevPowerShell) { @@ -829,6 +831,7 @@ function New-PSOptions { "alpine-x64", "fxdependent", "fxdependent-linux-x64", + "fxdependent-linux-arm64", "fxdependent-win-desktop", "linux-arm", "linux-arm64", @@ -913,9 +916,14 @@ function New-PSOptions { # Build the Output path if (!$Output) { - if ($Runtime -like 'fxdependent*') { + if ($Runtime -like 'fxdependent*' -and $Runtime -like 'fxdependent*linux*') { + $outputRuntime = $Runtime -replace 'fxdependent-', '' + $Output = [IO.Path]::Combine($Top, "bin", $Configuration, $Framework, $outputRuntime, "publish", $Executable) + } + elseif ($Runtime -like 'fxdependent*') { $Output = [IO.Path]::Combine($Top, "bin", $Configuration, $Framework, "publish", $Executable) - } else { + } + else { $Output = [IO.Path]::Combine($Top, "bin", $Configuration, $Framework, $Runtime, "publish", $Executable) } } else { diff --git a/tools/ci.psm1 b/tools/ci.psm1 index e2feca60dd..07a73f1b02 100644 --- a/tools/ci.psm1 +++ b/tools/ci.psm1 @@ -777,7 +777,7 @@ function New-LinuxPackage # Only build packages for PowerShell/PowerShell repository # branches, not pull requests - $packages = @(Start-PSPackage @packageParams -SkipReleaseChecks -Type deb, rpm, tar) + $packages = @(Start-PSPackage @packageParams -SkipReleaseChecks -Type deb, rpm, rpm-fxdependent-arm64, tar) foreach($package in $packages) { if (Test-Path $package) diff --git a/tools/packaging/packaging.psm1 b/tools/packaging/packaging.psm1 index adb96dc557..20c6a65c79 100644 --- a/tools/packaging/packaging.psm1 +++ b/tools/packaging/packaging.psm1 @@ -37,7 +37,7 @@ function Start-PSPackage { [string]$Name = "powershell", # Ubuntu, CentOS, Fedora, macOS, and Windows packages are supported - [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")] + [ValidateSet("msix", "deb", "osxpkg", "rpm", "rpm-fxdependent", "rpm-fxdependent-arm64", "msi", "zip", "zip-pdb", "nupkg", "tar", "tar-arm", "tar-arm64", "tar-alpine", "fxdependent", "fxdependent-win-desktop", "min-size")] [string[]]$Type, # Generate windows downlevel package @@ -97,7 +97,10 @@ function Start-PSPackage { } } 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 { + } elseif ($Type.Count -eq 1 -and $Type[0] -eq "rpm-fxdependent-arm64") { + New-PSOptions -Configuration "Release" -Runtime 'fxdependent-linux-arm64' -WarningAction SilentlyContinue | ForEach-Object { $_.Runtime, $_.Configuration } + } + else { New-PSOptions -Configuration "Release" -WarningAction SilentlyContinue | ForEach-Object { $_.Runtime, $_.Configuration } } @@ -512,6 +515,7 @@ function Start-PSPackage { Force = $Force NoSudo = $NoSudo LTS = $LTS + HostArchitecture = "amd64" } foreach ($Distro in $Script:DebianDistributions) { $Arguments["Distribution"] = $Distro @@ -529,6 +533,7 @@ function Start-PSPackage { Force = $Force NoSudo = $NoSudo LTS = $LTS + HostArchitecture = "x86_64" } foreach ($Distro in $Script:RedhatFullDistributions) { $Arguments["Distribution"] = $Distro @@ -547,6 +552,7 @@ function Start-PSPackage { Force = $Force NoSudo = $NoSudo LTS = $LTS + HostArchitecture = "x86_64" } foreach ($Distro in $Script:RedhatFddDistributions) { $Arguments["Distribution"] = $Distro @@ -556,6 +562,26 @@ function Start-PSPackage { } } } + 'rpm-fxdependent-arm64' { + $Arguments = @{ + Type = 'rpm' + PackageSourcePath = $Source + Name = $Name + Version = $Version + Force = $Force + NoSudo = $NoSudo + LTS = $LTS + HostArchitecture = "aarch64" + } + foreach ($Distro in $Script:RedhatFddDistributions) { + $Arguments["Distribution"] = $Distro + $Arguments["HostArchitecture"] = $HostArchitecture + if ($PSCmdlet.ShouldProcess("Create RPM Package for $Distro")) { + Write-Verbose -Verbose "Creating RPM Package for $Distro" + New-UnixPackage @Arguments + } + } + } 'osxpkg' { $HostArchitecture = "x86_64" if ($MacOSRuntime -match "-arm64") { @@ -588,6 +614,7 @@ function Start-PSPackage { Force = $Force NoSudo = $NoSudo LTS = $LTS + HostArchitecture = "all" } if ($PSCmdlet.ShouldProcess("Create $_ Package")) { @@ -844,6 +871,10 @@ function New-UnixPackage { # This is a string because strings are appended to it [string]$Iteration = "1", + [string] + [ValidateSet("x86_64", "amd64", "aarch64", "native", "all", "noarch", "any")] + $HostArchitecture, + [Switch] $Force, @@ -873,9 +904,9 @@ function New-UnixPackage { $Attributes = New-Object "System.Collections.ObjectModel.Collection``1[System.Attribute]" $Attributes.Add($ParameterAttr) > $null $Attributes.Add($ValidateSetAttr) > $null - - $Parameter = New-Object "System.Management.Automation.RuntimeDefinedParameter" -ArgumentList ("Distribution", [string], $Attributes) $Dict = New-Object "System.Management.Automation.RuntimeDefinedParameterDictionary" + $Parameter = New-Object "System.Management.Automation.RuntimeDefinedParameter" -ArgumentList ("Distribution", [string], $Attributes) + $Dict.Add("Distribution", $Parameter) > $null return $Dict } elseif ($Type -eq "osxpkg") { @@ -990,6 +1021,7 @@ function New-UnixPackage { # Destination for symlink to powershell executable $Link = Get-PwshExecutablePath -IsPreview:$IsPreview + $links = @(New-LinkInfo -LinkDestination $Link -LinkTarget "$Destination/pwsh") if($LTS) { @@ -1049,7 +1081,10 @@ function New-UnixPackage { # Setup package dependencies $Dependencies = @(Get-PackageDependencies @packageDependenciesParams) - $Arguments = Get-FpmArguments ` + $Arguments = @() + + + $Arguments += Get-FpmArguments ` -Name $Name ` -Version $packageVersion ` -Iteration $Iteration ` @@ -1065,6 +1100,7 @@ function New-UnixPackage { -LinkInfo $Links ` -AppsFolder $AppsFolder ` -Distribution $DebDistro ` + -HostArchitecture $HostArchitecture ` -ErrorAction Stop # Build package @@ -1316,7 +1352,8 @@ function Get-FpmArguments return $true })] [String]$AppsFolder, - [String]$Distribution = 'rhel.7' + [String]$Distribution = 'rhel.7', + [string]$HostArchitecture ) $Arguments = @( @@ -1328,6 +1365,7 @@ function Get-FpmArguments "--vendor", "Microsoft Corporation", "--url", "https://microsoft.com/powershell", "--description", $Description, + "--architecture", $HostArchitecture, "--category", "shells", "-t", $Type, "-s", "dir"