fix: fix nala installation on Ubuntu 20.04

This commit is contained in:
Amin Yahyaabadi 2024-09-03 02:34:11 -07:00
parent 4e7c4bb64b
commit b6193582b7
No known key found for this signature in database
GPG Key ID: F52AF77F636088F0
8 changed files with 37 additions and 19 deletions

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

View File

@ -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

View File

@ -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,18 +30,28 @@ 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
const nalaPack = await qualifiedNeededAptPackage({ name: "nala", version }) try {
if (nalaPack !== undefined) { const nalaPack = await qualifiedNeededAptPackage({ name: "nala", version })
await installAptPack([{ name: nalaPack }]) if (nalaPack !== undefined) {
return { binDir } await installAptPack([{ name: nalaPack }])
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
const nalaLegacyPack = await qualifiedNeededAptPackage({ name: "nala-legacy" }) try {
if (nalaLegacyPack !== undefined) { const nalaLegacyPack = await qualifiedNeededAptPackage({ name: "nala-legacy" })
await installAptPack([{ name: nalaLegacyPack }], true) if (nalaLegacyPack !== undefined) {
return { binDir } await installAptPack([{ name: nalaLegacyPack }], true)
return { binDir }
}
} catch (err) {
// ignore
info(`Failed to install nala-legacy: ${err}`)
} }
// Install via the installer script // Install via the installer script
@ -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, ""))
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) { export function bashWithNala(script: string) {