mirror of https://github.com/aminya/setup-cpp
fix: fix nala installation on Ubuntu 20.04
This commit is contained in:
parent
4e7c4bb64b
commit
b6193582b7
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
|
@ -4,4 +4,4 @@ pre-commit:
|
||||||
test.lint:
|
test.lint:
|
||||||
run: pnpm run test.lint
|
run: pnpm run test.lint
|
||||||
build:
|
build:
|
||||||
run: pnpm run clean && pnpm i && pnpm run build -- --no-color && git add ./dist
|
run: pnpm run clean && pnpm run build -- --no-color && git add ./dist
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { tmpdir } from "os"
|
import { tmpdir } from "os"
|
||||||
import { execRootSync } from "admina"
|
import { execRootSync } from "admina"
|
||||||
|
import { error, info } from "ci-log"
|
||||||
import { readFile, writeFile } from "fs/promises"
|
import { readFile, writeFile } from "fs/promises"
|
||||||
import { DownloaderHelper } from "node-downloader-helper"
|
import { DownloaderHelper } from "node-downloader-helper"
|
||||||
import { dirname, join } from "patha"
|
import { dirname, join } from "patha"
|
||||||
|
@ -29,19 +30,29 @@ export async function setupNala(version: string, _setupDir: string, _arch: strin
|
||||||
binDir = "/usr/bin" // eslint-disable-line require-atomic-updates
|
binDir = "/usr/bin" // eslint-disable-line require-atomic-updates
|
||||||
|
|
||||||
// If nala is available in the default repositories, install it
|
// If nala is available in the default repositories, install it
|
||||||
|
try {
|
||||||
const nalaPack = await qualifiedNeededAptPackage({ name: "nala", version })
|
const nalaPack = await qualifiedNeededAptPackage({ name: "nala", version })
|
||||||
if (nalaPack !== undefined) {
|
if (nalaPack !== undefined) {
|
||||||
await installAptPack([{ name: nalaPack }])
|
await installAptPack([{ name: nalaPack }])
|
||||||
return { binDir }
|
return { binDir }
|
||||||
}
|
}
|
||||||
|
} catch (err) {
|
||||||
|
// ignore
|
||||||
|
info(`Failed to install nala: ${err}`)
|
||||||
|
}
|
||||||
|
|
||||||
// Nala is not available in the default repositories
|
// Nala is not available in the default repositories
|
||||||
// Check if the legacy version is available
|
// Check if the legacy version is available
|
||||||
|
try {
|
||||||
const nalaLegacyPack = await qualifiedNeededAptPackage({ name: "nala-legacy" })
|
const nalaLegacyPack = await qualifiedNeededAptPackage({ name: "nala-legacy" })
|
||||||
if (nalaLegacyPack !== undefined) {
|
if (nalaLegacyPack !== undefined) {
|
||||||
await installAptPack([{ name: nalaLegacyPack }], true)
|
await installAptPack([{ name: nalaLegacyPack }], true)
|
||||||
return { binDir }
|
return { binDir }
|
||||||
}
|
}
|
||||||
|
} catch (err) {
|
||||||
|
// ignore
|
||||||
|
info(`Failed to install nala-legacy: ${err}`)
|
||||||
|
}
|
||||||
|
|
||||||
// Install via the installer script
|
// Install via the installer script
|
||||||
await setupNalaViaInstaller()
|
await setupNalaViaInstaller()
|
||||||
|
@ -66,7 +77,14 @@ async function setupNalaViaInstaller() {
|
||||||
const script = await readFile(installerPath, "utf8")
|
const script = await readFile(installerPath, "utf8")
|
||||||
await writeFile(installerPath, script.replace(/sudo/g, ""))
|
await writeFile(installerPath, script.replace(/sudo/g, ""))
|
||||||
|
|
||||||
|
await installAptPack([{ name: "wget" }])
|
||||||
|
|
||||||
|
try {
|
||||||
execRootSync("bash", [installerPath])
|
execRootSync("bash", [installerPath])
|
||||||
|
} catch (err) {
|
||||||
|
error(`Failed to install nala via installer: ${err}`)
|
||||||
|
execRootSync("apt", ["install", "-y", "-t", "nala", "nala"])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function bashWithNala(script: string) {
|
export function bashWithNala(script: string) {
|
||||||
|
|
Loading…
Reference in New Issue