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

Exit with an error if generate_appcast cannot sign an update #2322

Merged
merged 1 commit into from
Feb 25, 2023
Merged
Show file tree
Hide file tree
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
16 changes: 15 additions & 1 deletion generate_appcast/Appcast.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func makeAppcasts(archivesSourceDir: URL, outputPathURL: URL?, cacheDirectory ca
}

let group = DispatchGroup()
var updateArchivesToSign: [ArchiveItem] = []

var appcastByFeed: [FeedName: Appcast] = [:]
for (feed, updates) in updatesByAppcast {
Expand Down Expand Up @@ -174,6 +175,8 @@ func makeAppcasts(archivesSourceDir: URL, outputPathURL: URL?, cacheDirectory ca
continue
}

updateArchivesToSign.append(update)

group.enter()
DispatchQueue.global().async {
#if SPARKLE_BUILD_LEGACY_DSA_SUPPORT
Expand All @@ -193,13 +196,17 @@ func makeAppcasts(archivesSourceDir: URL, outputPathURL: URL?, cacheDirectory ca
do {
update.edSignature = try edSignature(path: update.archivePath, publicEdKey: publicEdKey, privateEdKey: privateEdKey)
} catch {
update.signingError = error
print(update, error)
}
} else {
print("Warning: SUPublicEDKey in the app \(update.archivePath.path) does not match key EdDSA in the Keychain. Run generate_keys and update Info.plist to match")
}
} else {
print("Warning: could not sign \(update.archivePath.path) due to lack of private EdDSA key")
let error = makeError(code: .insufficientSigningError, "Could not sign \(update.archivePath.path) due to lack of private EdDSA key")

update.signingError = error
print("Error: could not sign \(update.archivePath.path) due to lack of private EdDSA key")
}
}

Expand Down Expand Up @@ -375,6 +382,13 @@ func makeAppcasts(archivesSourceDir: URL, outputPathURL: URL?, cacheDirectory ca
}

group.wait()

// Check for fatal signing errors
for update in updateArchivesToSign {
if let signingError = update.signingError {
throw signingError
}
}

return appcastByFeed
}
Expand Down
1 change: 1 addition & 0 deletions generate_appcast/ArchiveItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class ArchiveItem: CustomStringConvertible {
var edSignature: String?
var downloadUrlPrefix: URL?
var releaseNotesURLPrefix: URL?
var signingError: Error?

init(version: String, shortVersion: String?, feedURL: URL?, minimumSystemVersion: String?, frameworkVersion: String?, sparkleExecutableFileSize: Int?, sparkleLocales: String?, publicEdKey: String?, supportsDSA: Bool, appPath: URL, archivePath: URL) throws {
self.version = version
Expand Down