Also add options to recursive codesign function
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Wed, 20 Nov 2024 08:33:36 +0000 (16:33 +0800)
committerClaudio Cambra <claudio.cambra@nextcloud.com>
Wed, 20 Nov 2024 08:33:36 +0000 (16:33 +0800)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
admin/osx/mac-crafter/Sources/Utils/Codesign.swift

index 62ec0e2d81f69acffd3152fc9bf09b0e72cc99fb..47614874c2b64ee65e72545ef4423e017fcbd99f 100644 (file)
@@ -14,6 +14,8 @@
 
 import Foundation
 
+fileprivate let defaultCodesignOptions = "--timestamp --force --preserve-metadata=entitlements --verbose=4 --options runtime --deep"
+
 enum CodeSigningError: Error {
     case failedToCodeSign(String)
 }
@@ -30,11 +32,7 @@ func isAppExtension(_ path: String) -> Bool {
     path.hasSuffix(".appex")
 }
 
-func codesign(
-    identity: String,
-    path: String,
-    options: String = "--timestamp --force --preserve-metadata=entitlements --verbose=4 --options runtime --deep"
-) throws {
+func codesign(identity: String, path: String, options: String = defaultCodesignOptions) throws {
     print("Code-signing \(path)...")
     let command = "codesign -s \"\(identity)\" \(options) \"\(path)\""
     guard shell(command) == 0 else {
@@ -42,7 +40,11 @@ func codesign(
     }
 }
 
-func recursivelyCodesign(path: String, identity: String) throws {
+func recursivelyCodesign(
+    path: String,
+    identity: String,
+    options: String = defaultCodesignOptions
+) throws {
     let fm = FileManager.default
     guard let pathEnumerator = fm.enumerator(atPath: path) else {
         throw AppBundleSigningError.couldNotEnumerate(