Skip to content

Commit 8fb789d

Browse files
authored
Merge pull request #110 from aminya/space-name [skip ci]
2 parents 79079b9 + d195a02 commit 8fb789d

File tree

6 files changed

+31
-15
lines changed

6 files changed

+31
-15
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/env/addEnv.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@ async function addPathSystem(path: string) {
7979
await execPowershell(
8080
`$USER_PATH=([Environment]::GetEnvironmentVariable("PATH", "User")); [Environment]::SetEnvironmentVariable("PATH", "${path};$USER_PATH", "User")`
8181
)
82-
info(`${path} was added to the PATH.`)
82+
info(`"${path}" was added to the PATH.`)
8383
return
8484
}
8585
case "linux":
8686
case "darwin": {
8787
setupCppInProfile()
88-
appendFileSync(cpprc_path, `\nexport PATH=${path}:$PATH\n`)
89-
info(`${path} was added to "${cpprc_path}"`)
88+
appendFileSync(cpprc_path, `\nexport PATH="${path}:$PATH"\n`)
89+
info(`"${path}" was added to "${cpprc_path}"`)
9090
return
9191
}
9292
default: {

src/utils/setup/setupAptPack.ts

Lines changed: 24 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
@@ -59,10 +59,6 @@ function getApt() {
5959
let apt: string
6060
if (which.sync("nala", { nothrow: true }) !== null) {
6161
apt = "nala"
62-
63-
// enable utf8 otherwise it fails because of the usage of ASCII encoding
64-
addEnv("LANG", "C.UTF-8")
65-
addEnv("LC_ALL", "C.UTF-8")
6662
} else {
6763
apt = "apt-get"
6864
}
@@ -84,10 +80,30 @@ function initApt(apt: string) {
8480
"ca-certificates",
8581
"gnupg",
8682
])
83+
addAptKey(["3B4FE6ACC0B21F32", "40976EAF437D05B5"], "setup-cpp-ubuntu-archive.gpg")
84+
addAptKey(["1E9377A2BA9EF27F"], "setup-cpp-launchpad-toolchain.gpg")
85+
if (apt === "nala") {
86+
// enable utf8 otherwise it fails because of the usage of ASCII encoding
87+
addEnv("LANG", "C.UTF-8")
88+
addEnv("LC_ALL", "C.UTF-8")
89+
}
90+
}
91+
92+
function addAptKey(keys: string[], name: string) {
8793
try {
88-
execSudo("apt-key", ["adv", "--keyserver", "keyserver.ubuntu.com", "--recv-keys", "3B4FE6ACC0B21F32"])
89-
execSudo("apt-key", ["adv", "--keyserver", "keyserver.ubuntu.com", "--recv-keys", "40976EAF437D05B5"])
90-
execSudo("apt-key", ["adv", "--keyserver", "keyserver.ubuntu.com", "--recv-keys", "1E9377A2BA9EF27F"])
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+
}
91107
} catch (err) {
92108
warning(`Failed to add keys: ${err}`)
93109
}

0 commit comments

Comments
 (0)