Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable-3.14] Fix recursive codesign steps and final bundle codesign in mac-crafter #7536

Merged
merged 3 commits into from
Nov 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
Loading