Merge pull request #7545 from nextcloud/bugfix/final-final-mc-fix-pls

Fix mac-crafter codesign executable check path building
This commit is contained in:
Claudio Cambra 2024-11-22 00:58:12 +08:00 коммит произвёл GitHub
Родитель 3378126833 07d6456d5b
Коммит 4e0e2f4a24
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
2 изменённых файлов: 17 добавлений и 4 удалений

Просмотреть файл

@ -70,11 +70,12 @@ func recursivelyCodesign(
}
for case let enumeratedItem as String in pathEnumerator {
let isExecutableFile = try isExecutable(fm.currentDirectoryPath + "/" + path + "/" + enumeratedItem)
let enumeratedItemPath = "\(path)/\(enumeratedItem)"
let isExecutableFile = try isExecutable(enumeratedItemPath)
guard isLibrary(enumeratedItem) || isAppExtension(enumeratedItem) || isExecutableFile else {
continue
}
try codesign(identity: identity, path: "\(path)/\(enumeratedItem)", options: options)
try codesign(identity: identity, path: enumeratedItemPath, options: options)
}
}
@ -144,6 +145,15 @@ func codesignClientAppBundle(
}
// Now we do the final codesign bit
let binariesDir = "\(clientContentsDir)/MacOS"
print("Code-signing Nextcloud Desktop Client binaries...")
try recursivelyCodesign(path: "\(clientContentsDir)/MacOS/", identity: codeSignIdentity)
try recursivelyCodesign(path: binariesDir, identity: codeSignIdentity)
guard let appName = clientAppDir.components(separatedBy: "/").last, clientAppDir.hasSuffix(".app") else {
throw AppBundleSigningError.couldNotEnumerate("Failed to determine main executable name.")
}
// Sign the main executable last
let mainExecutableName = String(appName.dropLast(".app".count))
try codesign(identity: codeSignIdentity, path: "\(binariesDir)/\(mainExecutableName)")
}

Просмотреть файл

@ -275,7 +275,10 @@ struct Codesign: ParsableCommand {
var codeSignIdentity: String
mutating func run() throws {
try codesignClientAppBundle(at: appBundlePath, withCodeSignIdentity: codeSignIdentity)
let absolutePath = appBundlePath.hasPrefix("/")
? appBundlePath
: "\(FileManager.default.currentDirectoryPath)/\(appBundlePath)"
try codesignClientAppBundle(at: absolutePath, withCodeSignIdentity: codeSignIdentity)
}
}