mirror of https://github.com/aminya/setup-cpp
fix: fix nala update arguments
This commit is contained in:
parent
b96f1ee859
commit
9f78cc758b
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
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue