Skip to content

Commit d195a02

Browse files
committed
fix: use gpg instead of apt-key
1 parent 2915ec8 commit d195a02

File tree

5 files changed

+27
-12
lines changed

5 files changed

+27
-12
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/utils/setup/setupAptPack.ts

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { info } from "@actions/core"
55
import { warning } from "../io/io"
66
import { isGitHubCI } from "../env/isCI"
77
import { addEnv, cpprc_path, setupCppInProfile } from "../env/addEnv"
8-
import { appendFileSync } from "fs"
8+
import { appendFileSync, existsSync } from "fs"
99
import which from "which"
1010

1111
let didUpdate: boolean = false
@@ -80,20 +80,35 @@ function initApt(apt: string) {
8080
"ca-certificates",
8181
"gnupg",
8282
])
83-
try {
84-
execSudo("apt-key", ["adv", "--keyserver", "keyserver.ubuntu.com", "--recv-keys", "3B4FE6ACC0B21F32"])
85-
execSudo("apt-key", ["adv", "--keyserver", "keyserver.ubuntu.com", "--recv-keys", "40976EAF437D05B5"])
86-
execSudo("apt-key", ["adv", "--keyserver", "keyserver.ubuntu.com", "--recv-keys", "1E9377A2BA9EF27F"])
87-
} catch (err) {
88-
warning(`Failed to add keys: ${err}`)
89-
}
83+
addAptKey(["3B4FE6ACC0B21F32", "40976EAF437D05B5"], "setup-cpp-ubuntu-archive.gpg")
84+
addAptKey(["1E9377A2BA9EF27F"], "setup-cpp-launchpad-toolchain.gpg")
9085
if (apt === "nala") {
9186
// enable utf8 otherwise it fails because of the usage of ASCII encoding
9287
addEnv("LANG", "C.UTF-8")
9388
addEnv("LC_ALL", "C.UTF-8")
9489
}
9590
}
9691

92+
function addAptKey(keys: string[], name: string) {
93+
try {
94+
if (!existsSync(`/root/.gnupg/${name}`)) {
95+
for (const key of keys) {
96+
execSudo("gpg", [
97+
"--no-default-keyring",
98+
"--keyring",
99+
name,
100+
"--keyserver",
101+
"keyserver.ubuntu.com",
102+
"--recv-keys",
103+
key,
104+
])
105+
}
106+
}
107+
} catch (err) {
108+
warning(`Failed to add keys: ${err}`)
109+
}
110+
}
111+
97112
export function updateAptAlternatives(name: string, path: string) {
98113
if (isGitHubCI()) {
99114
return execSudo("update-alternatives", ["--install", `/usr/bin/${name}`, name, path, "40"])

0 commit comments

Comments
 (0)