feat: support installing nala

This commit is contained in:
Amin Yahyaabadi 2022-07-25 00:40:05 -07:00
parent e82d38fa16
commit 96f1e1cf8c
6 changed files with 73 additions and 2 deletions

View File

@ -75,6 +75,9 @@ inputs:
sevenzip:
description: "The 7z version to install."
required: false
nala:
description: 'The nala version to install ("legacy" or "").'
required: false
runs:
using: "node12"

View File

@ -55,6 +55,14 @@ const DefaultUbuntuVersion: Record<string, Record<number, string>> = {
doxygen: {
20: "1.9.4",
},
nala: {
22: "",
21: "legacy",
20: "legacy",
18: "legacy",
16: "legacy",
14: "legacy",
},
}
/** Get the default version if passed true or undefined, otherwise return the version itself */

View File

@ -42,6 +42,7 @@ import { setupKcov } from "./kcov/kcov"
import { addEnv } from "./utils/env/addEnv"
import { setupSevenZip } from "./sevenzip/sevenzip"
import { setupGraphviz } from "./graphviz/graphviz"
import { setupNala } from "./nala/nala"
/** The setup functions */
const setups = {
@ -69,6 +70,7 @@ const setups = {
make: setupMake,
task: setupTask,
sevenzip: setupSevenZip,
nala: setupNala,
}
/** The tools that can be installed */
@ -97,6 +99,7 @@ const tools: Array<keyof typeof setups> = [
"make",
"task",
"sevenzip",
"nala",
]
/** The possible inputs to the program */

View File

@ -0,0 +1,13 @@
import { setupNala } from "../nala"
import { testBin } from "../../utils/tests/test-helpers"
jest.setTimeout(300000)
describe("setup-nala", () => {
it("should setup nala", async () => {
if (process.platform !== "linux") {
return
}
const installInfo = setupNala("", "", process.arch)
await testBin("nala", ["--version"], installInfo?.binDir)
})
})

43
src/nala/nala.ts Normal file
View File

@ -0,0 +1,43 @@
import { dirname } from "path"
import which from "which"
import { execSudo } from "../utils/exec/sudo"
import { setupAptPack } from "../utils/setup/setupAptPack"
let binDir: string | undefined
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function setupNala(version: string, _setupDir: string, _arch: string) {
if (process.platform !== "linux") {
return undefined
}
if (typeof binDir === "string") {
return { binDir }
}
const maybeBinDir = which.sync("nala", { nothrow: true })
if (maybeBinDir !== null) {
binDir = dirname(maybeBinDir)
return { binDir }
}
// https://github.com/volitank/nala#-installation
execSudo("/bin/bash", [
"-c",
`echo "deb http://deb.volian.org/volian/ scar main" | sudo tee /etc/apt/sources.list.d/volian-archive-scar-unstable.list`,
])
setupAptPack("wget")
execSudo("/bin/bash", [
"-c",
`wget -qO - https://deb.volian.org/volian/scar.key | sudo tee /etc/apt/trusted.gpg.d/volian-archive-scar-unstable.gpg > /dev/null`,
])
if (version !== "legacy") {
setupAptPack("nala", undefined, [], true)
} else {
setupAptPack("nala-legacy", undefined, [], true)
}
binDir = "/usr/bin"
return { binDir }
}

View File

@ -14,7 +14,8 @@ let didInit: boolean = false
export function setupAptPack(
name: string,
version?: string,
repositories: boolean | string[] = true
repositories: string[] = [],
update = false
): InstallationInfo {
info(`Installing ${name} ${version ?? ""} via apt`)
@ -22,7 +23,7 @@ export function setupAptPack(
process.env.DEBIAN_FRONTEND = "noninteractive"
if (!didUpdate) {
if (!didUpdate || update) {
execSudo(apt, ["update", "-y"])
didUpdate = true
}