mirror of https://github.com/aminya/setup-cpp
feat: support installing nala
This commit is contained in:
parent
e82d38fa16
commit
96f1e1cf8c
|
@ -75,6 +75,9 @@ inputs:
|
||||||
sevenzip:
|
sevenzip:
|
||||||
description: "The 7z version to install."
|
description: "The 7z version to install."
|
||||||
required: false
|
required: false
|
||||||
|
nala:
|
||||||
|
description: 'The nala version to install ("legacy" or "").'
|
||||||
|
required: false
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: "node12"
|
using: "node12"
|
||||||
|
|
|
@ -55,6 +55,14 @@ const DefaultUbuntuVersion: Record<string, Record<number, string>> = {
|
||||||
doxygen: {
|
doxygen: {
|
||||||
20: "1.9.4",
|
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 */
|
/** Get the default version if passed true or undefined, otherwise return the version itself */
|
||||||
|
|
|
@ -42,6 +42,7 @@ import { setupKcov } from "./kcov/kcov"
|
||||||
import { addEnv } from "./utils/env/addEnv"
|
import { addEnv } from "./utils/env/addEnv"
|
||||||
import { setupSevenZip } from "./sevenzip/sevenzip"
|
import { setupSevenZip } from "./sevenzip/sevenzip"
|
||||||
import { setupGraphviz } from "./graphviz/graphviz"
|
import { setupGraphviz } from "./graphviz/graphviz"
|
||||||
|
import { setupNala } from "./nala/nala"
|
||||||
|
|
||||||
/** The setup functions */
|
/** The setup functions */
|
||||||
const setups = {
|
const setups = {
|
||||||
|
@ -69,6 +70,7 @@ const setups = {
|
||||||
make: setupMake,
|
make: setupMake,
|
||||||
task: setupTask,
|
task: setupTask,
|
||||||
sevenzip: setupSevenZip,
|
sevenzip: setupSevenZip,
|
||||||
|
nala: setupNala,
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The tools that can be installed */
|
/** The tools that can be installed */
|
||||||
|
@ -97,6 +99,7 @@ const tools: Array<keyof typeof setups> = [
|
||||||
"make",
|
"make",
|
||||||
"task",
|
"task",
|
||||||
"sevenzip",
|
"sevenzip",
|
||||||
|
"nala",
|
||||||
]
|
]
|
||||||
|
|
||||||
/** The possible inputs to the program */
|
/** The possible inputs to the program */
|
||||||
|
|
|
@ -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)
|
||||||
|
})
|
||||||
|
})
|
|
@ -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 }
|
||||||
|
}
|
|
@ -14,7 +14,8 @@ let didInit: boolean = false
|
||||||
export function setupAptPack(
|
export function setupAptPack(
|
||||||
name: string,
|
name: string,
|
||||||
version?: string,
|
version?: string,
|
||||||
repositories: boolean | string[] = true
|
repositories: string[] = [],
|
||||||
|
update = false
|
||||||
): InstallationInfo {
|
): InstallationInfo {
|
||||||
info(`Installing ${name} ${version ?? ""} via apt`)
|
info(`Installing ${name} ${version ?? ""} via apt`)
|
||||||
|
|
||||||
|
@ -22,7 +23,7 @@ export function setupAptPack(
|
||||||
|
|
||||||
process.env.DEBIAN_FRONTEND = "noninteractive"
|
process.env.DEBIAN_FRONTEND = "noninteractive"
|
||||||
|
|
||||||
if (!didUpdate) {
|
if (!didUpdate || update) {
|
||||||
execSudo(apt, ["update", "-y"])
|
execSudo(apt, ["update", "-y"])
|
||||||
didUpdate = true
|
didUpdate = true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue