Skip to content

Commit 1f049b0

Browse files
committed
feat: support installing packages using dnf
1 parent 45e4fd6 commit 1f049b0

File tree

4 files changed

+40
-7
lines changed

4 files changed

+40
-7
lines changed

src/utils/env/hasDnf.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import which from "which"
2+
3+
let hasDnfCache: undefined | boolean = undefined
4+
5+
export function hasDnf(): boolean {
6+
if (process.platform !== "linux") {
7+
return false
8+
}
9+
if (hasDnfCache === undefined) {
10+
hasDnfCache = which.sync("dnf", { nothrow: true }) !== null
11+
}
12+
13+
return hasDnfCache
14+
}

src/utils/setup/setupAptPack.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ export function setupAptPack(
2929

3030
if (!didInit) {
3131
// install apt utils and certificates (usually missing from docker containers)
32-
// set time - zone
33-
// TZ = Canada / Pacific
34-
// ln - snf / usr / share / zoneinfo / $TZ / etc / localtime && echo $TZ > /etc/timezone
3532
execSudo(apt, [
3633
"install",
3734
"--fix-broken",

src/utils/setup/setupDnfPack.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/* eslint-disable require-atomic-updates */
2+
import { InstallationInfo } from "./setupBin"
3+
import { execSudo } from "../exec/sudo"
4+
import { info } from "../io/io"
5+
6+
let didUpdate: boolean = false
7+
8+
/** A function that installs a package using dnf */
9+
export function setupDnfPack(name: string, version?: string): InstallationInfo {
10+
info(`Installing ${name} ${version ?? ""} via dnf`)
11+
12+
const dnf = "dnf"
13+
14+
if (!didUpdate) {
15+
execSudo(dnf, ["-y", "check-update"])
16+
didUpdate = true
17+
}
18+
19+
if (version !== undefined && version !== "") {
20+
execSudo(dnf, ["-y", "install", `${name}-${version}`])
21+
} else {
22+
execSudo(dnf, ["-y", "install", name])
23+
}
24+
25+
return { binDir: "/usr/bin/" }
26+
}

src/utils/setup/setupPacmanPack.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ export function setupPacmanPack(name: string, version?: string, aur?: string): I
1818
}
1919

2020
if (!didInit) {
21-
// set time - zone
22-
// TZ = Canada / Pacific
23-
// ln - snf / usr / share / zoneinfo / $TZ / etc / localtime && echo $TZ > /etc/timezone
24-
2521
// install base-devel
2622
execSudo(pacman, ["-Sy", "--noconfirm", "base-devel"])
2723
didInit = true

0 commit comments

Comments
 (0)