2024-08-16 17:01:51 +08:00
|
|
|
<h1 align="center">setup-apt</h1>
|
|
|
|
<p>
|
2024-08-24 06:20:37 +08:00
|
|
|
<a href="https://www.npmjs.com/package/setup-apt" target="_blank">
|
|
|
|
<img alt="Version" src="https://img.shields.io/npm/v/setup-apt.svg">
|
|
|
|
</a>
|
2024-08-16 17:01:51 +08:00
|
|
|
<img src="https://img.shields.io/badge/node-%3E%3D12-blue.svg" />
|
|
|
|
<a href="#" target="_blank">
|
|
|
|
<img alt="License: Apache--2.0" src="https://img.shields.io/badge/License-Apache--2.0-yellow.svg" />
|
|
|
|
</a>
|
|
|
|
</p>
|
|
|
|
|
|
|
|
> Setup apt packages and repositories in Debian/Ubuntu-based distributions
|
|
|
|
|
|
|
|
## Install
|
|
|
|
|
|
|
|
```sh
|
|
|
|
npm install --save setup-apt
|
|
|
|
```
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
<!-- INSERT GENERATED DOCS START -->
|
|
|
|
|
2024-08-16 17:13:47 +08:00
|
|
|
### `updateAptAlternatives` (function)
|
|
|
|
|
|
|
|
Update the alternatives for a package
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
- name (`string`) - The name of the package
|
|
|
|
- path (`string`) - The path to the binary
|
|
|
|
- priority (`number`) - The priority of the alternative (Defaults to `40`)
|
|
|
|
|
|
|
|
**returns:** Promise<void>
|
|
|
|
|
|
|
|
### `addUpdateAlternativesToRc` (function)
|
|
|
|
|
|
|
|
Add the update-alternatives command to the rc file
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
- name (`string`) - The name of the package
|
|
|
|
- path (`string`) - The path to the binary
|
|
|
|
- rcOptions (`RcOptions`) - The options for the rc file to add the update-alternatives command to
|
|
|
|
- priority (`number`) - The priority of the alternative (Defaults to `40`)
|
|
|
|
|
|
|
|
**returns:** Promise<void>
|
|
|
|
|
2024-09-03 15:16:55 +08:00
|
|
|
### `getAptEnv` (function)
|
|
|
|
|
|
|
|
Get the environment variables to use for the apt command
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
- apt (`string`) - The apt command to use
|
|
|
|
|
|
|
|
**returns:** ProcessEnv
|
|
|
|
|
|
|
|
### `aptTimeout` (variable)
|
|
|
|
|
|
|
|
The timeout to use for apt commands
|
|
|
|
Wait up to 300 seconds if the apt-get lock is held
|
|
|
|
|
|
|
|
### `hasNala` (function)
|
|
|
|
|
|
|
|
Check if nala is installed
|
|
|
|
|
|
|
|
**returns:** boolean
|
|
|
|
|
|
|
|
### `getApt` (function)
|
|
|
|
|
|
|
|
Get the apt command to use
|
|
|
|
If nala is installed, use that, otherwise use apt-get
|
|
|
|
|
|
|
|
**returns:** string
|
|
|
|
|
2024-08-16 17:13:47 +08:00
|
|
|
### `isAptPackInstalled` (function)
|
|
|
|
|
|
|
|
Check if a package is installed
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
- pack (`string`) - The package to check
|
|
|
|
|
|
|
|
**returns:** Promise<boolean>
|
|
|
|
|
|
|
|
### `isAptPackRegexInstalled` (function)
|
|
|
|
|
|
|
|
Check if a package matching a regexp is installed
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
- regexp (`string`) - The regexp to check
|
|
|
|
|
|
|
|
**returns:** Promise<boolean>
|
|
|
|
|
2024-09-03 15:16:55 +08:00
|
|
|
### `updatedRepos` (variable)
|
|
|
|
|
2024-08-16 17:37:02 +08:00
|
|
|
### `updateAptRepos` (function)
|
2024-08-16 17:13:47 +08:00
|
|
|
|
|
|
|
Update the apt repositories
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
- apt (`string`) - The apt command to use (optional)
|
|
|
|
|
|
|
|
**returns:** void
|
|
|
|
|
2024-09-03 15:16:55 +08:00
|
|
|
### `updateAptReposMemoized` (variable)
|
2024-08-16 17:01:51 +08:00
|
|
|
|
2024-09-03 15:16:55 +08:00
|
|
|
Update the apt repositories (memoized)
|
2024-08-16 17:13:47 +08:00
|
|
|
|
2024-09-03 15:16:55 +08:00
|
|
|
**Parameters:**
|
2024-08-16 17:01:51 +08:00
|
|
|
|
2024-09-03 15:16:55 +08:00
|
|
|
- apt - The apt command to use (optional)
|
|
|
|
|
|
|
|
### `filterAndQualifyAptPackages` (function)
|
|
|
|
|
|
|
|
Filter out the packages that are already installed and qualify the packages into a full package name/version
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
- packages (`AptPackage[]`)
|
|
|
|
- apt (`string`)
|
|
|
|
|
|
|
|
**returns:** Promise<string[]>
|
|
|
|
|
|
|
|
### `qualifiedNeededAptPackage` (function)
|
|
|
|
|
|
|
|
Qualify the package into full package name/version.
|
|
|
|
If the package is not installed, return the full package name/version.
|
|
|
|
If the package is already installed, return undefined
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
- pack (`AptPackage`)
|
|
|
|
- apt (`string`)
|
|
|
|
|
|
|
|
**returns:** Promise<string>
|
|
|
|
|
|
|
|
### `initApt` (function)
|
|
|
|
|
|
|
|
Install gnupg and certificates (usually missing from docker containers)
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
- apt (`string`)
|
|
|
|
|
|
|
|
**returns:** Promise<void>
|
|
|
|
|
|
|
|
### `initAptMemoized` (variable)
|
|
|
|
|
|
|
|
Install gnupg and certificates (usually missing from docker containers) (memoized)
|
|
|
|
|
|
|
|
### `addAptRepository` (function)
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
- repo (`string`)
|
|
|
|
- apt (`string`)
|
|
|
|
|
|
|
|
**returns:** Promise<void>
|
|
|
|
|
|
|
|
### `installAddAptRepo` (function)
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
- apt (`string`)
|
|
|
|
|
|
|
|
**returns:** Promise<void>
|
|
|
|
|
|
|
|
### `InstallationInfo` (type)
|
|
|
|
|
|
|
|
The information about an installation result
|
2024-08-16 17:13:47 +08:00
|
|
|
|
2024-08-16 17:01:51 +08:00
|
|
|
### `AptPackage` (type)
|
|
|
|
|
2024-08-16 17:13:47 +08:00
|
|
|
The information about an apt package
|
|
|
|
|
2024-08-16 17:01:51 +08:00
|
|
|
### `installAptPack` (function)
|
|
|
|
|
2024-08-16 17:13:47 +08:00
|
|
|
Install a package using apt
|
2024-08-16 17:01:51 +08:00
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
2024-08-16 17:13:47 +08:00
|
|
|
- packages (`AptPackage[]`) - The packages to install (name, and optional info like version and repositories)
|
|
|
|
- update (`boolean`) - Whether to update the package list before installing (Defaults to `false`)
|
2024-08-16 17:01:51 +08:00
|
|
|
|
|
|
|
**returns:** Promise<InstallationInfo>
|
|
|
|
|
2024-08-29 05:12:56 +08:00
|
|
|
```ts
|
|
|
|
await installAptPack([{ name: "ca-certificates" }, { name: "gnupg" }])
|
|
|
|
```
|
|
|
|
|
|
|
|
```ts
|
|
|
|
await installAptPack([
|
|
|
|
{
|
|
|
|
name: "gcc",
|
|
|
|
version,
|
2024-08-29 05:23:40 +08:00
|
|
|
repository: "ppa:ubuntu-toolchain-r/test",
|
|
|
|
key: { key: "1E9377A2BA9EF27F", fileName: "ubuntu-toolchain-r-test.gpg" },
|
2024-08-29 05:12:56 +08:00
|
|
|
},
|
|
|
|
])
|
|
|
|
```
|
|
|
|
|
|
|
|
### `AddAptKeyOptions` (type)
|
|
|
|
|
|
|
|
### `addAptKey` (function)
|
|
|
|
|
|
|
|
Add an apt key
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
- options (`AddAptKeyOptions`) - The options for adding the key
|
|
|
|
|
|
|
|
**returns:** Promise<string>
|
|
|
|
|
|
|
|
```ts
|
2024-09-03 15:16:55 +08:00
|
|
|
await addAptKey({ key: "3B4FE6ACC0B21F32" fileName: "bazel-archive-keyring.gpg"})
|
2024-08-29 05:12:56 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
```ts
|
|
|
|
await addAptKey({
|
|
|
|
keyUrl: "https://bazel.build/bazel-release.pub.gpg",
|
|
|
|
fileName: "bazel-archive-keyring.gpg",
|
|
|
|
})
|
|
|
|
```
|
|
|
|
|
|
|
|
### `defaultKeyStorePath` (variable)
|
|
|
|
|
|
|
|
### `KeyServerOptions` (type)
|
|
|
|
|
|
|
|
### `defaultKeyServer` (variable)
|
|
|
|
|
2024-08-16 17:13:47 +08:00
|
|
|
### `addAptKeyViaServer` (function)
|
2024-08-16 17:01:51 +08:00
|
|
|
|
2024-08-16 17:13:47 +08:00
|
|
|
Add an apt key via a keyserver
|
2024-08-16 17:01:51 +08:00
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
2024-08-29 05:23:40 +08:00
|
|
|
- { key, keyServer = defaultKeyServer, fileName, keyStorePath = defaultKeyServer } (`KeyServerOptions`)
|
2024-08-16 17:01:51 +08:00
|
|
|
|
2024-08-16 17:13:47 +08:00
|
|
|
**returns:** Promise<string>
|
2024-08-16 17:01:51 +08:00
|
|
|
|
2024-08-29 05:12:56 +08:00
|
|
|
### `KeyUrl` (type)
|
|
|
|
|
2024-08-29 04:54:48 +08:00
|
|
|
### `addAptKeyViaURL` (function)
|
2024-08-16 17:13:47 +08:00
|
|
|
|
|
|
|
Add an apt key via a download
|
2024-08-16 17:01:51 +08:00
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
2024-08-29 05:12:56 +08:00
|
|
|
- options - The options for adding the key
|
|
|
|
- { keyUrl, fileName, keyStorePath = defaultKeyStorePath } (`KeyUrl`)
|
2024-08-16 17:01:51 +08:00
|
|
|
|
2024-08-16 17:13:47 +08:00
|
|
|
**returns:** Promise<string>
|
2024-08-16 17:01:51 +08:00
|
|
|
|
|
|
|
<!-- INSERT GENERATED DOCS END -->
|
|
|
|
|
|
|
|
## 🤝 Contributing
|
|
|
|
|
|
|
|
You can sponsor my work here:
|
|
|
|
|
|
|
|
https://github.com/sponsors/aminya
|
|
|
|
|
|
|
|
Pull requests, issues and feature requests are welcome.
|
|
|
|
See the [Contributing guide](https://github.com/aminya/setup-cpp/blob/master/CONTRIBUTING.md).
|