-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Packaging: make mac package require 10.12 or newer #5649
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
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
00739c7
Add background image asset for mac package
TravisEz13 829a5ca
Add link to distribution XML reference
TravisEz13 8b278a0
address prior PR comments from #5625
TravisEz13 6a83388
[Package] Add packaging step which adds distribution xml
TravisEz13 d68e10f
[Package] Address PR comments
TravisEz13 31fe05a
[Package] Address @thezim 's comments
TravisEz13 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -582,7 +582,7 @@ function New-UnixPackage { | |
| } | ||
| } | ||
|
|
||
| # Verify depenecies are installed and in the path | ||
| # Verify dependencies are installed and in the path | ||
| Test-Dependencies | ||
|
|
||
| $Description = $packagingStrings.Description | ||
|
|
@@ -653,8 +653,7 @@ function New-UnixPackage { | |
| if($pscmdlet.ShouldProcess("Add macOS launch application")) | ||
| { | ||
| # Generate launcher app folder | ||
| $appsfolder = New-MacOSLauncher -Version $Version | ||
| $Arguments += "$appsfolder=/" | ||
| $AppsFolder = New-MacOSLauncher -Version $Version | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -681,7 +680,9 @@ function New-UnixPackage { | |
| -ManGzipFile $ManGzipInfo.GzipFile ` | ||
| -ManDestination $ManGzipInfo.ManFile ` | ||
| -LinkSource $LinkSource ` | ||
| -LinkDestination $Link | ||
| -LinkDestination $Link ` | ||
| -AppsFolder $AppsFolder ` | ||
| -ErrorAction Stop | ||
|
|
||
| # Build package | ||
| try { | ||
|
|
@@ -702,10 +703,10 @@ function New-UnixPackage { | |
| } | ||
| } | ||
| if ($AfterScriptInfo.AfterInstallScript) { | ||
| Remove-Item -erroraction 'silentlycontinue' $AfterScriptInfo.AfterInstallScript | ||
| Remove-Item -erroraction 'silentlycontinue' $AfterScriptInfo.AfterInstallScript -Force | ||
| } | ||
| if ($AfterScriptInfo.AfterRemoveScript) { | ||
| Remove-Item -erroraction 'silentlycontinue' $AfterScriptInfo.AfterRemoveScript | ||
| Remove-Item -erroraction 'silentlycontinue' $AfterScriptInfo.AfterRemoveScript -Force | ||
| } | ||
| Remove-Item -Path $ManGzipInfo.GzipFile -Force -ErrorAction SilentlyContinue | ||
| } | ||
|
|
@@ -714,22 +715,9 @@ function New-UnixPackage { | |
| $createdPackage = Get-Item (Join-Path $PWD (($Output[-1] -split ":path=>")[-1] -replace '["{}]')) | ||
|
|
||
| if ($Environment.IsMacOS) { | ||
| if ($pscmdlet.ShouldProcess("Fix package name")) | ||
| if ($pscmdlet.ShouldProcess("Add distribution information and Fix PackageName")) | ||
| { | ||
| # Add the OS information to the macOS package file name. | ||
| $packageExt = [System.IO.Path]::GetExtension($createdPackage.Name) | ||
| $packageNameWithoutExt = [System.IO.Path]::GetFileNameWithoutExtension($createdPackage.Name) | ||
|
|
||
| $newPackageName = "{0}-{1}{2}" -f $packageNameWithoutExt, $script:Options.Runtime, $packageExt | ||
| $newPackagePath = Join-Path $createdPackage.DirectoryName $newPackageName | ||
|
|
||
| # -Force is not deleting the NewName if it exists, so delete it if it does | ||
| if ($Force -and (Test-Path -Path $newPackagePath)) | ||
| { | ||
| Remove-Item -Force $newPackagePath | ||
| } | ||
|
|
||
| $createdPackage = Rename-Item -Path $createdPackage.FullName -NewName $newPackagePath -PassThru -ErrorAction Stop | ||
| $createdPackage = New-MacOsDistributionPackage -FpmPackage $createdPackage | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -745,7 +733,70 @@ function New-UnixPackage { | |
| } | ||
| } | ||
|
|
||
| function New-MacOsDistributionPackage | ||
| { | ||
| param( | ||
| [Parameter(Mandatory,HelpMessage='The FileInfo of the file created by FPM')] | ||
| [System.IO.FileInfo]$FpmPackage | ||
| ) | ||
|
|
||
| if(!$Environment.IsMacOS) | ||
| { | ||
| throw 'New-MacOsDistributionPackage is only supported on macOS!' | ||
| } | ||
|
|
||
| $packageName = Split-Path -leaf -Path $FpmPackage | ||
|
|
||
| # Create a temp directory to store the needed files | ||
| $tempDir = Join-Path ([System.IO.Path]::GetTempPath()) ([System.IO.Path]::GetRandomFileName()) | ||
| New-Item -ItemType Directory -Path $tempDir -Force > $null | ||
|
|
||
| $resourcesDir = Join-Path -path $tempDir -childPath 'resources' | ||
| New-Item -ItemType Directory -Path $resourcesDir -Force > $null | ||
| #Copy background file to temp directory | ||
| $backgroundFile = Join-Path $PSScriptRoot "/../../assets/macDialog.png" | ||
| Copy-Item -Path $backgroundFile -Destination $resourcesDir | ||
| # Move the current package to the temp directory | ||
| $tempPackagePath = Join-Path -path $tempDir -ChildPath $packageName | ||
| Move-Item -Path $FpmPackage -Destination $tempPackagePath -Force | ||
|
|
||
| # Add the OS information to the macOS package file name. | ||
| $packageExt = [System.IO.Path]::GetExtension($FpmPackage.Name) | ||
| $packageNameWithoutExt = [System.IO.Path]::GetFileNameWithoutExtension($FpmPackage.Name) | ||
|
|
||
| $newPackageName = "{0}-{1}{2}" -f $packageNameWithoutExt, $script:Options.Runtime, $packageExt | ||
| $newPackagePath = Join-Path $FpmPackage.DirectoryName $newPackageName | ||
|
|
||
| # -Force is not deleting the NewName if it exists, so delete it if it does | ||
| if ($Force -and (Test-Path -Path $newPackagePath)) | ||
| { | ||
| Remove-Item -Force $newPackagePath | ||
| } | ||
|
|
||
| # Create the distribution xml | ||
| $distributionXmlPath = Join-Path -Path $tempDir -ChildPath 'powershellDistribution.xml' | ||
|
|
||
| # format distribution template with: | ||
| # 0 - title | ||
| # 1 - version | ||
| # 2 - package path | ||
| # 2 - minimum os version | ||
| $PackagingStrings.OsxDistributionTemplate -f "PowerShell - $Version", $Version, $packageName, '10.12' | Out-File -Encoding ascii -FilePath $distributionXmlPath -Force | ||
|
|
||
| log "Applying distribution.xml to package..." | ||
| Push-Location $tempDir | ||
| try | ||
| { | ||
| Start-NativeExecution -sb {productbuild --distribution $distributionXmlPath --resources $resourcesDir $newPackagePath} | ||
| } | ||
| finally | ||
| { | ||
| Pop-Location | ||
| Remove-item -Path $tempDir -Recurse -Force | ||
| } | ||
|
|
||
| return $newPackagePath | ||
| } | ||
| function Get-FpmArguments | ||
| { | ||
| param( | ||
|
|
@@ -814,7 +865,18 @@ function Get-FpmArguments | |
| } | ||
| return $true | ||
| })] | ||
| [String]$AfterRemoveScript | ||
| [String]$AfterRemoveScript, | ||
|
|
||
| [Parameter(HelpMessage='AppsFolder used to add macOS launcher')] | ||
| [AllowNull()] | ||
| [ValidateScript({ | ||
| if ($Environment.IsMacOS -and !$_) | ||
| { | ||
| throw "Must not be null on this environment." | ||
| } | ||
| return $true | ||
| })] | ||
| [String]$AppsFolder | ||
| ) | ||
|
|
||
| $Arguments = @( | ||
|
|
@@ -858,6 +920,12 @@ function Get-FpmArguments | |
| "$LinkSource=$LinkDestination" | ||
| ) | ||
|
|
||
| if($AppsFolder) | ||
| { | ||
| $Arguments += "$AppsFolder=/" | ||
| } | ||
|
|
||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non-blocking: remove an extra new line. |
||
| return $Arguments | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-blocking: it's better to add a comment explaining that
productbuild is a xcode command line tool which will be installed when homebrew is installed, so that people won't question about whether bootstrap script needs to be updated 😄