Skip to content

Commit

Permalink
fix: fix nala installation on Ubuntu 20.04
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Sep 3, 2024
1 parent 4e7c4bb commit 6170936
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 19 deletions.
4 changes: 2 additions & 2 deletions dist/actions/setup-cpp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/actions/setup-cpp.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions 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.

4 changes: 2 additions & 2 deletions dist/modern/setup-cpp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/modern/setup-cpp.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lefthook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ pre-commit:
test.lint:
run: pnpm run test.lint
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
36 changes: 27 additions & 9 deletions src/nala/nala.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { dirname, join } from "patha"
import { hasNala, installAptPack, qualifiedNeededAptPackage } from "setup-apt"
import which from "which"
import { isUbuntu } from "../utils/env/isUbuntu.js"
import { error, info } from "ci-log"

let binDir: string | undefined

Expand All @@ -29,18 +30,28 @@ export async function setupNala(version: string, _setupDir: string, _arch: strin
binDir = "/usr/bin" // eslint-disable-line require-atomic-updates

// If nala is available in the default repositories, install it
const nalaPack = await qualifiedNeededAptPackage({ name: "nala", version })
if (nalaPack !== undefined) {
await installAptPack([{ name: nalaPack }])
return { binDir }
try {
const nalaPack = await qualifiedNeededAptPackage({ name: "nala", version })
if (nalaPack !== undefined) {
await installAptPack([{ name: nalaPack }])
return { binDir }
}
} catch (err) {
// ignore
info(`Failed to install nala: ${err}`)
}

// Nala is not available in the default repositories
// Check if the legacy version is available
const nalaLegacyPack = await qualifiedNeededAptPackage({ name: "nala-legacy" })
if (nalaLegacyPack !== undefined) {
await installAptPack([{ name: nalaLegacyPack }], true)
return { binDir }
try {
const nalaLegacyPack = await qualifiedNeededAptPackage({ name: "nala-legacy" })
if (nalaLegacyPack !== undefined) {
await installAptPack([{ name: nalaLegacyPack }], true)
return { binDir }
}
} catch (err) {
// ignore
info(`Failed to install nala-legacy: ${err}`)
}

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

execRootSync("bash", [installerPath])
await installAptPack([{ name: "wget" }])

try {
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) {
Expand Down

0 comments on commit 6170936

Please sign in to comment.