solenv/bin/macosx-codesign-app-bundle |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

New commits:
commit c2ebc77e636e9cdefad6cef446a2f8acec1580f1
Author:     Patrick Luby <guibmac...@gmail.com>
AuthorDate: Thu Feb 15 19:59:55 2024 -0500
Commit:     Patrick Luby <guibomac...@gmail.com>
CommitDate: Fri Feb 16 03:29:08 2024 +0100

    Related: tdf#159529 fix increasing failures when setting entitlements
    
    Starting in one of the Xcode versions 15.2 or earlier, setting the
    entitlements without a certificate started failing on Mac Silicon.
    The hacky solution is to make a copy of the application's executable,
    set the entitlements on that binary only, and then move the copied
    binary back.
    
    Change-Id: I25c32cbe6f9aa87e2d6c2c554a8a9cf48d79e75d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163468
    Tested-by: Jenkins
    Reviewed-by: Patrick Luby <guibomac...@gmail.com>

diff --git a/solenv/bin/macosx-codesign-app-bundle 
b/solenv/bin/macosx-codesign-app-bundle
index 695b3ae97922..3f0003f9a4a2 100755
--- a/solenv/bin/macosx-codesign-app-bundle
+++ b/solenv/bin/macosx-codesign-app-bundle
@@ -59,7 +59,19 @@ if test -z "$MACOSX_CODESIGNING_IDENTITY"; then
     # set entitlements to allow Xcode's Instruments application to connect to
     # the application. Note: the following command fails on some Mac Intel
     # machines, and since this not a release build, ignore any failures.
-    codesign --force --identifier="${MACOSX_BUNDLE_IDENTIFIER}" --sign - 
$entitlements "$APP_BUNDLE"
+    # Related: tdf#159529 fix increasing failures when setting entitlements
+    # Starting in one of the Xcode versions 15.2 or earlier, setting the
+    # entitlements without a certificate started failing on Mac Silicon. 
+    # The hacky solution is to make a copy of the application's executable,
+    # set the entitlements on that binary only, and then move the copied
+    # binary back.
+    rm -f "$APP_BUNDLE/Contents/MacOS/soffice.withentitlements"
+    cp "$APP_BUNDLE/Contents/MacOS/soffice" 
"$APP_BUNDLE/Contents/MacOS/soffice.withentitlements"
+    if codesign --force --identifier="${MACOSX_BUNDLE_IDENTIFIER}" --sign - 
$entitlements "$APP_BUNDLE/Contents/MacOS/soffice.withentitlements"; then
+        mv "$APP_BUNDLE/Contents/MacOS/soffice.withentitlements" 
"$APP_BUNDLE/Contents/MacOS/soffice"
+    else
+        rm "$APP_BUNDLE/Contents/MacOS/soffice.withentitlements"
+    fi
     exit 0
 fi
 

Reply via email to