Skip to content

Commit 4c0bf0a

Browse files
committed
fix: make apt-fast non-interactive
1 parent ecc6c76 commit 4c0bf0a

File tree

5 files changed

+22
-5
lines changed

5 files changed

+22
-5
lines changed

dist/legacy/setup-cpp.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/legacy/setup-cpp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/modern/setup-cpp.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dist/modern/setup-cpp.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/apt-fast/apt-fast.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { execRootSync } from "admina"
44
import { error } from "ci-log"
55
import { readFile, writeFile } from "fs/promises"
66
import { DownloaderHelper } from "node-downloader-helper"
7+
import { installAptPack } from "setup-apt"
78
import which from "which"
89
import { hasAptGet } from "../utils/env/hasAptGet.js"
910

@@ -33,6 +34,8 @@ export async function setupAptFast(_version: string, _setupDir: string, _arch: s
3334
}
3435

3536
async function setupAptFastViaInstaller() {
37+
const depP = installAptPack([{ name: "bash" }, { name: "wget" }])
38+
3639
const installer = new DownloaderHelper(
3740
"https://git.io/vokNn",
3841
tmpdir(),
@@ -49,10 +52,24 @@ async function setupAptFastViaInstaller() {
4952
const script = await readFile(installerPath, "utf8")
5053
await writeFile(installerPath, script.replace(/sudo/g, ""))
5154

55+
await depP
56+
5257
try {
5358
execRootSync("bash", [installerPath])
5459
} catch (err) {
5560
error(`Failed to install apt-fast via installer: ${err}`)
56-
execRootSync("apt", ["install", "-y", "-t", "apt-fast", "apt-fast"])
5761
}
62+
63+
// Update the apt-fast config
64+
const aptFastConfigPath = "/etc/apt-fast.conf"
65+
let aptFastConfig = await readFile(aptFastConfigPath, "utf8")
66+
67+
// enable default suggested configs
68+
const opts = ["_APTMGR", "DOWNLOADBEFORE"]
69+
for (const opt of opts) {
70+
aptFastConfig = aptFastConfig.replace(new RegExp(`^#\\s*${opt}`, "m"), opt)
71+
}
72+
73+
// write the config
74+
await writeFile(aptFastConfigPath, aptFastConfig)
5875
}

0 commit comments

Comments
 (0)