fix: strip components for windows LLVM tar.xz

This commit is contained in:
Amin Yahyaabadi 2025-07-03 05:26:22 -07:00
parent 8ffe76cee3
commit 8e6c0edd38
6 changed files with 35 additions and 32 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -7,7 +7,7 @@ import { loadAssetList, matchAsset } from "../utils/asset/load-assets.js"
import { arm64, armv7, powerpc64le, sparc64, sparcv9, x86, x86_64 } from "../utils/env/arch.js"
import { hasDnf } from "../utils/env/hasDnf.js"
import { ubuntuVersion } from "../utils/env/ubuntu_version.js"
import { extractTarByExe, getArchiveType, getExtractFunction } from "../utils/setup/extract.js"
import { ArchiveType, extractTarByExe, getArchiveType, getExtractFunction } from "../utils/setup/extract.js"
import type { PackageInfo } from "../utils/setup/setupBin.js"
const dirname = typeof __dirname === "string" ? __dirname : path.dirname(fileURLToPath(import.meta.url))
@ -20,16 +20,19 @@ export async function getLLVMPackageInfo(
const url = await getLLVMAssetURL(platform, arch, version)
info(`Downloading LLVM from ${url}`)
const archiveType = getArchiveType(url)
return {
url,
extractedFolderName: "",
binRelativeDir: "bin",
binFileName: addExeExt("clang"),
extractFunction: platform === "win32"
? getExtractFunction(getArchiveType(url))
: (file: string, dest: string) => {
extractFunction: process.platform === "win32"
&& (archiveType === ArchiveType.Tar || archiveType === ArchiveType.TarGz || archiveType === ArchiveType.TarXz)
? (file: string, dest: string) => {
// strip components to get the top folder on Windows
return extractTarByExe(file, dest, 1)
},
}
: getExtractFunction(archiveType),
}
}

View File

@ -54,7 +54,6 @@ export function getExtractFunction(archiveType: ArchiveType) {
switch (archiveType) {
case ArchiveType.Tar:
case ArchiveType.TarGz:
return extractTarByExe
case ArchiveType.TarXz:
return extractTarByExe
case ArchiveType.Zip:
@ -160,36 +159,37 @@ export async function extractTarByExe(file: string, dest: string, stripComponent
}
async function installTarDependencies(archiveType: ArchiveType) {
if (process.platform !== "linux") {
return
}
info("Installing tar extraction dependencies")
switch (archiveType) {
case ArchiveType.TarGz: {
if (process.platform === "linux") {
if (isArch()) {
await setupPacmanPack("gzip")
await setupPacmanPack("tar")
} else if (hasDnf()) {
await setupDnfPack([{ name: "gzip" }, { name: "tar" }])
} else if (hasAptGet()) {
await installAptPack([{ name: "gzip" }, { name: "tar" }])
} else if (await hasApk()) {
await installApkPack([{ name: "gzip" }, { name: "tar" }])
}
if (isArch()) {
await setupPacmanPack("gzip")
await setupPacmanPack("tar")
} else if (hasDnf()) {
await setupDnfPack([{ name: "gzip" }, { name: "tar" }])
} else if (hasAptGet()) {
await installAptPack([{ name: "gzip" }, { name: "tar" }])
} else if (await hasApk()) {
await installApkPack([{ name: "gzip" }, { name: "tar" }])
}
return
}
case ArchiveType.TarXz: {
if (process.platform === "linux") {
if (isArch()) {
await setupPacmanPack("xz")
await setupPacmanPack("tar")
} else if (hasDnf()) {
await setupDnfPack([{ name: "xz" }, { name: "tar" }])
} else if (hasAptGet()) {
await installAptPack([{ name: "xz-utils" }, { name: "tar" }])
} else if (await hasApk()) {
await installApkPack([{ name: "xz" }, { name: "tar" }])
}
if (isArch()) {
await setupPacmanPack("xz")
await setupPacmanPack("tar")
} else if (hasDnf()) {
await setupDnfPack([{ name: "xz" }, { name: "tar" }])
} else if (hasAptGet()) {
await installAptPack([{ name: "xz-utils" }, { name: "tar" }])
} else if (await hasApk()) {
await installApkPack([{ name: "xz" }, { name: "tar" }])
}
return
}