From 8580dcc03af0c3b01938f7f4d63fa3ee1dc57e5a Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 12 Sep 2024 03:48:28 +0800 Subject: [PATCH] Move building into separate subcommand, add subcommand just for codesigning Signed-off-by: Claudio Cambra --- admin/osx/mac-crafter/Sources/main.swift | 41 +++++++++++++++++------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/admin/osx/mac-crafter/Sources/main.swift b/admin/osx/mac-crafter/Sources/main.swift index 25e1d824c5067..0492d9fc527b8 100644 --- a/admin/osx/mac-crafter/Sources/main.swift +++ b/admin/osx/mac-crafter/Sources/main.swift @@ -15,10 +15,8 @@ import ArgumentParser import Foundation -struct MacCrafter: ParsableCommand { - static let configuration = CommandConfiguration( - abstract: "A tool to easily build a fully-functional Nextcloud Desktop Client for macOS." - ) +struct Build: ParsableCommand { + static let configuration = CommandConfiguration(abstract: "Client building script") enum MacCrafterError: Error { case failedEnumeration(String) @@ -194,14 +192,11 @@ struct MacCrafter: ParsableCommand { throw MacCrafterError.craftError("Error crafting Nextcloud Desktop Client.") } - guard let codeSignIdentity else { - print("Crafted Nextcloud Desktop Client. Not codesigned.") - return - } - - print("Code-signing Nextcloud Desktop Client libraries and frameworks...") let clientAppDir = "\(clientBuildDir)/image-\(buildType)-master/\(appName).app" - try codesignClientAppBundle(at: clientAppDir, withCodeSignIdentity: codeSignIdentity) + if let codeSignIdentity { + print("Code-signing Nextcloud Desktop Client libraries and frameworks...") + try codesignClientAppBundle(at: clientAppDir, withCodeSignIdentity: codeSignIdentity) + } print("Placing Nextcloud Desktop Client in \(productPath)...") if !fm.fileExists(atPath: productPath) { @@ -218,4 +213,28 @@ struct MacCrafter: ParsableCommand { } } +struct Codesign: ParsableCommand { + static let configuration = CommandConfiguration(abstract: "Codesigning script for the client.") + + @Argument(help: "Path to the Nextcloud Desktop Client app bundle.") + var appBundlePath = "\(FileManager.default.currentDirectoryPath)/product/Nextcloud.app" + + @Option(name: [.short, .long], help: "Code signing identity for desktop client and libs.") + var codeSignIdentity: String + + mutating func run() throws { + try codesignClientAppBundle(at: appBundlePath, withCodeSignIdentity: codeSignIdentity) + } +} + +struct MacCrafter: ParsableCommand { + static let configuration = CommandConfiguration( + abstract: "A tool to easily build a fully-functional Nextcloud Desktop Client for macOS.", + subcommands: [Build.self, Codesign.self], + defaultSubcommand: Build.self + ) + + +} + MacCrafter.main()