fix: init gpg before adding the keys

This commit is contained in:
Amin Yahyaabadi 2022-07-27 20:30:15 -07:00
parent fb111ffcf1
commit 9da09a7595
5 changed files with 10 additions and 4 deletions

2
dist/setup_cpp.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/setup_cpp.mjs vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -88,9 +88,14 @@ async function initApt(apt: string) {
}
}
function initGpg() {
execSudo("gpg", ["-k"])
}
export function addAptKeyViaServer(keys: string[], name: string, server = "keyserver.ubuntu.com") {
const fileName = `/etc/apt/trusted.gpg.d/${name}`
if (!existsSync(fileName)) {
initGpg()
for (const key of keys) {
execSudo("gpg", [
"--no-default-keyring",
@ -110,6 +115,7 @@ export function addAptKeyViaServer(keys: string[], name: string, server = "keyse
export async function addAptKeyViaDownload(name: string, url: string) {
const fileName = `/etc/apt/trusted.gpg.d/${name}`
if (!existsSync(fileName)) {
initGpg()
await setupAptPack("curl", undefined)
execSudo("bash", ["-c", `curl -s ${url} | gpg --no-default-keyring --keyring gnupg-ring:${fileName} --import`])
execSudo("chmod", ["644", fileName])