Skip main executable during first binary codesign round
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Thu, 21 Nov 2024 18:30:04 +0000 (02:30 +0800)
committerClaudio Cambra <claudio.cambra@nextcloud.com>
Thu, 21 Nov 2024 18:30:04 +0000 (02:30 +0800)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
admin/osx/mac-crafter/Sources/Utils/Codesign.swift

index 1e31b244c58afa0ef0e213501c089c807034725c..be7eb586d6da910aa1ebafd124eca64caa982449 100644 (file)
@@ -152,7 +152,6 @@ func codesignClientAppBundle(
     // Now we do the final codesign bit
     let binariesDir = "\(clientContentsDir)/MacOS"
     print("Code-signing Nextcloud Desktop Client binaries...")
-    try recursivelyCodesign(path: binariesDir, identity: codeSignIdentity)
 
     guard let appName = clientAppDir.components(separatedBy: "/").last, clientAppDir.hasSuffix(".app") else {
         throw AppBundleSigningError.couldNotEnumerate("Failed to determine main executable name.")
@@ -160,5 +159,7 @@ func codesignClientAppBundle(
 
     // Sign the main executable last
     let mainExecutableName = String(appName.dropLast(".app".count))
-    try codesign(identity: codeSignIdentity, path: "\(binariesDir)/\(mainExecutableName)")
+    let mainExecutablePath = "\(binariesDir)/\(mainExecutableName)"
+    try recursivelyCodesign(path: binariesDir, identity: codeSignIdentity, skip: [mainExecutablePath])
+    try codesign(identity: codeSignIdentity, path: mainExecutablePath)
 }