feat: support installing packages using dnf

This commit is contained in:
Amin Yahyaabadi 2022-07-10 16:13:02 -07:00
parent 45e4fd60f0
commit 1f049b017f
4 changed files with 40 additions and 7 deletions

14
src/utils/env/hasDnf.ts vendored Normal file
View File

@ -0,0 +1,14 @@
import which from "which"
let hasDnfCache: undefined | boolean = undefined
export function hasDnf(): boolean {
if (process.platform !== "linux") {
return false
}
if (hasDnfCache === undefined) {
hasDnfCache = which.sync("dnf", { nothrow: true }) !== null
}
return hasDnfCache
}

View File

@ -29,9 +29,6 @@ export function setupAptPack(
if (!didInit) {
// install apt utils and certificates (usually missing from docker containers)
// set time - zone
// TZ = Canada / Pacific
// ln - snf / usr / share / zoneinfo / $TZ / etc / localtime && echo $TZ > /etc/timezone
execSudo(apt, [
"install",
"--fix-broken",

View File

@ -0,0 +1,26 @@
/* eslint-disable require-atomic-updates */
import { InstallationInfo } from "./setupBin"
import { execSudo } from "../exec/sudo"
import { info } from "../io/io"
let didUpdate: boolean = false
/** A function that installs a package using dnf */
export function setupDnfPack(name: string, version?: string): InstallationInfo {
info(`Installing ${name} ${version ?? ""} via dnf`)
const dnf = "dnf"
if (!didUpdate) {
execSudo(dnf, ["-y", "check-update"])
didUpdate = true
}
if (version !== undefined && version !== "") {
execSudo(dnf, ["-y", "install", `${name}-${version}`])
} else {
execSudo(dnf, ["-y", "install", name])
}
return { binDir: "/usr/bin/" }
}

View File

@ -18,10 +18,6 @@ export function setupPacmanPack(name: string, version?: string, aur?: string): I
}
if (!didInit) {
// set time - zone
// TZ = Canada / Pacific
// ln - snf / usr / share / zoneinfo / $TZ / etc / localtime && echo $TZ > /etc/timezone
// install base-devel
execSudo(pacman, ["-Sy", "--noconfirm", "base-devel"])
didInit = true