summaryrefslogtreecommitdiffstats
path: root/osdep
diff options
context:
space:
mode:
authorDaniel Brookman <dannntrax@gmail.com>2023-08-10 16:09:37 -0400
committerder richter <der.richter@gmx.de>2023-11-15 23:08:11 +0100
commitaa8af2e66bf9613470c47c3a64e6d4ed7497fa14 (patch)
treef9dce64b4003e1167170105ca90a3ee7caf2e8c0 /osdep
parentdcb3213aa7495e4037b6040c103511aaac2f46c5 (diff)
downloadmpv-aa8af2e66bf9613470c47c3a64e6d4ed7497fa14.tar.bz2
mpv-aa8af2e66bf9613470c47c3a64e6d4ed7497fa14.tar.xz
osxbundle: remove mpv-bundle symlink to allow code signing
Apps on Apple silicon have to be codesigned to run, but you can't codesign bundles that have a symlink for the main executable. The "mpv-bundle" symlink was used as the bundle's main executable because it makes the execution name of the binary different. Launch Services runs the CFBundleExecutable key from Info.plist when launching a bundle, so by comparing the execution name to the name of the symlink, you can check if that's how the binary was launched. This replaces that detection method by moving the MPVBUNDLE environmental variable into Info.plist. Launch Services will set anything in LSEnvironment as environmental variables before launching the bundle, so we're able to check for it instead of needing to differentiate the execution name of the binary. Fixes #12116
Diffstat (limited to 'osdep')
-rw-r--r--osdep/macosx_application.m9
1 files changed, 4 insertions, 5 deletions
diff --git a/osdep/macosx_application.m b/osdep/macosx_application.m
index ff8fac6cbb..73503ad66c 100644
--- a/osdep/macosx_application.m
+++ b/osdep/macosx_application.m
@@ -310,10 +310,10 @@ static void init_cocoa_application(bool regular)
});
}
-static bool bundle_started_from_finder(char **argv)
+static bool bundle_started_from_finder()
{
- NSString *binary_path = [NSString stringWithUTF8String:argv[0]];
- return [binary_path hasSuffix:@"mpv-bundle"];
+ NSString* bundle = [[[NSProcessInfo processInfo] environment] objectForKey:@"MPVBUNDLE"];
+ return [bundle isEqual:@"true"];
}
static bool is_psn_argument(char *arg_to_check)
@@ -338,7 +338,6 @@ static void setup_bundle(int *argc, char *argv[])
@"/opt/local/bin",
@"/opt/local/sbin"];
setenv("PATH", [path_new UTF8String], 1);
- setenv("MPVBUNDLE", "true", 1);
}
int cocoa_main(int argc, char *argv[])
@@ -351,7 +350,7 @@ int cocoa_main(int argc, char *argv[])
ctx.argc = &argc;
ctx.argv = &argv;
- if (bundle_started_from_finder(argv)) {
+ if (bundle_started_from_finder()) {
setup_bundle(&argc, argv);
init_cocoa_application(true);
} else {