Skip to content

Commit 96f1e1c

Browse files
committed
feat: support installing nala
1 parent e82d38f commit 96f1e1c

File tree

6 files changed

+73
-2
lines changed

6 files changed

+73
-2
lines changed

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ inputs:
7575
sevenzip:
7676
description: "The 7z version to install."
7777
required: false
78+
nala:
79+
description: 'The nala version to install ("legacy" or "").'
80+
required: false
7881

7982
runs:
8083
using: "node12"

src/default_versions.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ const DefaultUbuntuVersion: Record<string, Record<number, string>> = {
5555
doxygen: {
5656
20: "1.9.4",
5757
},
58+
nala: {
59+
22: "",
60+
21: "legacy",
61+
20: "legacy",
62+
18: "legacy",
63+
16: "legacy",
64+
14: "legacy",
65+
},
5866
}
5967

6068
/** Get the default version if passed true or undefined, otherwise return the version itself */

src/main.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import { setupKcov } from "./kcov/kcov"
4242
import { addEnv } from "./utils/env/addEnv"
4343
import { setupSevenZip } from "./sevenzip/sevenzip"
4444
import { setupGraphviz } from "./graphviz/graphviz"
45+
import { setupNala } from "./nala/nala"
4546

4647
/** The setup functions */
4748
const setups = {
@@ -69,6 +70,7 @@ const setups = {
6970
make: setupMake,
7071
task: setupTask,
7172
sevenzip: setupSevenZip,
73+
nala: setupNala,
7274
}
7375

7476
/** The tools that can be installed */
@@ -97,6 +99,7 @@ const tools: Array<keyof typeof setups> = [
9799
"make",
98100
"task",
99101
"sevenzip",
102+
"nala",
100103
]
101104

102105
/** The possible inputs to the program */

src/nala/__tests__/nala.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { setupNala } from "../nala"
2+
import { testBin } from "../../utils/tests/test-helpers"
3+
4+
jest.setTimeout(300000)
5+
describe("setup-nala", () => {
6+
it("should setup nala", async () => {
7+
if (process.platform !== "linux") {
8+
return
9+
}
10+
const installInfo = setupNala("", "", process.arch)
11+
await testBin("nala", ["--version"], installInfo?.binDir)
12+
})
13+
})

src/nala/nala.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { dirname } from "path"
2+
import which from "which"
3+
import { execSudo } from "../utils/exec/sudo"
4+
import { setupAptPack } from "../utils/setup/setupAptPack"
5+
6+
let binDir: string | undefined
7+
8+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
9+
export function setupNala(version: string, _setupDir: string, _arch: string) {
10+
if (process.platform !== "linux") {
11+
return undefined
12+
}
13+
if (typeof binDir === "string") {
14+
return { binDir }
15+
}
16+
17+
const maybeBinDir = which.sync("nala", { nothrow: true })
18+
if (maybeBinDir !== null) {
19+
binDir = dirname(maybeBinDir)
20+
return { binDir }
21+
}
22+
23+
// https://github.com/volitank/nala#-installation
24+
execSudo("/bin/bash", [
25+
"-c",
26+
`echo "deb http://deb.volian.org/volian/ scar main" | sudo tee /etc/apt/sources.list.d/volian-archive-scar-unstable.list`,
27+
])
28+
setupAptPack("wget")
29+
execSudo("/bin/bash", [
30+
"-c",
31+
`wget -qO - https://deb.volian.org/volian/scar.key | sudo tee /etc/apt/trusted.gpg.d/volian-archive-scar-unstable.gpg > /dev/null`,
32+
])
33+
34+
if (version !== "legacy") {
35+
setupAptPack("nala", undefined, [], true)
36+
} else {
37+
setupAptPack("nala-legacy", undefined, [], true)
38+
}
39+
40+
binDir = "/usr/bin"
41+
42+
return { binDir }
43+
}

src/utils/setup/setupAptPack.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@ let didInit: boolean = false
1414
export function setupAptPack(
1515
name: string,
1616
version?: string,
17-
repositories: boolean | string[] = true
17+
repositories: string[] = [],
18+
update = false
1819
): InstallationInfo {
1920
info(`Installing ${name} ${version ?? ""} via apt`)
2021

2122
const apt = "apt-get"
2223

2324
process.env.DEBIAN_FRONTEND = "noninteractive"
2425

25-
if (!didUpdate) {
26+
if (!didUpdate || update) {
2627
execSudo(apt, ["update", "-y"])
2728
didUpdate = true
2829
}

0 commit comments

Comments
 (0)