64 lines
1.9 KiB
Bash
Executable file
64 lines
1.9 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Part of JoeyLib, Copyright (c) 2026 Scott Duensing, under the MIT License.
|
|
# See LICENSE.md for license information.
|
|
# SPDX-License-Identifier: MIT
|
|
#
|
|
# Pack a linked macOS program into its app, as make/macos.mk's packing step:
|
|
# the program as Contents/MacOS/NAME (NAME the app's, without .app), and
|
|
# Contents/Info.plist, which tells macOS that is the program to run, the
|
|
# app's identifier and title, its icon (Contents/Resources/icon.icns, baked
|
|
# by make beside its DATA), the oldest macOS it runs on (cc.sh's), and that
|
|
# it draws at a Retina screen's own resolution. The program's Apple silicon
|
|
# half carries the ad hoc signature zig gave it, which a copy keeps.
|
|
#
|
|
# Usage: packApp.sh PROGRAM NAME.app IDENTIFIER TITLE
|
|
|
|
set -euo pipefail
|
|
|
|
if [[ $# -ne 4 ]]; then
|
|
echo "usage: $0 PROGRAM NAME.app IDENTIFIER TITLE" >&2
|
|
exit 2
|
|
fi
|
|
|
|
program=$1
|
|
app=$2
|
|
identifier=$3
|
|
title=$4
|
|
name=$(basename "$app" .app)
|
|
minimum=$("$(dirname "$0")/cc.sh" --minimum)
|
|
|
|
# The title as XML text.
|
|
title=${title//&/&}
|
|
title=${title//</<}
|
|
title=${title//>/>}
|
|
|
|
mkdir -p "$app/Contents/MacOS" "$app/Contents/Resources"
|
|
cp -f "$program" "$app/Contents/MacOS/$name"
|
|
cat > "$app/Contents/Info.plist" <<EOF
|
|
<?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>CFBundleDevelopmentRegion</key>
|
|
<string>en</string>
|
|
<key>CFBundleDisplayName</key>
|
|
<string>$title</string>
|
|
<key>CFBundleExecutable</key>
|
|
<string>$name</string>
|
|
<key>CFBundleIconFile</key>
|
|
<string>icon</string>
|
|
<key>CFBundleIdentifier</key>
|
|
<string>$identifier</string>
|
|
<key>CFBundleInfoDictionaryVersion</key>
|
|
<string>6.0</string>
|
|
<key>CFBundleName</key>
|
|
<string>$name</string>
|
|
<key>CFBundlePackageType</key>
|
|
<string>APPL</string>
|
|
<key>LSMinimumSystemVersion</key>
|
|
<string>$minimum</string>
|
|
<key>NSHighResolutionCapable</key>
|
|
<true/>
|
|
</dict>
|
|
</plist>
|
|
EOF
|