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,22 +20,57 @@ export function setupAptPack(
): InstallationInfo {
info(`Installing ${name} ${version ?? ""} via apt`)
let apt: string = getApt()
process.env.DEBIAN_FRONTEND = "noninteractive"
if (!didUpdate || update) {
updateRepos(apt)
didUpdate = true
}
if (!didInit) {
initApt(apt)
didInit = true
}
if (Array.isArray(repositories)) {
for (const repo of repositories) {
// eslint-disable-next-line no-await-in-loop
execSudo("add-apt-repository", ["--update", "-y", repo])
}
updateRepos(apt)
}
if (version !== undefined && version !== "") {
try {
execSudo(apt, ["install", "--fix-broken", "-y", `${name}=${version}`])
} catch {
execSudo(apt, ["install", "--fix-broken", "-y", `${name}-${version}`])
}
} else {
execSudo(apt, ["install", "--fix-broken", "-y", name])
}
return { binDir: "/usr/bin/" }
}
function getApt() {
let apt: string
if (which.sync("nala", { nothrow: true }) !== null) {
apt = "nala"
} else {
apt = "apt-get"
}
process.env.DEBIAN_FRONTEND = "noninteractive"
if (!didUpdate || update) {
execSudo(apt, ["update", "-y"])
didUpdate = true
return apt
}
if (!didInit) {
// install apt utils and certificates (usually missing from docker containers)
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",
@ -52,28 +87,6 @@ export function setupAptPack(
} catch (err) {
warning(`Failed to add keys: ${err}`)
}
didInit = true
}
if (Array.isArray(repositories)) {
for (const repo of repositories) {
// eslint-disable-next-line no-await-in-loop
execSudo("add-apt-repository", ["--update", "-y", repo])
}
execSudo(apt, ["update", "-y"])
}
if (version !== undefined && version !== "") {
try {
execSudo(apt, ["install", "--fix-broken", "-y", `${name}=${version}`])
} catch {
execSudo(apt, ["install", "--fix-broken", "-y", `${name}-${version}`])
}
} else {
execSudo(apt, ["install", "--fix-broken", "-y", name])
}
return { binDir: "/usr/bin/" }
}
export function updateAptAlternatives(name: string, path: string) {