fix: fix nala update arguments

This commit is contained in:
Amin Yahyaabadi 2022-07-27 16:06:34 -07:00
parent b96f1ee859
commit 9f78cc758b
5 changed files with 42 additions and 29 deletions

2
dist/setup_cpp.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/setup_cpp.mjs vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -20,38 +20,17 @@ export function setupAptPack(
): InstallationInfo {
info(`Installing ${name} ${version ?? ""} via apt`)
let apt: string
if (which.sync("nala", { nothrow: true }) !== null) {
apt = "nala"
} else {
apt = "apt-get"
}
let apt: string = getApt()
process.env.DEBIAN_FRONTEND = "noninteractive"
if (!didUpdate || update) {
execSudo(apt, ["update", "-y"])
updateRepos(apt)
didUpdate = true
}
if (!didInit) {
// install apt utils and certificates (usually missing from docker containers)
execSudo(apt, [
"install",
"--fix-broken",
"-y",
"software-properties-common",
"apt-utils",
"ca-certificates",
"gnupg",
])
try {
execSudo("apt-key", ["adv", "--keyserver", "keyserver.ubuntu.com", "--recv-keys", "3B4FE6ACC0B21F32"])
execSudo("apt-key", ["adv", "--keyserver", "keyserver.ubuntu.com", "--recv-keys", "40976EAF437D05B5"])
execSudo("apt-key", ["adv", "--keyserver", "keyserver.ubuntu.com", "--recv-keys", "1E9377A2BA9EF27F"])
} catch (err) {
warning(`Failed to add keys: ${err}`)
}
initApt(apt)
didInit = true
}
@ -60,7 +39,7 @@ export function setupAptPack(
// eslint-disable-next-line no-await-in-loop
execSudo("add-apt-repository", ["--update", "-y", repo])
}
execSudo(apt, ["update", "-y"])
updateRepos(apt)
}
if (version !== undefined && version !== "") {
@ -76,6 +55,40 @@ export function setupAptPack(
return { binDir: "/usr/bin/" }
}
function getApt() {
let apt: string
if (which.sync("nala", { nothrow: true }) !== null) {
apt = "nala"
} else {
apt = "apt-get"
}
return apt
}
function updateRepos(apt: string) {
execSudo(apt, apt !== "nala" ? ["update", "-y"] : ["update"])
}
/** Install apt utils and certificates (usually missing from docker containers) */
function initApt(apt: string) {
execSudo(apt, [
"install",
"--fix-broken",
"-y",
"software-properties-common",
"apt-utils",
"ca-certificates",
"gnupg",
])
try {
execSudo("apt-key", ["adv", "--keyserver", "keyserver.ubuntu.com", "--recv-keys", "3B4FE6ACC0B21F32"])
execSudo("apt-key", ["adv", "--keyserver", "keyserver.ubuntu.com", "--recv-keys", "40976EAF437D05B5"])
execSudo("apt-key", ["adv", "--keyserver", "keyserver.ubuntu.com", "--recv-keys", "1E9377A2BA9EF27F"])
} catch (err) {
warning(`Failed to add keys: ${err}`)
}
}
export function updateAptAlternatives(name: string, path: string) {
if (isGitHubCI()) {
return execSudo("update-alternatives", ["--install", `/usr/bin/${name}`, name, path, "40"])