Skip to content

Commit

Permalink
Merge pull request #7536 from nextcloud/backport/7535/stable-3.14
Browse files Browse the repository at this point in the history
[stable-3.14] Fix recursive codesign steps and final bundle codesign in mac-crafter
  • Loading branch information
claucambra authored Nov 21, 2024
2 parents 3f5e5e2 + 237f2ce commit 7638655
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions admin/osx/mac-crafter/Sources/Utils/Codesign.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import Foundation

fileprivate let defaultCodesignOptions = "--timestamp --force --preserve-metadata=entitlements --verbose=4 --options runtime --deep"
fileprivate let defaultCodesignOptions = "--timestamp --force --preserve-metadata=entitlements --verbose=4 --options runtime"

enum CodeSigningError: Error {
case failedToCodeSign(String)
Expand All @@ -32,6 +32,10 @@ func isAppExtension(_ path: String) -> Bool {
path.hasSuffix(".appex")
}

func isExecutable(_ path: String) -> Bool {
FileManager.default.isExecutableFile(atPath: path)
}

func codesign(identity: String, path: String, options: String = defaultCodesignOptions) throws {
print("Code-signing \(path)...")
let command = "codesign -s \"\(identity)\" \(options) \"\(path)\""
Expand All @@ -53,7 +57,10 @@ func recursivelyCodesign(
}

for case let enumeratedItem as String in pathEnumerator {
guard isLibrary(enumeratedItem) || isAppExtension(enumeratedItem) else { continue }
guard isLibrary(enumeratedItem) ||
isAppExtension(enumeratedItem) ||
isExecutable(enumeratedItem)
else { continue }
try codesign(identity: identity, path: "\(path)/\(enumeratedItem)")
}
}
Expand Down Expand Up @@ -126,4 +133,7 @@ func codesignClientAppBundle(
// Now we do the final codesign bit
print("Code-signing Nextcloud Desktop Client binaries...")
try recursivelyCodesign(path: "\(clientContentsDir)/MacOS/", identity: codeSignIdentity)

print("Code-signing Nextcloud Desktop Client app bundle...")
try codesign(identity: codeSignIdentity, path: clientAppDir)
}

0 comments on commit 7638655

Please sign in to comment.