|
| 1 | +import { tmpdir } from "os" |
1 | 2 | import path, { delimiter, join } from "path"
|
2 | 3 | import { fileURLToPath } from "url"
|
| 4 | +import { execRootSync } from "admina" |
3 | 5 | import { GITHUB_ACTIONS } from "ci-info"
|
4 | 6 | import { info, warning } from "ci-log"
|
5 | 7 | import { addEnv } from "envosman"
|
6 | 8 | import memoize from "memoizee"
|
| 9 | +import { DownloaderHelper } from "node-downloader-helper" |
7 | 10 | import { pathExists } from "path-exists"
|
8 | 11 | import { addExeExt } from "patha"
|
9 | 12 | import { addUpdateAlternativesToRc, installAptPack } from "setup-apt"
|
10 | 13 | import { rcOptions } from "../cli-options.js"
|
11 | 14 | import { setupGcc } from "../gcc/gcc.js"
|
12 | 15 | import { setupMacOSSDK } from "../macos-sdk/macos-sdk.js"
|
| 16 | +import { arm64, x86_64 } from "../utils/env/arch.js" |
13 | 17 | import { hasDnf } from "../utils/env/hasDnf.js"
|
14 | 18 | import { isArch } from "../utils/env/isArch.js"
|
15 | 19 | import { isUbuntu } from "../utils/env/isUbuntu.js"
|
@@ -87,7 +91,27 @@ function majorLLVMVersion(version: string) {
|
87 | 91 | async function llvmBinaryDeps_(majorVersion: number) {
|
88 | 92 | if (isUbuntu()) {
|
89 | 93 | 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 | + } |
91 | 115 | } else {
|
92 | 116 | await installAptPack([{ name: "libtinfo-dev" }])
|
93 | 117 | }
|
|
0 commit comments