Skip to content
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>PowerShell.sh</string>
<key>CFBundleGetInfoString</key>
<string></string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string></string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>PowerShell</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string></string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>CFBundleVersion</key>
<string></string>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
open /usr/local/bin/pwsh
70 changes: 70 additions & 0 deletions tools/packaging/packaging.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -629,13 +629,83 @@ function New-UnixPackage {
"$GzipFile=$ManFile",
"/tmp/pwsh=$Link"
)

# Add macOS powershell launcher
if($Type -eq "osxpkg")
{
if($pscmdlet.ShouldProcess("Add macOS launch application")) {
# Define folder for launch application.
$macosapp = "$PSScriptRoot/macos/launcher/ROOT/Applications/Powershell.app"

# Update icns file.
$iconfile = "$PSScriptRoot/../../assets/Powershell.icns"
$iconfilebase = (Get-Item -Path $iconfile).BaseName

# Create Resources folder, ignore error if exists.
New-Item -Force -ItemType Directory -Path "$macosapp/Contents/Resources" | Out-Null
Copy-Item -Force -Path $iconfile -Destination "$macosapp/Contents/Resources"

# Set values in plist.
$plist = "$macosapp/Contents/Info.plist"
Start-NativeExecution {
defaults write $plist CFBundleIdentifier com.microsoft.powershell
defaults write $plist CFBundleVersion $Version
defaults write $plist CFBundleShortVersionString $Version
defaults write $plist CFBundleGetInfoString $Version
defaults write $plist CFBundleIconFile $iconfilebase
}

# Convert to XML plist, needed because defaults native
# app auto converts it to binary format when it modify
# the plist file.
Start-NativeExecution {
plutil -convert xml1 $plist
}

# Set permissions for plist and shell script. Note that
# defaults native app sets 700 when writing to the plist
# file from above. Both of these will be reset post fpm.
$shellscript = "$macosapp/Contents/MacOS/PowerShell.sh"
Start-NativeExecution {
chmod 644 $plist
chmod 755 $shellscript
}

# Add app folder to fpm paths.
$appsfolder = (Resolve-Path -Path "$macosapp/..").Path
$Arguments += "$appsfolder=/"
}
}

# Build package
try {
if($pscmdlet.ShouldProcess("Create $type package")) {
$Output = Start-NativeExecution { fpm $Arguments }
}
} finally {
if ($Environment.IsMacOS) {
if($pscmdlet.ShouldProcess("Cleanup macOS launcher"))
{
# This is needed to prevent installer from picking up
# the launcher app in the build structure and updating
# it which locks out subsequent package builds due to
# increase permissions.
$macosapp = "$PSScriptRoot/macos/launcher/ROOT/Applications/Powershell.app"
$plist = "$macosapp/Contents/Info.plist"
$tempguid = (New-Guid).Guid
Start-NativeExecution {
defaults write $plist CFBundleIdentifier $tempguid
plutil -convert xml1 $plist
}

# Restore default permissions.
$shellscript = "$macosapp/Contents/MacOS/PowerShell.sh"
Start-NativeExecution {
chmod 644 $shellscript
chmod 644 $plist
}
}

# 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)"
Expand Down