mirror of https://github.com/aminya/setup-cpp
fix!: only support a single repository/key for each apt package
BREAKING the option for repositories/keys are now singular instead of an array
This commit is contained in:
parent
2032957802
commit
adb1af1e17
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -109,10 +109,8 @@ await installAptPack([
|
||||||
{
|
{
|
||||||
name: "gcc",
|
name: "gcc",
|
||||||
version,
|
version,
|
||||||
repositories: ["ppa:ubuntu-toolchain-r/test"],
|
repository: "ppa:ubuntu-toolchain-r/test",
|
||||||
addAptKey: [
|
key: { key: "1E9377A2BA9EF27F", fileName: "ubuntu-toolchain-r-test.gpg" },
|
||||||
{ keys: ["1E9377A2BA9EF27F"], fileName: "ubuntu-toolchain-r-test.gpg" },
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
```
|
```
|
||||||
|
@ -154,7 +152,7 @@ Add an apt key
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
await addAptKey({
|
await addAptKey({
|
||||||
keys: ["3B4FE6ACC0B21F32", "40976EAF437D05B5"],
|
key: "3B4FE6ACC0B21F32"
|
||||||
fileName: "bazel-archive-keyring.gpg",
|
fileName: "bazel-archive-keyring.gpg",
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
@ -178,7 +176,7 @@ Add an apt key via a keyserver
|
||||||
|
|
||||||
**Parameters:**
|
**Parameters:**
|
||||||
|
|
||||||
- { keys, keyServer = defaultKeyServer, fileName, keyStorePath = defaultKeyServer } (`KeyServerOptions`)
|
- { key, keyServer = defaultKeyServer, fileName, keyStorePath = defaultKeyServer } (`KeyServerOptions`)
|
||||||
|
|
||||||
**returns:** Promise<string>
|
**returns:** Promise<string>
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ export type AddAptKeyOptions = KeyServerOptions | KeyUrl
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
* await addAptKey({ keys: ["3B4FE6ACC0B21F32", "40976EAF437D05B5"], fileName: "bazel-archive-keyring.gpg"})
|
* await addAptKey({ key: "3B4FE6ACC0B21F32" fileName: "bazel-archive-keyring.gpg"})
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
|
@ -46,14 +46,14 @@ export const defaultKeyStorePath = "/etc/apt/trusted.gpg.d"
|
||||||
|
|
||||||
export type KeyServerOptions = {
|
export type KeyServerOptions = {
|
||||||
/**
|
/**
|
||||||
* The keys to add
|
* The key to add
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
* ["3B4FE6ACC0B21F32", "40976EAF437D05B5"]
|
* "3B4FE6ACC0B21F32"
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
keys: string[]
|
key: string
|
||||||
/**
|
/**
|
||||||
* The keyserver to use (Defaults to `keyserver.ubuntu.com`)
|
* The keyserver to use (Defaults to `keyserver.ubuntu.com`)
|
||||||
*/
|
*/
|
||||||
|
@ -67,7 +67,7 @@ export const defaultKeyServer = "keyserver.ubuntu.com"
|
||||||
* @returns The file name of the key that was added or `undefined` if it failed
|
* @returns The file name of the key that was added or `undefined` if it failed
|
||||||
*/
|
*/
|
||||||
export async function addAptKeyViaServer(
|
export async function addAptKeyViaServer(
|
||||||
{ keys, keyServer = defaultKeyServer, fileName, keyStorePath = defaultKeyServer }: KeyServerOptions,
|
{ key, keyServer = defaultKeyServer, fileName, keyStorePath = defaultKeyServer }: KeyServerOptions,
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
assertGpgFileName(fileName)
|
assertGpgFileName(fileName)
|
||||||
|
@ -75,20 +75,16 @@ export async function addAptKeyViaServer(
|
||||||
if (!(await pathExists(filePath))) {
|
if (!(await pathExists(filePath))) {
|
||||||
initGpg()
|
initGpg()
|
||||||
|
|
||||||
await Promise.all(
|
await execRoot("gpg", [
|
||||||
keys.map(async (key) => {
|
"--no-default-keyring",
|
||||||
await execRoot("gpg", [
|
"--keyring",
|
||||||
"--no-default-keyring",
|
`gnupg-ring:${filePath}`,
|
||||||
"--keyring",
|
"--keyserver",
|
||||||
`gnupg-ring:${filePath}`,
|
keyServer,
|
||||||
"--keyserver",
|
"--recv-keys",
|
||||||
keyServer,
|
key,
|
||||||
"--recv-keys",
|
])
|
||||||
key,
|
await execRoot("chmod", ["644", filePath])
|
||||||
])
|
|
||||||
await execRoot("chmod", ["644", filePath])
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
return filePath
|
return filePath
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
|
@ -38,10 +38,10 @@ export type AptPackage = {
|
||||||
name: string
|
name: string
|
||||||
/** The version of the package (optional) */
|
/** The version of the package (optional) */
|
||||||
version?: string
|
version?: string
|
||||||
/** The repositories to add before installing the package (optional) */
|
/** The repository to add before installing the package (optional) */
|
||||||
repositories?: string[]
|
repository?: string
|
||||||
/** The keys to add before installing the package (optional) */
|
/** The key to add before installing the package (optional) */
|
||||||
addAptKey?: AddAptKeyOptions[]
|
key?: AddAptKeyOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
const retryErrors = [
|
const retryErrors = [
|
||||||
|
@ -69,8 +69,8 @@ const retryErrors = [
|
||||||
{
|
{
|
||||||
name: "gcc",
|
name: "gcc",
|
||||||
version,
|
version,
|
||||||
repositories: ["ppa:ubuntu-toolchain-r/test"],
|
repository: "ppa:ubuntu-toolchain-r/test",
|
||||||
addAptKey: [{ keys: ["1E9377A2BA9EF27F"], fileName: "ubuntu-toolchain-r-test.gpg" }],
|
key: { key: "1E9377A2BA9EF27F", fileName: "ubuntu-toolchain-r-test.gpg" },
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
* ```
|
* ```
|
||||||
|
@ -133,8 +133,8 @@ export async function installAptPack(packages: AptPackage[], update = false): Pr
|
||||||
|
|
||||||
async function addAptKeys(packages: AptPackage[]) {
|
async function addAptKeys(packages: AptPackage[]) {
|
||||||
await Promise.all(packages.map(async (pack) => {
|
await Promise.all(packages.map(async (pack) => {
|
||||||
if (pack.addAptKey !== undefined) {
|
if (pack.key !== undefined) {
|
||||||
await Promise.all(pack.addAptKey.map(addAptKey))
|
await addAptKey(pack.key)
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
@ -211,7 +211,7 @@ async function qualifiedNeededAptPackage(apt: string, pack: AptPackage) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function addRepositories(apt: string, packages: AptPackage[]) {
|
async function addRepositories(apt: string, packages: AptPackage[]) {
|
||||||
const allRepositories = [...new Set(packages.flatMap((pack) => pack.repositories ?? []))]
|
const allRepositories = [...new Set(packages.flatMap((pack) => pack.repository ?? []))]
|
||||||
if (allRepositories.length !== 0) {
|
if (allRepositories.length !== 0) {
|
||||||
if (!didInit) {
|
if (!didInit) {
|
||||||
await initApt(apt)
|
await initApt(apt)
|
||||||
|
|
|
@ -114,14 +114,14 @@ export async function setupGcc(version: string, setupDir: string, arch: string,
|
||||||
{
|
{
|
||||||
name: "gcc",
|
name: "gcc",
|
||||||
version,
|
version,
|
||||||
repositories: ["ppa:ubuntu-toolchain-r/test"],
|
repository: "ppa:ubuntu-toolchain-r/test",
|
||||||
addAptKey: [{ keys: ["1E9377A2BA9EF27F"], fileName: "ubuntu-toolchain-r-test.gpg" }],
|
key: { key: "1E9377A2BA9EF27F", fileName: "ubuntu-toolchain-r-test.gpg" },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "g++",
|
name: "g++",
|
||||||
version,
|
version,
|
||||||
repositories: ["ppa:ubuntu-toolchain-r/test"],
|
repository: "ppa:ubuntu-toolchain-r/test",
|
||||||
addAptKey: [{ keys: ["1E9377A2BA9EF27F"], fileName: "ubuntu-toolchain-r-test.gpg" }],
|
key: { key: "1E9377A2BA9EF27F", fileName: "ubuntu-toolchain-r-test.gpg" },
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
@ -133,8 +133,8 @@ export async function setupGcc(version: string, setupDir: string, arch: string,
|
||||||
await installAptPack([{
|
await installAptPack([{
|
||||||
name: "gcc-multilib",
|
name: "gcc-multilib",
|
||||||
version,
|
version,
|
||||||
repositories: ["ppa:ubuntu-toolchain-r/test"],
|
repository: "ppa:ubuntu-toolchain-r/test",
|
||||||
addAptKey: [{ keys: ["1E9377A2BA9EF27F"], fileName: "ubuntu-toolchain-r-test.gpg" }],
|
key: { key: "1E9377A2BA9EF27F", fileName: "ubuntu-toolchain-r-test.gpg" },
|
||||||
}])
|
}])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -180,8 +180,8 @@ export async function setupMingw(version: string, setupDir: string, arch: string
|
||||||
{
|
{
|
||||||
name: "mingw-w64",
|
name: "mingw-w64",
|
||||||
version,
|
version,
|
||||||
repositories: ["ppa:ubuntu-toolchain-r/test"],
|
repository: "ppa:ubuntu-toolchain-r/test",
|
||||||
addAptKey: [{ keys: ["1E9377A2BA9EF27F"], fileName: "ubuntu-toolchain-r-test.gpg" }],
|
key: { key: "1E9377A2BA9EF27F", fileName: "ubuntu-toolchain-r-test.gpg" },
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue