mirror of https://github.com/aminya/setup-cpp
fix: use http client for downloading the LLVM installer
This commit is contained in:
parent
1a9cdb35d8
commit
a247573c5d
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
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,12 +1,12 @@
|
|||
import { tmpdir } from "os"
|
||||
import { join } from "path"
|
||||
import { HttpClient } from "@actions/http-client"
|
||||
import { addPath } from "envosman"
|
||||
import { execaSync } from "execa"
|
||||
import { writeFile } from "fs/promises"
|
||||
import { dirname } from "patha"
|
||||
import which from "which"
|
||||
import { rcOptions } from "../cli-options.js"
|
||||
import { HttpClient } from "@actions/http-client"
|
||||
import { writeFile } from "fs/promises"
|
||||
|
||||
/* eslint-disable require-atomic-updates */
|
||||
let binDir: string | undefined
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
import { info } from "console"
|
||||
import { tmpdir } from "os"
|
||||
import { join } from "path"
|
||||
import { HttpClient } from "@actions/http-client"
|
||||
import { execRoot } from "admina"
|
||||
import { addPath } from "envosman"
|
||||
import { execa } from "execa"
|
||||
import { chmod, readFile, writeFile } from "fs/promises"
|
||||
import { chmod, writeFile } from "fs/promises"
|
||||
import { aptTimeout, hasNala, installAptPack, isAptPackRegexInstalled } from "setup-apt"
|
||||
import { rcOptions } from "../cli-options.js"
|
||||
import { DEFAULT_TIMEOUT } from "../installTool.js"
|
||||
|
@ -21,14 +23,26 @@ export async function setupLLVMApt(
|
|||
// TODO for older versions, this also includes the minor version
|
||||
const installationFolder = `/usr/lib/llvm-${majorVersion}`
|
||||
|
||||
await installAptPack([{ name: "curl" }])
|
||||
await execa("curl", ["-LJO", "https://apt.llvm.org/llvm.sh"], { cwd: "/tmp" })
|
||||
const neededPackages = await patchAptLLVMScript("/tmp/llvm.sh", "/tmp/llvm-setup-cpp.sh", majorVersion, packages)
|
||||
// download the installation script
|
||||
const http = new HttpClient("setup-llvm")
|
||||
const response = await http.get("https://apt.llvm.org/llvm.sh")
|
||||
if (response.message.statusCode !== 200) {
|
||||
throw new Error(`Failed to download LLVM installation script: ${response.message.statusCode}`)
|
||||
}
|
||||
const installerScript = await response.readBody()
|
||||
|
||||
const installerPath = join(tmpdir(), "llvm-setup-cpp.sh")
|
||||
const neededPackages = await patchAptLLVMScript(
|
||||
installerScript,
|
||||
installerPath,
|
||||
majorVersion,
|
||||
packages,
|
||||
)
|
||||
await installAptPack(neededPackages)
|
||||
await chmod("/tmp/llvm-setup-cpp.sh", "755")
|
||||
await chmod(installerPath, "755")
|
||||
await execRoot(
|
||||
"bash",
|
||||
["/tmp/llvm-setup-cpp.sh", `${majorVersion}`, ...(packages === LLVMPackages.All ? ["all"] : [])],
|
||||
[installerPath, `${majorVersion}`, ...(packages === LLVMPackages.All ? ["all"] : [])],
|
||||
{
|
||||
stdio: "inherit",
|
||||
shell: true,
|
||||
|
@ -45,10 +59,13 @@ export async function setupLLVMApt(
|
|||
}
|
||||
}
|
||||
|
||||
async function patchAptLLVMScript(path: string, target_path: string, majorVersion: number, packages: LLVMPackages) {
|
||||
let script = await readFile(path, "utf-8")
|
||||
|
||||
script = debugScript(script)
|
||||
async function patchAptLLVMScript(
|
||||
givenScript: string,
|
||||
target_path: string,
|
||||
majorVersion: number,
|
||||
packages: LLVMPackages,
|
||||
) {
|
||||
let script = debugScript(givenScript)
|
||||
script = nonInteractiveScript(script)
|
||||
script = choosePackages(packages, script, majorVersion)
|
||||
script = await removeConflictingPackages(script)
|
||||
|
|
Loading…
Reference in New Issue