Skip to content

Commit d25e673

Browse files
authored
Merge pull request #7605 from nextcloud/bugfix/mac-crafter-codesign-no-sparkle
mac-crafter: Fix codesigning of app bundle when auto-updater is excluded
2 parents 1bc4d8c + 154cb1c commit d25e673

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

admin/osx/mac-crafter/Sources/Utils/Codesign.swift

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ enum CodeSigningError: Error {
2121
}
2222

2323
enum AppBundleSigningError: Error {
24+
case doesNotExist(String)
2425
case couldNotEnumerate(String)
2526
}
2627

@@ -64,6 +65,10 @@ func recursivelyCodesign(
6465
skip: [String] = []
6566
) throws {
6667
let fm = FileManager.default
68+
guard fm.fileExists(atPath: path) else {
69+
throw AppBundleSigningError.doesNotExist("Item at \(path) does not exist.")
70+
}
71+
6772
guard let pathEnumerator = fm.enumerator(atPath: path) else {
6873
throw AppBundleSigningError.couldNotEnumerate(
6974
"Failed to enumerate directory at \(path)."
@@ -118,14 +123,21 @@ func codesignClientAppBundle(
118123
// Multiple components of the app will now have the get-task-allow entitlements.
119124
// We need to strip these out manually.
120125

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

127-
print("Re-codesigning Sparkle library...")
128-
try codesign(identity: codeSignIdentity, path: "\(sparkleFrameworkPath)/Sparkle")
130+
try recursivelyCodesign(
131+
path: "\(sparkleFrameworkPath)/Resources/Autoupdate.app",
132+
identity: codeSignIdentity,
133+
options: "--timestamp --force --verbose=4 --options runtime --deep"
134+
)
135+
136+
print("Re-codesigning Sparkle library...")
137+
try codesign(identity: codeSignIdentity, path: "\(sparkleFrameworkPath)/Sparkle")
138+
} else {
139+
print("Build does not have Sparkle, skipping.")
140+
}
129141

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

0 commit comments

Comments
 (0)