Skip to content

Commit c8cec57

Browse files
committed
fix: handle the promises in setupAptPack
1 parent a9e484f commit c8cec57

File tree

16 files changed

+45
-45
lines changed

16 files changed

+45
-45
lines changed

dist/setup_cpp.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/setup_cpp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/setup_cpp.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dist/setup_cpp.mjs.map

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

src/doxygen/doxygen.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,18 @@ export async function setupDoxygen(version: string, setupDir: string, arch: stri
6767
} else if (hasDnf()) {
6868
return setupDnfPack("doxygen", version)
6969
} else if (isUbuntu()) {
70-
installationInfo = setupAptPack("doxygen", version)
70+
installationInfo = await setupAptPack("doxygen", version)
7171
} else {
7272
throw new Error(`Unsupported linux distributions`)
7373
}
7474
} else if (isUbuntu()) {
7575
try {
7676
// doxygen on stable Ubuntu repositories is very old. So, we use get the binary from the website itself
7777
installationInfo = await setupBin("doxygen", version, getDoxygenPackageInfo, setupDir, arch)
78-
setupAptPack("libclang-cpp9")
78+
await setupAptPack("libclang-cpp9")
7979
} catch (err) {
8080
notice(`Failed to download doxygen binary. ${err}. Falling back to apt-get.`)
81-
installationInfo = setupAptPack("doxygen", undefined)
81+
installationInfo = await setupAptPack("doxygen", undefined)
8282
}
8383
} else {
8484
throw new Error(`Unsupported linux distributions`)

src/gcc/gcc.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,15 @@ export async function setupGcc(version: string, setupDir: string, arch: string)
9191
setupDnfPack("gcc-c++", version)
9292
setupDnfPack("libstdc++-devel", undefined)
9393
} else if (isUbuntu()) {
94-
setupAptPack("gcc", version, ["ppa:ubuntu-toolchain-r/test"])
95-
installationInfo = setupAptPack("g++", version, [])
94+
await setupAptPack("gcc", version, ["ppa:ubuntu-toolchain-r/test"])
95+
installationInfo = await setupAptPack("g++", version, [])
9696
}
9797
} else {
9898
info(`Install g++-multilib because gcc for ${arch} was requested`)
9999
if (isArch()) {
100100
setupPacmanPack("gcc-multilib", version)
101101
} else if (isUbuntu()) {
102-
setupAptPack("gcc-multilib", version, ["ppa:ubuntu-toolchain-r/test"])
102+
await setupAptPack("gcc-multilib", version, ["ppa:ubuntu-toolchain-r/test"])
103103
}
104104
}
105105
break

src/kcov/kcov.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async function buildKcov(file: string, dest: string) {
4141
const out = await extractTarByExe(file, dest, ["--strip-components=1"])
4242

4343
// build after extraction using CMake
44-
let cmake = await getCmake()
44+
const cmake = await getCmake()
4545

4646
if (process.platform === "linux") {
4747
if (isArch()) {
@@ -51,8 +51,8 @@ async function buildKcov(file: string, dest: string) {
5151
setupDnfPack("libdwarf-devel")
5252
setupDnfPack("libcurl-devel")
5353
} else if (isUbuntu()) {
54-
setupAptPack("libdw-dev")
55-
setupAptPack("libcurl4-openssl-dev")
54+
await setupAptPack("libdw-dev")
55+
await setupAptPack("libcurl4-openssl-dev")
5656
}
5757
}
5858
const buildDir = join(out, "build")
@@ -72,7 +72,7 @@ async function getCmake() {
7272
const { binDir } = await setupCmake(getVersion("cmake", undefined), join(untildify_user(""), "cmake"), "")
7373
cmake = join(binDir, "cmake")
7474
}
75-
let ninja = which.sync("ninja", { nothrow: true })
75+
const ninja = which.sync("ninja", { nothrow: true })
7676
if (ninja === null) {
7777
await setupNinja(getVersion("ninja", undefined), join(untildify_user(""), "ninja"), "")
7878
}
@@ -103,7 +103,7 @@ export async function setupKcov(versionGiven: string, setupDir: string, arch: st
103103
} else if (hasDnf()) {
104104
setupDnfPack("binutils")
105105
} else if (isUbuntu()) {
106-
setupAptPack("libbinutils")
106+
await setupAptPack("libbinutils")
107107
}
108108
return installationInfo
109109
} else {

src/llvm/llvm.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ async function _setupLLVM(version: string, setupDir: string, arch: string) {
294294
// setupPacmanPack("ncurses")
295295
// TODO: install libtinfo ?
296296
} else if (isUbuntu()) {
297-
setupAptPack("libtinfo-dev")
297+
await setupAptPack("libtinfo-dev")
298298
}
299299
}
300300
// eslint-disable-next-line require-atomic-updates

src/nala/__tests__/nala.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ describe("setup-nala", () => {
88
if (!isUbuntu()) {
99
return
1010
}
11-
const installInfo = setupNala("", "", process.arch)
11+
const installInfo = await setupNala("", "", process.arch)
1212
await testBin("nala", ["--version"], installInfo?.binDir)
1313
})
1414
})

src/nala/nala.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { setupAptPack } from "../utils/setup/setupAptPack"
77
let binDir: string | undefined
88

99
// eslint-disable-next-line @typescript-eslint/no-unused-vars
10-
export function setupNala(version: string, _setupDir: string, _arch: string) {
10+
export async function setupNala(version: string, _setupDir: string, _arch: string) {
1111
if (!isUbuntu()) {
1212
return undefined
1313
}
@@ -22,7 +22,7 @@ export function setupNala(version: string, _setupDir: string, _arch: string) {
2222
}
2323

2424
// https://github.com/volitank/nala#-installation
25-
setupAptPack("wget")
25+
await setupAptPack("wget")
2626
execSudo("/bin/bash", [
2727
"-c",
2828
`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) {
3434

3535
try {
3636
if (version !== "legacy") {
37-
setupAptPack("nala", undefined, [], true)
37+
await setupAptPack("nala", undefined, [], true)
3838
} else {
39-
setupAptPack("nala-legacy", undefined, [], true)
39+
await setupAptPack("nala-legacy", undefined, [], true)
4040
}
4141
} catch (err) {
42-
setupAptPack("nala-legacy", undefined, [], true)
42+
await setupAptPack("nala-legacy", undefined, [], true)
4343
}
4444

45-
binDir = "/usr/bin"
45+
binDir = "/usr/bin" // eslint-disable-line require-atomic-updates
4646

4747
return { binDir }
4848
}

src/python/python.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ export async function setupPythonViaSystem(
6363
installInfo = setupDnfPack("python3", version)
6464
setupDnfPack("python3-pip")
6565
} else if (isUbuntu()) {
66-
installInfo = setupAptPack("python3", version)
67-
setupAptPack("python3-pip")
66+
installInfo = await setupAptPack("python3", version)
67+
await setupAptPack("python3-pip")
6868
} else {
6969
throw new Error(`Unsupported linux distributions`)
7070
}

src/utils/env/ubuntu_version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { isUbuntu } from "./isUbuntu"
66
export async function ubuntuVersion(): Promise<number[] | null> {
77
if (isUbuntu()) {
88
if (which.sync("lsb_release", { nothrow: true }) === null) {
9-
setupAptPack("lsb-release")
9+
await setupAptPack("lsb-release")
1010
}
1111
const versionSplitted = await getUbuntuVersion()
1212

src/utils/setup/setupAptPack.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ let didUpdate: boolean = false
1212
let didInit: boolean = false
1313

1414
/** A function that installs a package using apt */
15-
export function setupAptPack(
15+
export async function setupAptPack(
1616
name: string,
1717
version?: string,
1818
repositories: string[] = [],
1919
update = false
20-
): InstallationInfo {
20+
): Promise<InstallationInfo> {
2121
info(`Installing ${name} ${version ?? ""} via apt`)
2222

23-
let apt: string = getApt()
23+
const apt: string = getApt()
2424

2525
process.env.DEBIAN_FRONTEND = "noninteractive"
2626

@@ -30,7 +30,7 @@ export function setupAptPack(
3030
}
3131

3232
if (!didInit) {
33-
initApt(apt)
33+
await initApt(apt)
3434
didInit = true
3535
}
3636

@@ -70,7 +70,7 @@ function updateRepos(apt: string) {
7070
}
7171

7272
/** Install apt utils and certificates (usually missing from docker containers) */
73-
function initApt(apt: string) {
73+
async function initApt(apt: string) {
7474
execSudo(apt, [
7575
"install",
7676
"--fix-broken",
@@ -84,8 +84,8 @@ function initApt(apt: string) {
8484
addAptKey(["1E9377A2BA9EF27F"], "setup-cpp-launchpad-toolchain.gpg")
8585
if (apt === "nala") {
8686
// enable utf8 otherwise it fails because of the usage of ASCII encoding
87-
addEnv("LANG", "C.UTF-8")
88-
addEnv("LC_ALL", "C.UTF-8")
87+
await addEnv("LANG", "C.UTF-8")
88+
await addEnv("LC_ALL", "C.UTF-8")
8989
}
9090
}
9191

src/utils/setup/setupBin.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ export async function setupBin(
8282
}
8383
}
8484

85-
let installDir = join(setupDir, extractedFolderName)
86-
let binDir = join(installDir, binRelativeDir)
85+
const installDir = join(setupDir, extractedFolderName)
86+
const binDir = join(installDir, binRelativeDir)
8787
const binFile = join(binDir, binFileName)
8888

8989
// download ane extract the package into the installation directory.
@@ -102,9 +102,9 @@ export async function setupBin(
102102
setupDnfPack("tar")
103103
setupDnfPack("xz")
104104
} else if (isUbuntu()) {
105-
setupAptPack("unzip")
106-
setupAptPack("tar")
107-
setupAptPack("xz-utils")
105+
await setupAptPack("unzip")
106+
await setupAptPack("tar")
107+
await setupAptPack("xz-utils")
108108
}
109109
}
110110
// eslint-disable-next-line require-atomic-updates

src/utils/setup/setupPipPack.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export async function setupPipPack(name: string, version?: string): Promise<Inst
5252
} else if (hasDnf()) {
5353
setupDnfPack("python3-pip")
5454
} else if (isUbuntu()) {
55-
setupAptPack("python3-pip")
55+
await setupAptPack("python3-pip")
5656
}
5757
}
5858

src/vcpkg/vcpkg.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ export async function setupVcpkg(_version: string, setupDir: string, _arch: stri
3636
setupDnfPack("git")
3737
setupDnfPack("pkg-config")
3838
} else if (isUbuntu()) {
39-
setupAptPack("curl")
40-
setupAptPack("zip")
41-
setupAptPack("unzip")
42-
setupAptPack("tar")
43-
setupAptPack("git")
44-
setupAptPack("pkg-config")
39+
await setupAptPack("curl")
40+
await setupAptPack("zip")
41+
await setupAptPack("unzip")
42+
await setupAptPack("tar")
43+
await setupAptPack("git")
44+
await setupAptPack("pkg-config")
4545
}
4646
}
4747

0 commit comments

Comments
 (0)