From: Claudio Cambra Date: Thu, 19 Sep 2024 13:00:52 +0000 (+0800) Subject: Add ability to sign pkg from mac-crafter X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~6^2~11^2~11 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=1b747fa134f1d793124203ea014a838ddc0017c2;p=nextcloud-desktop.git Add ability to sign pkg from mac-crafter Signed-off-by: Claudio Cambra --- diff --git a/admin/osx/mac-crafter/Sources/Utils/Packaging.swift b/admin/osx/mac-crafter/Sources/Utils/Packaging.swift index 49ba535f4..1da19d539 100644 --- a/admin/osx/mac-crafter/Sources/Utils/Packaging.swift +++ b/admin/osx/mac-crafter/Sources/Utils/Packaging.swift @@ -17,6 +17,7 @@ import Foundation enum PackagingError: Error { case projectNameSettingError(String) case packageBuildError(String) + case packageSigningError(String) } func buildPackage(buildWorkPath: String, productPath: String) throws -> String { @@ -34,3 +35,13 @@ func buildPackage(buildWorkPath: String, productPath: String) throws -> String { return "\(productPath)/\(packageFile)" } +func signPackage(packagePath: String, packageSigningId: String) throws { + let packagePathNew = "\(packagePath).new" + guard shell("productsign --timestamp --sign '\(packageSigningId)' \(packagePath) \(packagePathNew)") == 0 else { + throw PackagingError.packageSigningError("Could not sign pkg file!") + } + let fm = FileManager.default + try fm.removeItem(atPath: packagePath) + try fm.moveItem(atPath: packagePathNew, toPath: packagePath) +} + diff --git a/admin/osx/mac-crafter/Sources/main.swift b/admin/osx/mac-crafter/Sources/main.swift index 1efe1e992..4ba8d75dc 100644 --- a/admin/osx/mac-crafter/Sources/main.swift +++ b/admin/osx/mac-crafter/Sources/main.swift @@ -65,6 +65,9 @@ struct Build: ParsableCommand { @Option(name: [.long], help: "Git clone command; include options such as depth.") var gitCloneCommand = "git clone --depth=1" + @Option(name: [.long], help: "Apple package signing ID.") + var packageSigningId: String? + @Flag(help: "Reconfigure KDE Craft.") var reconfigureCraft = false @@ -216,6 +219,10 @@ struct Build: ParsableCommand { if package { let packagePath = try buildPackage(buildWorkPath: buildWorkPath, productPath: productPath) + + if let packageSigningId { + try signPackage(packagePath: packagePath, packageSigningId: packageSigningId) + } } print("Done!")