Skip to content

Commit

Permalink
Merge pull request #7605 from nextcloud/bugfix/mac-crafter-codesign-n…
Browse files Browse the repository at this point in the history
…o-sparkle

mac-crafter: Fix codesigning of app bundle when auto-updater is excluded
  • Loading branch information
claucambra authored Dec 9, 2024
2 parents 1bc4d8c + 154cb1c commit d25e673
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions admin/osx/mac-crafter/Sources/Utils/Codesign.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ enum CodeSigningError: Error {
}

enum AppBundleSigningError: Error {
case doesNotExist(String)
case couldNotEnumerate(String)
}

Expand Down Expand Up @@ -64,6 +65,10 @@ func recursivelyCodesign(
skip: [String] = []
) throws {
let fm = FileManager.default
guard fm.fileExists(atPath: path) else {
throw AppBundleSigningError.doesNotExist("Item at \(path) does not exist.")
}

guard let pathEnumerator = fm.enumerator(atPath: path) else {
throw AppBundleSigningError.couldNotEnumerate(
"Failed to enumerate directory at \(path)."
Expand Down Expand Up @@ -118,14 +123,21 @@ func codesignClientAppBundle(
// Multiple components of the app will now have the get-task-allow entitlements.
// We need to strip these out manually.

print("Code-signing Sparkle autoupdater app (without entitlements)...")
let sparkleFrameworkPath = "\(frameworksPath)/Sparkle.framework"
try recursivelyCodesign(path: "\(sparkleFrameworkPath)/Resources/Autoupdate.app",
identity: codeSignIdentity,
options: "--timestamp --force --verbose=4 --options runtime --deep")
if FileManager.default.fileExists(atPath: "\(sparkleFrameworkPath)/Resources/Autoupdate.app") {
print("Code-signing Sparkle autoupdater app (without entitlements)...")

print("Re-codesigning Sparkle library...")
try codesign(identity: codeSignIdentity, path: "\(sparkleFrameworkPath)/Sparkle")
try recursivelyCodesign(
path: "\(sparkleFrameworkPath)/Resources/Autoupdate.app",
identity: codeSignIdentity,
options: "--timestamp --force --verbose=4 --options runtime --deep"
)

print("Re-codesigning Sparkle library...")
try codesign(identity: codeSignIdentity, path: "\(sparkleFrameworkPath)/Sparkle")
} else {
print("Build does not have Sparkle, skipping.")
}

print("Code-signing app extensions (removing get-task-allow entitlements)...")
let fm = FileManager.default
Expand Down

0 comments on commit d25e673

Please sign in to comment.