fix: use gpg instead of apt-key

This commit is contained in:
Amin Yahyaabadi 2022-07-27 18:10:40 -07:00
parent 2915ec8f01
commit d195a02a1d
5 changed files with 27 additions and 12 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

@ -5,7 +5,7 @@ import { info } from "@actions/core"
import { warning } from "../io/io"
import { isGitHubCI } from "../env/isCI"
import { addEnv, cpprc_path, setupCppInProfile } from "../env/addEnv"
import { appendFileSync } from "fs"
import { appendFileSync, existsSync } from "fs"
import which from "which"
let didUpdate: boolean = false
@ -80,13 +80,8 @@ function initApt(apt: string) {
"ca-certificates",
"gnupg",
])
try {
execSudo("apt-key", ["adv", "--keyserver", "keyserver.ubuntu.com", "--recv-keys", "3B4FE6ACC0B21F32"])
execSudo("apt-key", ["adv", "--keyserver", "keyserver.ubuntu.com", "--recv-keys", "40976EAF437D05B5"])
execSudo("apt-key", ["adv", "--keyserver", "keyserver.ubuntu.com", "--recv-keys", "1E9377A2BA9EF27F"])
} catch (err) {
warning(`Failed to add keys: ${err}`)
}
addAptKey(["3B4FE6ACC0B21F32", "40976EAF437D05B5"], "setup-cpp-ubuntu-archive.gpg")
addAptKey(["1E9377A2BA9EF27F"], "setup-cpp-launchpad-toolchain.gpg")
if (apt === "nala") {
// enable utf8 otherwise it fails because of the usage of ASCII encoding
addEnv("LANG", "C.UTF-8")
@ -94,6 +89,26 @@ function initApt(apt: string) {
}
}
function addAptKey(keys: string[], name: string) {
try {
if (!existsSync(`/root/.gnupg/${name}`)) {
for (const key of keys) {
execSudo("gpg", [
"--no-default-keyring",
"--keyring",
name,
"--keyserver",
"keyserver.ubuntu.com",
"--recv-keys",
key,
])
}
}
} catch (err) {
warning(`Failed to add keys: ${err}`)
}
}
export function updateAptAlternatives(name: string, path: string) {
if (isGitHubCI()) {
return execSudo("update-alternatives", ["--install", `/usr/bin/${name}`, name, path, "40"])