Skip to content

Commit e4784c9

Browse files
committed
fix: use nala on ubuntu instead of apt
1 parent 96f1e1c commit e4784c9

File tree

5 files changed

+16
-6
lines changed

5 files changed

+16
-6
lines changed

action.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,6 @@ 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
8178

8279
runs:
8380
using: "node12"

src/main.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import { addEnv } from "./utils/env/addEnv"
4343
import { setupSevenZip } from "./sevenzip/sevenzip"
4444
import { setupGraphviz } from "./graphviz/graphviz"
4545
import { setupNala } from "./nala/nala"
46+
import { isUbuntu } from "./utils/env/isUbuntu"
4647

4748
/** The setup functions */
4849
const setups = {
@@ -154,6 +155,10 @@ export async function main(args: string[]): Promise<number> {
154155
return 1
155156
}
156157

158+
if (isUbuntu()) {
159+
setupNala(getVersion("nala", undefined, osVersion), "", arch)
160+
}
161+
157162
// loop over the tools and run their setup function
158163
for (const tool of tools) {
159164
// get the version or "true" or undefined for this tool from the options

src/nala/__tests__/nala.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { setupNala } from "../nala"
22
import { testBin } from "../../utils/tests/test-helpers"
3+
import { isUbuntu } from "../../utils/env/isUbuntu"
34

45
jest.setTimeout(300000)
56
describe("setup-nala", () => {
67
it("should setup nala", async () => {
7-
if (process.platform !== "linux") {
8+
if (!isUbuntu()) {
89
return
910
}
1011
const installInfo = setupNala("", "", process.arch)

src/nala/nala.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import { dirname } from "path"
22
import which from "which"
3+
import { isUbuntu } from "../utils/env/isUbuntu"
34
import { execSudo } from "../utils/exec/sudo"
45
import { setupAptPack } from "../utils/setup/setupAptPack"
56

67
let binDir: string | undefined
78

89
// eslint-disable-next-line @typescript-eslint/no-unused-vars
910
export function setupNala(version: string, _setupDir: string, _arch: string) {
10-
if (process.platform !== "linux") {
11+
if (!isUbuntu()) {
1112
return undefined
1213
}
1314
if (typeof binDir === "string") {

src/utils/setup/setupAptPack.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { warning } from "../io/io"
66
import { isGitHubCI } from "../env/isCI"
77
import { cpprc_path, setupCppInProfile } from "../env/addEnv"
88
import { appendFileSync } from "fs"
9+
import which from "which"
910

1011
let didUpdate: boolean = false
1112
let didInit: boolean = false
@@ -19,7 +20,12 @@ export function setupAptPack(
1920
): InstallationInfo {
2021
info(`Installing ${name} ${version ?? ""} via apt`)
2122

22-
const apt = "apt-get"
23+
let apt: string
24+
if (which.sync("nala", { nothrow: true }) !== null) {
25+
apt = "nala"
26+
} else {
27+
apt = "apt-get"
28+
}
2329

2430
process.env.DEBIAN_FRONTEND = "noninteractive"
2531

0 commit comments

Comments
 (0)