fix: update before checking args when requested

This commit is contained in:
Amin Yahyaabadi 2024-08-08 16:08:25 -07:00
parent a9d70080cf
commit 5aa7099535
No known key found for this signature in database
GPG Key ID: F52AF77F636088F0
7 changed files with 18 additions and 18 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -35,6 +35,12 @@ export async function setupAptPack(packages: AptPackage[], update = false): Prom
process.env.DEBIAN_FRONTEND = "noninteractive" process.env.DEBIAN_FRONTEND = "noninteractive"
// Update the repos if needed
if (update) {
updateRepos(apt)
didUpdate = true
}
// Add the repos if needed // Add the repos if needed
await addRepositories(apt, packages) await addRepositories(apt, packages)
@ -49,12 +55,6 @@ export async function setupAptPack(packages: AptPackage[], update = false): Prom
return { binDir: "/usr/bin/" } return { binDir: "/usr/bin/" }
} }
// Update the repos if needed
if (!didUpdate || update) {
updateRepos(apt)
didUpdate = true
}
// Initialize apt if needed // Initialize apt if needed
if (!didInit) { if (!didInit) {
await initApt(apt) await initApt(apt)
@ -181,7 +181,7 @@ async function installAddAptRepo() {
if (await isPackageInstalled("software-properties-common")) { if (await isPackageInstalled("software-properties-common")) {
return return
} }
execRootSync("apt-get", ["install", "-y", "software-properties-common"]) execRootSync("apt-get", ["install", "-y", "--fix-broken", "software-properties-common"])
} }
/** Install gnupg and certificates (usually missing from docker containers) */ /** Install gnupg and certificates (usually missing from docker containers) */
@ -192,12 +192,12 @@ async function initApt(apt: string) {
didUpdate = true didUpdate = true
} }
if (!(await isPackageInstalled("ca-certificates"))) { const toInstall = ["ca-certificates", "gnupg", "apt-utils"].filter(async (pack) => !(await isPackageInstalled(pack)))
execRootSync(apt, ["install", "--fix-broken", "-y", "ca-certificates"])
} if (toInstall.length !== 0) {
if (!(await isPackageInstalled("gnupg"))) { execRootSync(apt, ["install", "-y", "--fix-broken", ...toInstall])
execRootSync(apt, ["install", "--fix-broken", "-y", "gnupg"])
} }
const promises: Promise<string | void>[] = [ const promises: Promise<string | void>[] = [
addAptKeyViaServer(["3B4FE6ACC0B21F32", "40976EAF437D05B5"], "setup-cpp-ubuntu-archive.gpg"), addAptKeyViaServer(["3B4FE6ACC0B21F32", "40976EAF437D05B5"], "setup-cpp-ubuntu-archive.gpg"),
addAptKeyViaServer(["1E9377A2BA9EF27F"], "launchpad-toolchain.gpg"), addAptKeyViaServer(["1E9377A2BA9EF27F"], "launchpad-toolchain.gpg"),