Skip to content

Commit b619358

Browse files
committed
fix: fix nala installation on Ubuntu 20.04
1 parent 4e7c4bb commit b619358

File tree

8 files changed

+37
-19
lines changed

8 files changed

+37
-19
lines changed

dist/actions/setup-cpp.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/actions/setup-cpp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/legacy/setup-cpp.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/legacy/setup-cpp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/modern/setup-cpp.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/modern/setup-cpp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lefthook.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ pre-commit:
44
test.lint:
55
run: pnpm run test.lint
66
build:
7-
run: pnpm run clean && pnpm i && pnpm run build -- --no-color && git add ./dist
7+
run: pnpm run clean && pnpm run build -- --no-color && git add ./dist

src/nala/nala.ts

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { tmpdir } from "os"
22
import { execRootSync } from "admina"
3+
import { error, info } from "ci-log"
34
import { readFile, writeFile } from "fs/promises"
45
import { DownloaderHelper } from "node-downloader-helper"
56
import { dirname, join } from "patha"
@@ -29,18 +30,28 @@ export async function setupNala(version: string, _setupDir: string, _arch: strin
2930
binDir = "/usr/bin" // eslint-disable-line require-atomic-updates
3031

3132
// If nala is available in the default repositories, install it
32-
const nalaPack = await qualifiedNeededAptPackage({ name: "nala", version })
33-
if (nalaPack !== undefined) {
34-
await installAptPack([{ name: nalaPack }])
35-
return { binDir }
33+
try {
34+
const nalaPack = await qualifiedNeededAptPackage({ name: "nala", version })
35+
if (nalaPack !== undefined) {
36+
await installAptPack([{ name: nalaPack }])
37+
return { binDir }
38+
}
39+
} catch (err) {
40+
// ignore
41+
info(`Failed to install nala: ${err}`)
3642
}
3743

3844
// Nala is not available in the default repositories
3945
// Check if the legacy version is available
40-
const nalaLegacyPack = await qualifiedNeededAptPackage({ name: "nala-legacy" })
41-
if (nalaLegacyPack !== undefined) {
42-
await installAptPack([{ name: nalaLegacyPack }], true)
43-
return { binDir }
46+
try {
47+
const nalaLegacyPack = await qualifiedNeededAptPackage({ name: "nala-legacy" })
48+
if (nalaLegacyPack !== undefined) {
49+
await installAptPack([{ name: nalaLegacyPack }], true)
50+
return { binDir }
51+
}
52+
} catch (err) {
53+
// ignore
54+
info(`Failed to install nala-legacy: ${err}`)
4455
}
4556

4657
// Install via the installer script
@@ -66,7 +77,14 @@ async function setupNalaViaInstaller() {
6677
const script = await readFile(installerPath, "utf8")
6778
await writeFile(installerPath, script.replace(/sudo/g, ""))
6879

69-
execRootSync("bash", [installerPath])
80+
await installAptPack([{ name: "wget" }])
81+
82+
try {
83+
execRootSync("bash", [installerPath])
84+
} catch (err) {
85+
error(`Failed to install nala via installer: ${err}`)
86+
execRootSync("apt", ["install", "-y", "-t", "nala", "nala"])
87+
}
7088
}
7189

7290
export function bashWithNala(script: string) {

0 commit comments

Comments
 (0)