diff --git a/src/utils/env/hasDnf.ts b/src/utils/env/hasDnf.ts new file mode 100644 index 00000000..da22bdbf --- /dev/null +++ b/src/utils/env/hasDnf.ts @@ -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 +} diff --git a/src/utils/setup/setupAptPack.ts b/src/utils/setup/setupAptPack.ts index 9eb6013e..517c0cfc 100644 --- a/src/utils/setup/setupAptPack.ts +++ b/src/utils/setup/setupAptPack.ts @@ -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", diff --git a/src/utils/setup/setupDnfPack.ts b/src/utils/setup/setupDnfPack.ts new file mode 100644 index 00000000..08f0fb97 --- /dev/null +++ b/src/utils/setup/setupDnfPack.ts @@ -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/" } +} diff --git a/src/utils/setup/setupPacmanPack.ts b/src/utils/setup/setupPacmanPack.ts index 2d871d16..69f9c307 100644 --- a/src/utils/setup/setupPacmanPack.ts +++ b/src/utils/setup/setupPacmanPack.ts @@ -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