Skip to content

Commit 757782e

Browse files
committed
fix: parallelize initApt
1 parent 5528c08 commit 757782e

File tree

5 files changed

+25
-21
lines changed

5 files changed

+25
-21
lines changed

dist/node12/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/node12/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/node16/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/node16/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.

src/utils/setup/setupAptPack.ts

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ export async function setupAptPack(packages: AptPackage[], update = false): Prom
5959

6060
async function getAptArg(name: string, version: string | undefined) {
6161
if (version !== undefined && version !== "") {
62-
console.log(`^${escapeRegex(`${name}-${version}`)}$`)
6362
const { stdout } = await execa("apt-cache", [
6463
"search",
6564
"--names-only",
@@ -100,13 +99,15 @@ async function initApt(apt: string) {
10099
"ca-certificates",
101100
"gnupg",
102101
])
103-
await addAptKeyViaServer(["3B4FE6ACC0B21F32", "40976EAF437D05B5"], "setup-cpp-ubuntu-archive.gpg")
104-
await addAptKeyViaServer(["1E9377A2BA9EF27F"], "launchpad-toolchain.gpg")
102+
const promises: Promise<any>[] = [
103+
addAptKeyViaServer(["3B4FE6ACC0B21F32", "40976EAF437D05B5"], "setup-cpp-ubuntu-archive.gpg"),
104+
addAptKeyViaServer(["1E9377A2BA9EF27F"], "launchpad-toolchain.gpg"),
105+
]
105106
if (apt === "nala") {
106107
// enable utf8 otherwise it fails because of the usage of ASCII encoding
107-
await addEnv("LANG", "C.UTF-8")
108-
await addEnv("LC_ALL", "C.UTF-8")
108+
promises.push(addEnv("LANG", "C.UTF-8"), addEnv("LC_ALL", "C.UTF-8"))
109109
}
110+
await Promise.all(promises)
110111
}
111112

112113
function initGpg() {
@@ -117,18 +118,21 @@ export async function addAptKeyViaServer(keys: string[], name: string, server =
117118
const fileName = `/etc/apt/trusted.gpg.d/${name}`
118119
if (!(await pathExists(fileName))) {
119120
initGpg()
120-
for (const key of keys) {
121-
execRootSync("gpg", [
122-
"--no-default-keyring",
123-
"--keyring",
124-
`gnupg-ring:${fileName}`,
125-
"--keyserver",
126-
server,
127-
"--recv-keys",
128-
key,
129-
])
130-
execRootSync("chmod", ["644", fileName])
131-
}
121+
122+
await Promise.all(
123+
keys.map(async (key) => {
124+
await execRoot("gpg", [
125+
"--no-default-keyring",
126+
"--keyring",
127+
`gnupg-ring:${fileName}`,
128+
"--keyserver",
129+
server,
130+
"--recv-keys",
131+
key,
132+
])
133+
await execRoot("chmod", ["644", fileName])
134+
})
135+
)
132136
}
133137
return fileName
134138
}

0 commit comments

Comments
 (0)