Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit
Swift apple-silicond3dmetaldxmtdxvkgame-porting-toolkitgptkmac-gamingmacosmetalfxrosetta-2steamsteam-playwinewinecx
Clears Finder info/resource forks, solving codesigning issues with Steam
NotProtonNotc352b11754b1
diff --git a/app/Sources/NotProtonApp/Model/SteamInstaller.swift b/app/Sources/NotProtonApp/Model/SteamInstaller.swiftindex b8042f5..88c2fc4 100644--- a/app/Sources/NotProtonApp/Model/SteamInstaller.swift+++ b/app/Sources/NotProtonApp/Model/SteamInstaller.swift@@ -355,7 +355,12 @@ enum SteamInstaller {static func adHocSign(_ url: URL, step: String = step) throws {let path = url.path(percentEncoded: false)- let result = try Shell.run("/usr/bin/codesign", ["-f", "-s", "-", path])+ var result = try Shell.run("/usr/bin/codesign", ["-f", "-s", "-", path])+ // Fixes codesign refusing a Steam.app that carries Finder info or a resource fork.+ if !result.succeeded, result.stderr.contains("detritus not allowed") {+ clearFinderData(in: enclosingBundle(of: url))+ result = try Shell.run("/usr/bin/codesign", ["-f", "-s", "-", path])+ }guard result.succeeded else {throw StepFailure(step: step,@@ -365,6 +370,29 @@ enum SteamInstaller {}}+ static func enclosingBundle(of url: URL) -> URL {+ var candidate = url+ while candidate.pathComponents.count > 1 {+ if candidate.pathExtension == "app" { return candidate }+ candidate = candidate.deletingLastPathComponent()+ }+ return url+ }++ static func clearFinderData(in root: URL) {+ var paths = [root.path(percentEncoded: false)]+ if let walk = FileManager.default.enumerator(atPath: paths[0]) {+ while let relative = walk.nextObject() as? String {+ paths.append(root.appending(path: relative).path(percentEncoded: false))+ }+ }+ for path in paths {+ for name in ["com.apple.FinderInfo", "com.apple.ResourceFork"] {+ removexattr(path, name, XATTR_NOFOLLOW)+ }+ }+ }+static func cdhash(of app: URL) -> String? {guard let result = try? Shell.run("/usr/bin/codesign", ["-dvvv", app.path(percentEncoded: false)]) else { return nil }return (result.stdout + result.stderr).split(separator: "\n")diff --git a/app/Tests/NotProtonAppTests/SteamInstallerTests.swift b/app/Tests/NotProtonAppTests/SteamInstallerTests.swiftindex ba7a0c1..397d5b4 100644--- a/app/Tests/NotProtonAppTests/SteamInstallerTests.swift+++ b/app/Tests/NotProtonAppTests/SteamInstallerTests.swift@@ -207,6 +207,32 @@ struct SteamInstallerTests {#expect(!(described.stdout + described.stderr).contains("TeamIdentifier=MXGJJ98X76"))}+ @Test("A Steam carrying Finder info or a resource fork still installs, and only those are cleared")+ func installsOverFinderData() async throws {+ let work = try scratchDirectory("install")+ defer { try? FileManager.default.removeItem(at: work) }+ let fixture = try await self.fixture(into: work)+ let app = fixture.app.path(percentEncoded: false)+ let icon = fixture.app.appending(path: "Icon\r").path(percentEncoded: false)+ try Data().write(to: URL(filePath: icon))+ try Shell.check("/usr/bin/xattr", ["-w", "com.apple.ResourceFork", "icns", icon])+ try Shell.check("/usr/bin/xattr", ["-wx", "com.apple.FinderInfo", String(repeating: "0", count: 64), icon])+ try Shell.check("/usr/bin/xattr", [+ "-wx", "com.apple.FinderInfo", "0000000000000000040000000000000000000000000000000000000000000000", app,+ ])+ try Shell.check("/usr/bin/xattr", ["-w", "com.notproton.keep", "1", app])+ #expect(!(try Shell.run("/usr/bin/codesign", ["-f", "-s", "-", app])).succeeded)++ _ = try install(fixture)++ let verified = try Shell.run("/usr/bin/codesign", ["--verify", "--strict", app])+ #expect(verified.succeeded, "\(verified.stderr)")+ let left = try Shell.run("/usr/bin/xattr", ["-lr", app]).stdout+ #expect(!left.contains("com.apple.FinderInfo"))+ #expect(!left.contains("com.apple.ResourceFork"))+ #expect(left.contains("com.notproton.keep"))+ }+@Test("An insert belonging to something else stops the install and is left alone")func refusesForeignInsert() async throws {let work = try scratchDirectory("install")