Skip to content

Commit

Permalink
fix: fix installation of libtinfo5 on Ubuntu 24
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Sep 19, 2024
1 parent f0dd57e commit b7cb71e
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 7 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.

4 changes: 2 additions & 2 deletions src/llvm/__tests__/llvm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe("setup-llvm", () => {
// test compilation
const file = join(dirname, "main.cpp")
const main_exe = join(dirname, addExeExt("main"))
execaSync("clang++", [file, "-o", main_exe], { cwd: dirname })
execaSync("clang++", ["-std=c++11", file, "-o", main_exe], { cwd: dirname })
if (process.platform !== "win32") {
await chmod(main_exe, "755")
}
Expand All @@ -92,7 +92,7 @@ describe("setup-llvm", () => {
// test compilation
const file = join(dirname, "main.cpp")
const main_exe = join(dirname, addExeExt("main"))
execaSync("clang++", [file, "-o", main_exe], { cwd: dirname })
execaSync("clang++", ["-std=c++11", file, "-o", main_exe], { cwd: dirname })
if (process.platform !== "win32") {
await chmod(main_exe, "755")
}
Expand Down
26 changes: 25 additions & 1 deletion src/llvm/llvm.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { tmpdir } from "os"
import path, { delimiter, join } from "path"
import { fileURLToPath } from "url"
import { execRoot } from "admina"
import { GITHUB_ACTIONS } from "ci-info"
import { info, warning } from "ci-log"
import { addEnv } from "envosman"
import memoize from "memoizee"
import { DownloaderHelper } from "node-downloader-helper"
import { pathExists } from "path-exists"
import { addExeExt } from "patha"
import { addUpdateAlternativesToRc, installAptPack } from "setup-apt"
import { rcOptions } from "../cli-options.js"
import { setupGcc } from "../gcc/gcc.js"
import { setupMacOSSDK } from "../macos-sdk/macos-sdk.js"
import { arm64, x86_64 } from "../utils/env/arch.js"
import { hasDnf } from "../utils/env/hasDnf.js"
import { isArch } from "../utils/env/isArch.js"
import { isUbuntu } from "../utils/env/isUbuntu.js"
Expand Down Expand Up @@ -87,7 +91,27 @@ function majorLLVMVersion(version: string) {
async function llvmBinaryDeps_(majorVersion: number) {
if (isUbuntu()) {
if (majorVersion <= 10) {
await installAptPack([{ name: "libtinfo5" }])
try {
await installAptPack([{ name: "libtinfo5" }])
} catch (err) {
// Manually install libtinfo5 if the package is not available
info(`Failed to install libtinfo5 ${err}\nManually installing the package`)
const arch = x86_64.includes(process.arch)
? "amd64"
: arm64.includes(process.arch)
? "arm64"
: process.arch

const fileName = `libtinfo5_6.3-2ubuntu0.1_${arch}.deb`
const url = `http://launchpadlibrarian.net/666971015/${fileName}`
const dl = new DownloaderHelper(url, tmpdir(), { fileName })
dl.on("error", (dlErr) => {
throw new Error(`Failed to download ${url}: ${dlErr}`)
})
await dl.start()
// Install the downloaded package via dpkg
await execRoot("dpkg", ["-i", join(tmpdir(), fileName)])
}
} else {
await installAptPack([{ name: "libtinfo-dev" }])
}
Expand Down

0 comments on commit b7cb71e

Please sign in to comment.