mirror of https://github.com/aminya/setup-cpp
fix: handle the promises in setupAptPack
This commit is contained in:
parent
a9e484f19f
commit
c8cec57d18
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
|
@ -67,7 +67,7 @@ export async function setupDoxygen(version: string, setupDir: string, arch: stri
|
||||||
} else if (hasDnf()) {
|
} else if (hasDnf()) {
|
||||||
return setupDnfPack("doxygen", version)
|
return setupDnfPack("doxygen", version)
|
||||||
} else if (isUbuntu()) {
|
} else if (isUbuntu()) {
|
||||||
installationInfo = setupAptPack("doxygen", version)
|
installationInfo = await setupAptPack("doxygen", version)
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`Unsupported linux distributions`)
|
throw new Error(`Unsupported linux distributions`)
|
||||||
}
|
}
|
||||||
|
@ -75,10 +75,10 @@ export async function setupDoxygen(version: string, setupDir: string, arch: stri
|
||||||
try {
|
try {
|
||||||
// doxygen on stable Ubuntu repositories is very old. So, we use get the binary from the website itself
|
// doxygen on stable Ubuntu repositories is very old. So, we use get the binary from the website itself
|
||||||
installationInfo = await setupBin("doxygen", version, getDoxygenPackageInfo, setupDir, arch)
|
installationInfo = await setupBin("doxygen", version, getDoxygenPackageInfo, setupDir, arch)
|
||||||
setupAptPack("libclang-cpp9")
|
await setupAptPack("libclang-cpp9")
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
notice(`Failed to download doxygen binary. ${err}. Falling back to apt-get.`)
|
notice(`Failed to download doxygen binary. ${err}. Falling back to apt-get.`)
|
||||||
installationInfo = setupAptPack("doxygen", undefined)
|
installationInfo = await setupAptPack("doxygen", undefined)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`Unsupported linux distributions`)
|
throw new Error(`Unsupported linux distributions`)
|
||||||
|
|
|
@ -91,15 +91,15 @@ export async function setupGcc(version: string, setupDir: string, arch: string)
|
||||||
setupDnfPack("gcc-c++", version)
|
setupDnfPack("gcc-c++", version)
|
||||||
setupDnfPack("libstdc++-devel", undefined)
|
setupDnfPack("libstdc++-devel", undefined)
|
||||||
} else if (isUbuntu()) {
|
} else if (isUbuntu()) {
|
||||||
setupAptPack("gcc", version, ["ppa:ubuntu-toolchain-r/test"])
|
await setupAptPack("gcc", version, ["ppa:ubuntu-toolchain-r/test"])
|
||||||
installationInfo = setupAptPack("g++", version, [])
|
installationInfo = await setupAptPack("g++", version, [])
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
info(`Install g++-multilib because gcc for ${arch} was requested`)
|
info(`Install g++-multilib because gcc for ${arch} was requested`)
|
||||||
if (isArch()) {
|
if (isArch()) {
|
||||||
setupPacmanPack("gcc-multilib", version)
|
setupPacmanPack("gcc-multilib", version)
|
||||||
} else if (isUbuntu()) {
|
} else if (isUbuntu()) {
|
||||||
setupAptPack("gcc-multilib", version, ["ppa:ubuntu-toolchain-r/test"])
|
await setupAptPack("gcc-multilib", version, ["ppa:ubuntu-toolchain-r/test"])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
|
|
@ -41,7 +41,7 @@ async function buildKcov(file: string, dest: string) {
|
||||||
const out = await extractTarByExe(file, dest, ["--strip-components=1"])
|
const out = await extractTarByExe(file, dest, ["--strip-components=1"])
|
||||||
|
|
||||||
// build after extraction using CMake
|
// build after extraction using CMake
|
||||||
let cmake = await getCmake()
|
const cmake = await getCmake()
|
||||||
|
|
||||||
if (process.platform === "linux") {
|
if (process.platform === "linux") {
|
||||||
if (isArch()) {
|
if (isArch()) {
|
||||||
|
@ -51,8 +51,8 @@ async function buildKcov(file: string, dest: string) {
|
||||||
setupDnfPack("libdwarf-devel")
|
setupDnfPack("libdwarf-devel")
|
||||||
setupDnfPack("libcurl-devel")
|
setupDnfPack("libcurl-devel")
|
||||||
} else if (isUbuntu()) {
|
} else if (isUbuntu()) {
|
||||||
setupAptPack("libdw-dev")
|
await setupAptPack("libdw-dev")
|
||||||
setupAptPack("libcurl4-openssl-dev")
|
await setupAptPack("libcurl4-openssl-dev")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const buildDir = join(out, "build")
|
const buildDir = join(out, "build")
|
||||||
|
@ -72,7 +72,7 @@ async function getCmake() {
|
||||||
const { binDir } = await setupCmake(getVersion("cmake", undefined), join(untildify_user(""), "cmake"), "")
|
const { binDir } = await setupCmake(getVersion("cmake", undefined), join(untildify_user(""), "cmake"), "")
|
||||||
cmake = join(binDir, "cmake")
|
cmake = join(binDir, "cmake")
|
||||||
}
|
}
|
||||||
let ninja = which.sync("ninja", { nothrow: true })
|
const ninja = which.sync("ninja", { nothrow: true })
|
||||||
if (ninja === null) {
|
if (ninja === null) {
|
||||||
await setupNinja(getVersion("ninja", undefined), join(untildify_user(""), "ninja"), "")
|
await setupNinja(getVersion("ninja", undefined), join(untildify_user(""), "ninja"), "")
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ export async function setupKcov(versionGiven: string, setupDir: string, arch: st
|
||||||
} else if (hasDnf()) {
|
} else if (hasDnf()) {
|
||||||
setupDnfPack("binutils")
|
setupDnfPack("binutils")
|
||||||
} else if (isUbuntu()) {
|
} else if (isUbuntu()) {
|
||||||
setupAptPack("libbinutils")
|
await setupAptPack("libbinutils")
|
||||||
}
|
}
|
||||||
return installationInfo
|
return installationInfo
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -294,7 +294,7 @@ async function _setupLLVM(version: string, setupDir: string, arch: string) {
|
||||||
// setupPacmanPack("ncurses")
|
// setupPacmanPack("ncurses")
|
||||||
// TODO: install libtinfo ?
|
// TODO: install libtinfo ?
|
||||||
} else if (isUbuntu()) {
|
} else if (isUbuntu()) {
|
||||||
setupAptPack("libtinfo-dev")
|
await setupAptPack("libtinfo-dev")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line require-atomic-updates
|
// eslint-disable-next-line require-atomic-updates
|
||||||
|
|
|
@ -8,7 +8,7 @@ describe("setup-nala", () => {
|
||||||
if (!isUbuntu()) {
|
if (!isUbuntu()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const installInfo = setupNala("", "", process.arch)
|
const installInfo = await setupNala("", "", process.arch)
|
||||||
await testBin("nala", ["--version"], installInfo?.binDir)
|
await testBin("nala", ["--version"], installInfo?.binDir)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { setupAptPack } from "../utils/setup/setupAptPack"
|
||||||
let binDir: string | undefined
|
let binDir: string | undefined
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
export function setupNala(version: string, _setupDir: string, _arch: string) {
|
export async function setupNala(version: string, _setupDir: string, _arch: string) {
|
||||||
if (!isUbuntu()) {
|
if (!isUbuntu()) {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ export function setupNala(version: string, _setupDir: string, _arch: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://github.com/volitank/nala#-installation
|
// https://github.com/volitank/nala#-installation
|
||||||
setupAptPack("wget")
|
await setupAptPack("wget")
|
||||||
execSudo("/bin/bash", [
|
execSudo("/bin/bash", [
|
||||||
"-c",
|
"-c",
|
||||||
`wget -qO - https://deb.volian.org/volian/scar.key | tee /etc/apt/trusted.gpg.d/volian-archive-scar-unstable.gpg > /dev/null`,
|
`wget -qO - https://deb.volian.org/volian/scar.key | tee /etc/apt/trusted.gpg.d/volian-archive-scar-unstable.gpg > /dev/null`,
|
||||||
|
@ -34,15 +34,15 @@ export function setupNala(version: string, _setupDir: string, _arch: string) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (version !== "legacy") {
|
if (version !== "legacy") {
|
||||||
setupAptPack("nala", undefined, [], true)
|
await setupAptPack("nala", undefined, [], true)
|
||||||
} else {
|
} else {
|
||||||
setupAptPack("nala-legacy", undefined, [], true)
|
await setupAptPack("nala-legacy", undefined, [], true)
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setupAptPack("nala-legacy", undefined, [], true)
|
await setupAptPack("nala-legacy", undefined, [], true)
|
||||||
}
|
}
|
||||||
|
|
||||||
binDir = "/usr/bin"
|
binDir = "/usr/bin" // eslint-disable-line require-atomic-updates
|
||||||
|
|
||||||
return { binDir }
|
return { binDir }
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,8 +63,8 @@ export async function setupPythonViaSystem(
|
||||||
installInfo = setupDnfPack("python3", version)
|
installInfo = setupDnfPack("python3", version)
|
||||||
setupDnfPack("python3-pip")
|
setupDnfPack("python3-pip")
|
||||||
} else if (isUbuntu()) {
|
} else if (isUbuntu()) {
|
||||||
installInfo = setupAptPack("python3", version)
|
installInfo = await setupAptPack("python3", version)
|
||||||
setupAptPack("python3-pip")
|
await setupAptPack("python3-pip")
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`Unsupported linux distributions`)
|
throw new Error(`Unsupported linux distributions`)
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { isUbuntu } from "./isUbuntu"
|
||||||
export async function ubuntuVersion(): Promise<number[] | null> {
|
export async function ubuntuVersion(): Promise<number[] | null> {
|
||||||
if (isUbuntu()) {
|
if (isUbuntu()) {
|
||||||
if (which.sync("lsb_release", { nothrow: true }) === null) {
|
if (which.sync("lsb_release", { nothrow: true }) === null) {
|
||||||
setupAptPack("lsb-release")
|
await setupAptPack("lsb-release")
|
||||||
}
|
}
|
||||||
const versionSplitted = await getUbuntuVersion()
|
const versionSplitted = await getUbuntuVersion()
|
||||||
|
|
||||||
|
|
|
@ -12,15 +12,15 @@ let didUpdate: boolean = false
|
||||||
let didInit: boolean = false
|
let didInit: boolean = false
|
||||||
|
|
||||||
/** A function that installs a package using apt */
|
/** A function that installs a package using apt */
|
||||||
export function setupAptPack(
|
export async function setupAptPack(
|
||||||
name: string,
|
name: string,
|
||||||
version?: string,
|
version?: string,
|
||||||
repositories: string[] = [],
|
repositories: string[] = [],
|
||||||
update = false
|
update = false
|
||||||
): InstallationInfo {
|
): Promise<InstallationInfo> {
|
||||||
info(`Installing ${name} ${version ?? ""} via apt`)
|
info(`Installing ${name} ${version ?? ""} via apt`)
|
||||||
|
|
||||||
let apt: string = getApt()
|
const apt: string = getApt()
|
||||||
|
|
||||||
process.env.DEBIAN_FRONTEND = "noninteractive"
|
process.env.DEBIAN_FRONTEND = "noninteractive"
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ export function setupAptPack(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!didInit) {
|
if (!didInit) {
|
||||||
initApt(apt)
|
await initApt(apt)
|
||||||
didInit = true
|
didInit = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ function updateRepos(apt: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Install apt utils and certificates (usually missing from docker containers) */
|
/** Install apt utils and certificates (usually missing from docker containers) */
|
||||||
function initApt(apt: string) {
|
async function initApt(apt: string) {
|
||||||
execSudo(apt, [
|
execSudo(apt, [
|
||||||
"install",
|
"install",
|
||||||
"--fix-broken",
|
"--fix-broken",
|
||||||
|
@ -84,8 +84,8 @@ function initApt(apt: string) {
|
||||||
addAptKey(["1E9377A2BA9EF27F"], "setup-cpp-launchpad-toolchain.gpg")
|
addAptKey(["1E9377A2BA9EF27F"], "setup-cpp-launchpad-toolchain.gpg")
|
||||||
if (apt === "nala") {
|
if (apt === "nala") {
|
||||||
// enable utf8 otherwise it fails because of the usage of ASCII encoding
|
// enable utf8 otherwise it fails because of the usage of ASCII encoding
|
||||||
addEnv("LANG", "C.UTF-8")
|
await addEnv("LANG", "C.UTF-8")
|
||||||
addEnv("LC_ALL", "C.UTF-8")
|
await addEnv("LC_ALL", "C.UTF-8")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,8 +82,8 @@ export async function setupBin(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let installDir = join(setupDir, extractedFolderName)
|
const installDir = join(setupDir, extractedFolderName)
|
||||||
let binDir = join(installDir, binRelativeDir)
|
const binDir = join(installDir, binRelativeDir)
|
||||||
const binFile = join(binDir, binFileName)
|
const binFile = join(binDir, binFileName)
|
||||||
|
|
||||||
// download ane extract the package into the installation directory.
|
// download ane extract the package into the installation directory.
|
||||||
|
@ -102,9 +102,9 @@ export async function setupBin(
|
||||||
setupDnfPack("tar")
|
setupDnfPack("tar")
|
||||||
setupDnfPack("xz")
|
setupDnfPack("xz")
|
||||||
} else if (isUbuntu()) {
|
} else if (isUbuntu()) {
|
||||||
setupAptPack("unzip")
|
await setupAptPack("unzip")
|
||||||
setupAptPack("tar")
|
await setupAptPack("tar")
|
||||||
setupAptPack("xz-utils")
|
await setupAptPack("xz-utils")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line require-atomic-updates
|
// eslint-disable-next-line require-atomic-updates
|
||||||
|
|
|
@ -52,7 +52,7 @@ export async function setupPipPack(name: string, version?: string): Promise<Inst
|
||||||
} else if (hasDnf()) {
|
} else if (hasDnf()) {
|
||||||
setupDnfPack("python3-pip")
|
setupDnfPack("python3-pip")
|
||||||
} else if (isUbuntu()) {
|
} else if (isUbuntu()) {
|
||||||
setupAptPack("python3-pip")
|
await setupAptPack("python3-pip")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,12 +36,12 @@ export async function setupVcpkg(_version: string, setupDir: string, _arch: stri
|
||||||
setupDnfPack("git")
|
setupDnfPack("git")
|
||||||
setupDnfPack("pkg-config")
|
setupDnfPack("pkg-config")
|
||||||
} else if (isUbuntu()) {
|
} else if (isUbuntu()) {
|
||||||
setupAptPack("curl")
|
await setupAptPack("curl")
|
||||||
setupAptPack("zip")
|
await setupAptPack("zip")
|
||||||
setupAptPack("unzip")
|
await setupAptPack("unzip")
|
||||||
setupAptPack("tar")
|
await setupAptPack("tar")
|
||||||
setupAptPack("git")
|
await setupAptPack("git")
|
||||||
setupAptPack("pkg-config")
|
await setupAptPack("pkg-config")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue