Skip to content

Commit 67a5cc5

Browse files
committed
fix: do not pani on addAptKey server errors
1 parent 201ecd0 commit 67a5cc5

File tree

5 files changed

+28
-23
lines changed

5 files changed

+28
-23
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: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -123,26 +123,31 @@ function initGpg() {
123123
}
124124

125125
export async function addAptKeyViaServer(keys: string[], name: string, server = "keyserver.ubuntu.com") {
126-
const fileName = `/etc/apt/trusted.gpg.d/${name}`
127-
if (!(await pathExists(fileName))) {
128-
initGpg()
129-
130-
await Promise.all(
131-
keys.map(async (key) => {
132-
await execRoot("gpg", [
133-
"--no-default-keyring",
134-
"--keyring",
135-
`gnupg-ring:${fileName}`,
136-
"--keyserver",
137-
server,
138-
"--recv-keys",
139-
key,
140-
])
141-
await execRoot("chmod", ["644", fileName])
142-
})
143-
)
126+
try {
127+
const fileName = `/etc/apt/trusted.gpg.d/${name}`
128+
if (!(await pathExists(fileName))) {
129+
initGpg()
130+
131+
await Promise.all(
132+
keys.map(async (key) => {
133+
await execRoot("gpg", [
134+
"--no-default-keyring",
135+
"--keyring",
136+
`gnupg-ring:${fileName}`,
137+
"--keyserver",
138+
server,
139+
"--recv-keys",
140+
key,
141+
])
142+
await execRoot("chmod", ["644", fileName])
143+
})
144+
)
145+
}
146+
return fileName
147+
} catch (err) {
148+
warning(`Failed to add apt key via server ${server}: ${err}`)
149+
return undefined
144150
}
145-
return fileName
146151
}
147152

148153
export async function addAptKeyViaDownload(name: string, url: string) {

0 commit comments

Comments
 (0)