Skip to content

Commit abbeaf1

Browse files
committed
fix: fix installation of libtinfo5 on Ubuntu 24
1 parent f0dd57e commit abbeaf1

File tree

6 files changed

+30
-6
lines changed

6 files changed

+30
-6
lines changed

dist/legacy/setup-cpp.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/legacy/setup-cpp.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/modern/setup-cpp.mjs

+1-1
Large diffs are not rendered by default.

dist/modern/setup-cpp.mjs.map

+1-1
Large diffs are not rendered by default.

src/llvm/__tests__/llvm.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ describe("setup-llvm", () => {
8383
})
8484

8585
it("should setup LLVM from llvm.org", async () => {
86-
const { binDir } = await setupLLVM("5", directory, process.arch)
86+
const { binDir } = await setupLLVM("9.0.0", directory, process.arch)
8787
await testBin("clang++", ["--version"], binDir)
8888

8989
expect(process.env.CC?.includes("clang")).toBeTruthy()

src/llvm/llvm.ts

+25-1
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1+
import { tmpdir } from "os"
12
import path, { delimiter, join } from "path"
23
import { fileURLToPath } from "url"
4+
import { execRoot } from "admina"
35
import { GITHUB_ACTIONS } from "ci-info"
46
import { info, warning } from "ci-log"
57
import { addEnv } from "envosman"
68
import memoize from "memoizee"
9+
import { DownloaderHelper } from "node-downloader-helper"
710
import { pathExists } from "path-exists"
811
import { addExeExt } from "patha"
912
import { addUpdateAlternativesToRc, installAptPack } from "setup-apt"
1013
import { rcOptions } from "../cli-options.js"
1114
import { setupGcc } from "../gcc/gcc.js"
1215
import { setupMacOSSDK } from "../macos-sdk/macos-sdk.js"
16+
import { arm64, x86_64 } from "../utils/env/arch.js"
1317
import { hasDnf } from "../utils/env/hasDnf.js"
1418
import { isArch } from "../utils/env/isArch.js"
1519
import { isUbuntu } from "../utils/env/isUbuntu.js"
@@ -87,7 +91,27 @@ function majorLLVMVersion(version: string) {
8791
async function llvmBinaryDeps_(majorVersion: number) {
8892
if (isUbuntu()) {
8993
if (majorVersion <= 10) {
90-
await installAptPack([{ name: "libtinfo5" }])
94+
try {
95+
await installAptPack([{ name: "libtinfo5" }])
96+
} catch (err) {
97+
// Manually install libtinfo5 if the package is not available
98+
info(`Failed to install libtinfo5 ${err}\nManually installing the package`)
99+
const arch = x86_64.includes(process.arch)
100+
? "amd64"
101+
: arm64.includes(process.arch)
102+
? "arm64"
103+
: process.arch
104+
105+
const fileName = `libtinfo5_6.3-2ubuntu0.1_${arch}.deb`
106+
const url = `http://launchpadlibrarian.net/666971015/${fileName}`
107+
const dl = new DownloaderHelper(url, tmpdir(), { fileName })
108+
dl.on("error", (dlErr) => {
109+
throw new Error(`Failed to download ${url}: ${dlErr}`)
110+
})
111+
await dl.start()
112+
// Install the downloaded package via dpkg
113+
await execRoot("dpkg", ["-i", join(tmpdir(), fileName)])
114+
}
91115
} else {
92116
await installAptPack([{ name: "libtinfo-dev" }])
93117
}

0 commit comments

Comments
 (0)