setup-cpp/packages/setup-apt/src/init-apt.ts

29 lines
974 B
TypeScript
Raw Normal View History

import { defaultExecOptions, execRootSync } from "admina"
2024-08-30 07:12:54 +08:00
import memoize from "memoizee"
import { getAptEnv } from "./apt-env.js"
import { aptTimeout } from "./apt-timeout.js"
import { filterAndQualifyAptPackages } from "./qualify-install.js"
import { updateAptReposMemoized } from "./update.js"
/** Install gnupg and certificates (usually missing from docker containers) */
export async function initApt(apt: string) {
// Update the repos
updateAptReposMemoized(apt)
const toInstall = await filterAndQualifyAptPackages(apt, [
{ name: "ca-certificates" },
{ name: "gnupg" },
{ name: "apt-utils" },
])
if (toInstall.length !== 0) {
execRootSync(apt, ["install", "-y", "--fix-broken", "-o", aptTimeout, ...toInstall], {
...defaultExecOptions,
env: getAptEnv(apt),
})
}
}
/** Install gnupg and certificates (usually missing from docker containers) (memoized) */
2024-08-30 07:12:54 +08:00
export const initAptMemoized = memoize(initApt, { promise: true })