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 {
|
): InstallationInfo {
|
||||||
info(`Installing ${name} ${version ?? ""} via apt`)
|
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
|
let apt: string
|
||||||
if (which.sync("nala", { nothrow: true }) !== null) {
|
if (which.sync("nala", { nothrow: true }) !== null) {
|
||||||
apt = "nala"
|
apt = "nala"
|
||||||
} else {
|
} else {
|
||||||
apt = "apt-get"
|
apt = "apt-get"
|
||||||
}
|
}
|
||||||
|
return apt
|
||||||
process.env.DEBIAN_FRONTEND = "noninteractive"
|
|
||||||
|
|
||||||
if (!didUpdate || update) {
|
|
||||||
execSudo(apt, ["update", "-y"])
|
|
||||||
didUpdate = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!didInit) {
|
function updateRepos(apt: string) {
|
||||||
// install apt utils and certificates (usually missing from docker containers)
|
execSudo(apt, apt !== "nala" ? ["update", "-y"] : ["update"])
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Install apt utils and certificates (usually missing from docker containers) */
|
||||||
|
function initApt(apt: string) {
|
||||||
execSudo(apt, [
|
execSudo(apt, [
|
||||||
"install",
|
"install",
|
||||||
"--fix-broken",
|
"--fix-broken",
|
||||||
|
@ -52,28 +87,6 @@ export function setupAptPack(
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
warning(`Failed to add keys: ${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) {
|
export function updateAptAlternatives(name: string, path: string) {
|
||||||
|
|
Loading…
Reference in New Issue