From: Claudio Cambra Date: Thu, 19 Sep 2024 12:59:46 +0000 (+0800) Subject: Add buildPackage function to mac crafter X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~58^2^2~180^2~13 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=9d8b27e829f8fb79d7e62585f0bf75fd83fcbe44;p=nextcloud-desktop.git Add buildPackage function to 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 new file mode 100644 index 000000000..49ba535f4 --- /dev/null +++ b/admin/osx/mac-crafter/Sources/Utils/Packaging.swift @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2024 by Claudio Cambra + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +import Foundation + +enum PackagingError: Error { + case projectNameSettingError(String) + case packageBuildError(String) +} + +func buildPackage(buildWorkPath: String, productPath: String) throws -> String { + let projectName = "Nextcloud" // TODO: Get specific name + let packageFile = "\(projectName).pkg" + let sparkleFile = "\(packageFile).tbz" + let pkgprojPath = "\(buildWorkPath)/admin/osx/macosx.pkgproj" + + guard shell("packagesutil --file \(pkgprojPath) set project name \(projectName)") == 0 else { + throw PackagingError.projectNameSettingError("Could not set project name in pkgproj!") + } + guard shell("packagesbuild -v --build-folder \(productPath) -F \(productPath) \(pkgprojPath)") == 0 else { + throw PackagingError.packageBuildError("Error building pkg file!") + } + return "\(productPath)/\(packageFile)" +} +