Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save al3xtjames/fd9d701a485a63af40a493ec6b9f9f9c to your computer and use it in GitHub Desktop.
Save al3xtjames/fd9d701a485a63af40a493ec6b9f9f9c to your computer and use it in GitHub Desktop.
From 4d4919ba08fcf95e4d6e727f369737ac513b3540 Mon Sep 17 00:00:00 2001
From: Alex James <theracermaster@gmail.com>
Date: Sun, 11 Jul 2021 21:26:50 -0500
Subject: [PATCH] macOS build: add script to generate app bundle
---
packaging/macos/build_app_bundle.sh | 72 +++++++++++++++++++++++++++++
1 file changed, 72 insertions(+)
create mode 100755 packaging/macos/build_app_bundle.sh
diff --git a/packaging/macos/build_app_bundle.sh b/packaging/macos/build_app_bundle.sh
new file mode 100755
index 000000000..942a91631
--- /dev/null
+++ b/packaging/macos/build_app_bundle.sh
@@ -0,0 +1,72 @@
+#!/usr/bin/env bash
+
+set -e
+
+if [ "$#" -ne 1 ]; then
+ echo "Usage: build_app_bundle.sh <prefix>"
+ exit 1
+fi
+
+prefix="$1"
+version=$("$prefix/bin/mkvmerge" -V | grep -E -o '[0-9]+\.[0-9]+\.[0-9]+')
+min_os_version=$(otool -l "$prefix/bin/mkvmerge" | awk '/minos/ {print $2}')
+
+echo "Creating app bundle for MKVToolNix-$version"
+
+app_base=MKVToolNix-$version.app/Contents
+mkdir -p "$app_base"/{MacOS,Resources}
+cp -r "$prefix"/bin/ "$app_base"/MacOS
+cp -r "$prefix"/share/{applications,icons,locale,man,metainfo,mime} "$app_base"/MacOS
+cp -r "$prefix"/share/mkvtoolnix/sounds "$app_base"/MacOS
+cp share/icons/macos/MKVToolNix.icns "$app_base"/Resources
+
+cat << EOF > "$app_base"/Info.plist
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+ <dict>
+ <key>LSEnvironment</key>
+ <dict>
+ <key>LANG</key>
+ <string>en_US.UTF-8</string>
+ </dict>
+ <key>Properties</key>
+ <dict>
+ <key>file.encoding</key> <string>UTF-8</string>
+ </dict>
+ <key>CFBundleDevelopmentRegion</key> <string>en-US</string>
+ <key>CFBundleIdentifier</key> <string>download.mkvtoolnix.MKVToolNix</string>
+ <key>CFBundleExecutable</key> <string>mkvtoolnix-gui</string>
+ <key>CFBundleInfoDictionaryVersion</key> <string>6.0</string>
+ <key>CFBundlePackageType</key> <string>APPL</string>
+ <key>CSResourcesFileMapped</key> <true/>
+ <key>CFBundleVersion</key> <string>${version}</string>
+ <key>CFBundleShortVersionString</key> <string>${version}</string>
+ <key>NSPrincipalClass</key> <string>NSApplication</string>
+ <key>LSMinimumSystemVersion</key> <string>${min_os_version}</string>
+ <key>CFBundleDisplayName</key> <string>MKVToolNix</string>
+ <key>CFBundleName</key> <string>MKVToolNix</string>
+ <key>CFBundleIconFile</key> <string>MKVToolNix.icns</string>
+ <key>CFBundleDocumentTypes</key>
+ <array>
+ <dict>
+ <key>CFBundleTypeExtensions</key>
+ <array>
+ <!-- Here goes the file formats your app can read -->
+ </array>
+ <key>CFBundleTypeIconFile</key> <string>MKVToolNix.icns</string>
+ <key>CFBundleTypeName</key> <string>MKVToolNix-${version}</string>
+ <key>CFBundleTypeRole</key> <string>Editor</string>
+ <key>LSIsAppleDefaultForType</key> <true/>
+ <key>LSTypeIsPackage</key> <false/>
+ </dict>
+ </array>
+ </dict>
+</plist>
+EOF
+
+set +e
+macdeployqt "$app_base"/.. -executable="$app_base"/MacOS/mkvextract \
+ -executable="$app_base"/MacOS/mkvinfo \
+ -executable="$app_base"/MacOS/mkvmerge \
+ -executable="$app_base"/MacOS/mkvpropedit
--
2.32.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment