Skip to content

Commit

Permalink
fix: extract tar.xz files correctly with 7zip
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Jan 30, 2025
1 parent 78cce09 commit 91536c7
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dist/legacy/setup-cpp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/legacy/setup-cpp.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/modern/setup-cpp.mjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/modern/setup-cpp.mjs.map

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions src/utils/setup/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { mkdirP } from "@actions/io"
import { grantUserWriteAccess } from "admina"
import { info, warning } from "ci-log"
import { execa } from "execa"
import { rm } from "fs/promises"
import { installAptPack } from "setup-apt"
import which from "which"
import { setupSevenZip } from "../../sevenzip/sevenzip.js"
Expand Down Expand Up @@ -68,6 +69,16 @@ let sevenZip: string | undefined
export async function extract7Zip(file: string, dest: string) {
await execa(await getSevenZip(), ["x", file, `-o${dest}`, "-y"], { stdio: "inherit" })
await grantUserWriteAccess(dest)

// if the file is tar.gz or tar.xz, extract the resulting tar again
const fileParts = file.split(".")
if (fileParts.length >= 2 && fileParts[fileParts.length - 2] === "tar") {
const tarFile = `${dest}/${fileParts.slice(0, -2).join(".")}.tar`
await extract7Zip(tarFile, dest)
// remove the tar file
await rm(tarFile)
}

return dest
}

Expand Down

0 comments on commit 91536c7

Please sign in to comment.