Skip to content

Commit 2a2a8eb

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

File tree

6 files changed

+31
-7
lines changed

6 files changed

+31
-7
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

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ describe("setup-llvm", () => {
8282
execaSync(main_exe, { cwd: dirname, stdio: "inherit" })
8383
})
8484

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

@@ -92,7 +92,7 @@ describe("setup-llvm", () => {
9292
// test compilation
9393
const file = join(dirname, "main.cpp")
9494
const main_exe = join(dirname, addExeExt("main"))
95-
execaSync("clang++", [file, "-o", main_exe], { cwd: dirname })
95+
execaSync("clang++", ["-std=c++17", file, "-o", main_exe], { cwd: dirname })
9696
if (process.platform !== "win32") {
9797
await chmod(main_exe, "755")
9898
}

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 { execRootSync } 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+
execRootSync("dpkg", ["-i", join(tmpdir(), fileName)])
114+
}
91115
} else {
92116
await installAptPack([{ name: "libtinfo-dev" }])
93117
}

0 commit comments

Comments
 (0)