Move library check to separate file in mac crafter

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2024-06-20 14:40:34 +08:00 committed by Claudio Cambra
parent 82c46b7539
commit 4e37ec8b4c
2 changed files with 23 additions and 6 deletions

View File

@ -0,0 +1,19 @@
/*
* Copyright (C) 2024 by Claudio Cambra <claudio.cambra@nextcloud.com>
*
* 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
func isLibrary(_ path: String) -> Bool {
path.hasSuffix(".dylib") || path.hasSuffix(".framework")
}

View File

@ -73,9 +73,8 @@ struct MacCrafter: ParsableCommand {
let craftLibDir = "\(currentDir)/\(craftTarget)/lib"
let craftLibs = try fm.contentsOfDirectory(atPath: craftLibDir)
for lib in craftLibs {
let libPath = "\(craftLibDir)/\(lib)"
guard lib.hasSuffix(".dylib") || lib.hasSuffix(".framework") else { continue }
try codesign(identity: codeSignIdentity, path: libPath)
guard isLibrary(lib) else { continue }
try codesign(identity: codeSignIdentity, path: "\(craftLibDir)/\(lib)")
}
let craftPluginsDir = "\(currentDir)/\(craftTarget)/plugins"
@ -84,9 +83,8 @@ struct MacCrafter: ParsableCommand {
}
for case let plugin as String in craftPluginsEnumerator {
let pluginPath = "\(craftPluginsDir)/\(plugin)"
guard plugin.hasSuffix(".dylib") || plugin.hasSuffix(".framework") else { continue }
try codesign(identity: codeSignIdentity, path: pluginPath)
guard isLibrary(plugin) else { continue }
try codesign(identity: codeSignIdentity, path: "\(craftPluginsDir)/\(plugin)")
}
print("Crafting Nextcloud Desktop Client...")