diff --git a/admin/osx/mac-crafter/Sources/Utils/Library.swift b/admin/osx/mac-crafter/Sources/Utils/Library.swift new file mode 100644 index 0000000000..1304f03281 --- /dev/null +++ b/admin/osx/mac-crafter/Sources/Utils/Library.swift @@ -0,0 +1,19 @@ +/* + * 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 + +func isLibrary(_ path: String) -> Bool { + path.hasSuffix(".dylib") || path.hasSuffix(".framework") +} diff --git a/admin/osx/mac-crafter/Sources/main.swift b/admin/osx/mac-crafter/Sources/main.swift index aed68631f5..a1eb85165a 100644 --- a/admin/osx/mac-crafter/Sources/main.swift +++ b/admin/osx/mac-crafter/Sources/main.swift @@ -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...")