diff --git a/Sources/RepoToolsCore/RepoActions.swift b/Sources/RepoToolsCore/RepoActions.swift index e5ff2b77..da3b3263 100644 --- a/Sources/RepoToolsCore/RepoActions.swift +++ b/Sources/RepoToolsCore/RepoActions.swift @@ -660,7 +660,7 @@ public enum RepoActions { static func unzipTransaction(rootDir: String, fileName: String) -> String { return "mkdir -p " + rootDir + " && " + "cd " + rootDir + " && " + - "unzip -d OUT " + fileName + " > /dev/null && " + + "ditto -x -k --sequesterRsrc --rsrc " + fileName + " OUT > /dev/null && " + "rm -rf " + fileName } diff --git a/Tests/PodToBUILDTests/PodStoreTests.swift b/Tests/PodToBUILDTests/PodStoreTests.swift index 8fc981f0..7dada08a 100644 --- a/Tests/PodToBUILDTests/PodStoreTests.swift +++ b/Tests/PodToBUILDTests/PodStoreTests.swift @@ -76,6 +76,30 @@ class PodStoreTests: XCTestCase { XCTAssertTrue(shell.executed(encodedCommand: extract.0)) } + func testZipExtractionWithSpecialCharacteres() { + let hasDir = MakeShellInvocation("/bin/[", arguments: ["-e", + cacheRoot(forPod: "Charts", url: "https://github.com/danielgindi/Charts/archive/refs/tags/v4.0.1.zip"), + "]"], exitCode: 1) + + + let extract = MakeShellInvocation("/bin/sh", + arguments: ["-c", RepoActions.unzipTransaction( + rootDir: escape(extractDir), + fileName: escape(downloadPath) + )], + exitCode: 0) + let shell = LogicalShellContext(commandInvocations: [ + hasDir, + extract + ]) + + RepoActions.fetch(shell: shell, fetchOptions: fetchOpts) + XCTAssertTrue(shell.executed(encodedCommand: + LogicalShellContext.encodeDownload(url: URL(string: fetchOpts.url)!, toFile: downloadPath) + )) + XCTAssertTrue(shell.executed(encodedCommand: extract.0)) + } + func testCachedDownload() { let hasDir = MakeShellInvocation("/bin/[", arguments: ["-e", cacheRoot(forPod: testPodName, url: "http://pinner.com/foo.zip"), "]"], value: 0) let shell = LogicalShellContext(commandInvocations: [