fix: use nala on ubuntu instead of apt

This commit is contained in:
Amin Yahyaabadi 2022-07-25 00:46:23 -07:00
parent 96f1e1cf8c
commit e4784c9adc
5 changed files with 16 additions and 6 deletions

View File

@ -75,9 +75,6 @@ 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"

View File

@ -43,6 +43,7 @@ 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" import { setupNala } from "./nala/nala"
import { isUbuntu } from "./utils/env/isUbuntu"
/** The setup functions */ /** The setup functions */
const setups = { const setups = {
@ -154,6 +155,10 @@ export async function main(args: string[]): Promise<number> {
return 1 return 1
} }
if (isUbuntu()) {
setupNala(getVersion("nala", undefined, osVersion), "", arch)
}
// loop over the tools and run their setup function // loop over the tools and run their setup function
for (const tool of tools) { for (const tool of tools) {
// get the version or "true" or undefined for this tool from the options // get the version or "true" or undefined for this tool from the options

View File

@ -1,10 +1,11 @@
import { setupNala } from "../nala" import { setupNala } from "../nala"
import { testBin } from "../../utils/tests/test-helpers" import { testBin } from "../../utils/tests/test-helpers"
import { isUbuntu } from "../../utils/env/isUbuntu"
jest.setTimeout(300000) jest.setTimeout(300000)
describe("setup-nala", () => { describe("setup-nala", () => {
it("should setup nala", async () => { it("should setup nala", async () => {
if (process.platform !== "linux") { if (!isUbuntu()) {
return return
} }
const installInfo = setupNala("", "", process.arch) const installInfo = setupNala("", "", process.arch)

View File

@ -1,5 +1,6 @@
import { dirname } from "path" import { dirname } from "path"
import which from "which" import which from "which"
import { isUbuntu } from "../utils/env/isUbuntu"
import { execSudo } from "../utils/exec/sudo" import { execSudo } from "../utils/exec/sudo"
import { setupAptPack } from "../utils/setup/setupAptPack" import { setupAptPack } from "../utils/setup/setupAptPack"
@ -7,7 +8,7 @@ let binDir: string | undefined
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
export function setupNala(version: string, _setupDir: string, _arch: string) { export function setupNala(version: string, _setupDir: string, _arch: string) {
if (process.platform !== "linux") { if (!isUbuntu()) {
return undefined return undefined
} }
if (typeof binDir === "string") { if (typeof binDir === "string") {

View File

@ -6,6 +6,7 @@ import { warning } from "../io/io"
import { isGitHubCI } from "../env/isCI" import { isGitHubCI } from "../env/isCI"
import { cpprc_path, setupCppInProfile } from "../env/addEnv" import { cpprc_path, setupCppInProfile } from "../env/addEnv"
import { appendFileSync } from "fs" import { appendFileSync } from "fs"
import which from "which"
let didUpdate: boolean = false let didUpdate: boolean = false
let didInit: boolean = false let didInit: boolean = false
@ -19,7 +20,12 @@ export function setupAptPack(
): InstallationInfo { ): InstallationInfo {
info(`Installing ${name} ${version ?? ""} via apt`) info(`Installing ${name} ${version ?? ""} via apt`)
const apt = "apt-get" let apt: string
if (which.sync("nala", { nothrow: true }) !== null) {
apt = "nala"
} else {
apt = "apt-get"
}
process.env.DEBIAN_FRONTEND = "noninteractive" process.env.DEBIAN_FRONTEND = "noninteractive"