mpv: sign darwin bundle executable

This fixes the application exiting immediately after launch via application bundle on macOS 14 (#261072).
This commit is contained in:
David Stritzl 2023-11-04 21:19:07 +01:00 committed by Anderson Torres
parent 94633f04a3
commit acd80bbf00
3 changed files with 9 additions and 2 deletions

View File

@ -19,6 +19,7 @@
, libuchardet
, libiconv
, xcbuild
, sigtool
, waylandSupport ? stdenv.isLinux
, wayland
@ -154,7 +155,7 @@ in stdenv'.mkDerivation (finalAttrs: {
pkg-config
python3
]
++ lib.optionals stdenv.isDarwin [ xcbuild.xcrun ]
++ lib.optionals stdenv.isDarwin [ xcbuild.xcrun sigtool ]
++ lib.optionals swiftSupport [ swift ]
++ lib.optionals waylandSupport [ wayland-scanner ];
@ -203,6 +204,11 @@ in stdenv'.mkDerivation (finalAttrs: {
postBuild = lib.optionalString stdenv.isDarwin ''
pushd .. # Must be run from the source dir because it uses relative paths
python3 TOOLS/osxbundle.py -s build/mpv
# Swap binary and bundle symlink to sign bundle executable as symlinks cannot be signed
rm build/mpv.app/Contents/MacOS/mpv-bundle
mv build/mpv.app/Contents/MacOS/mpv build/mpv.app/Contents/MacOS/mpv-bundle
ln -s mpv-bundle build/mpv.app/Contents/MacOS/mpv
codesign --force --sign - build/mpv.app/Contents/MacOS/mpv-bundle
popd
'';

View File

@ -97,7 +97,7 @@ let
'' + lib.optionalString stdenv.isDarwin ''
# wrapProgram can't operate on symlinks
rm "$out/Applications/mpv.app/Contents/MacOS/mpv"
makeWrapper "${mpv}/Applications/mpv.app/Contents/MacOS/mpv" "$out/Applications/mpv.app/Contents/MacOS/mpv" ${mostMakeWrapperArgs}
makeWrapper "${mpv}/Applications/mpv.app/Contents/MacOS/mpv-bundle" "$out/Applications/mpv.app/Contents/MacOS/mpv" ${mostMakeWrapperArgs}
'';
meta = {

View File

@ -33939,6 +33939,7 @@ with pkgs;
mpv-unwrapped = darwin.apple_sdk_11_0.callPackage ../applications/video/mpv {
stdenv = if stdenv.isDarwin then swiftPackages.stdenv else stdenv;
inherit lua;
inherit (darwin) sigtool;
};
shaka-packager = callPackage ../applications/video/shaka-packager { };