Skip to content

Commit 56a945c

Browse files
authored
Merge pull request #269 from aminya/apt
2 parents 12442d6 + c17f568 commit 56a945c

36 files changed

+779
-421
lines changed

cspell.config.yaml

+7-6
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,20 @@ ignorePaths:
1212
- .vscode/extensions.json
1313
words:
1414
- aarch
15-
- hadolint
1615
- aminya
17-
- envosman
1816
- applellvm
19-
- biome
20-
- biomejs
2117
- bazel
2218
- bazelisk
19+
- biome
20+
- biomejs
2321
- buildtools
2422
- caxa
2523
- ccache
2624
- choco
2725
- clangd
2826
- cmake
29-
- iarna
3027
- cobertura
3128
- copr
32-
- pnpx
3329
- CPATH
3430
- Cppcheck
3531
- CPPFLAGS
@@ -43,13 +39,16 @@ words:
4339
- DVCPKG
4440
- dyld
4541
- eabi
42+
- envosman
4643
- esmodule
4744
- execa
4845
- ftxui
4946
- GCOV
5047
- gcovr
5148
- ghes
5249
- Graphviz
50+
- hadolint
51+
- iarna
5352
- inja
5453
- isci
5554
- isroot
@@ -61,6 +60,7 @@ words:
6160
- libdw
6261
- libstdc
6362
- libtinfo
63+
- memoizee
6464
- msbuild
6565
- msvc
6666
- msvcrt
@@ -79,6 +79,7 @@ words:
7979
- patha
8080
- pipx
8181
- pnpm
82+
- pnpx
8283
- pwsh
8384
- pygments
8485
- pypy

dist/actions/setup-cpp.js

+34-34
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/actions/setup-cpp.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/legacy/setup-cpp.js

+34-34
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/legacy/setup-cpp.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/modern/setup-cpp.js

+34-34
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/modern/setup-cpp.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+8-7
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
"@types/eslint": "^8.56.11",
7474
"@types/iarna__toml": "~2.0.5",
7575
"@types/jest": "^29.5.12",
76+
"@types/memoizee": "^0.4.11",
7677
"@types/node": "^12.20.55",
7778
"@types/semver": "^7.5.8",
7879
"@types/which": "^3.0.4",
@@ -86,10 +87,10 @@
8687
"cspell": "^8.13.3",
8788
"diagnostics_channel": "^1.1.0",
8889
"dprint": "^0.47.2",
90+
"envosman": "workspace:*",
8991
"escape-path-with-spaces": "^1.0.2",
9092
"escape-quotes": "^1.0.2",
9193
"escape-string-regexp": "^5.0.0",
92-
"setup-apt": "workspace:*",
9394
"eslint": "^8.57.0",
9495
"eslint-config-atomic": "^1.22.1",
9596
"exec-powershell": "workspace:*",
@@ -98,14 +99,14 @@
9899
"jest": "^29.7.0",
99100
"lefthook": "^1.7.12",
100101
"macos-release": "^3.3.0",
101-
"micro-memoize": "^4.1.2",
102+
"memoizee": "^0.4.17",
102103
"mkdirp": "^3.0.1",
103104
"mri": "^1.2.0",
104105
"msvc-dev-cmd": "github:aminya/msvc-dev-cmd#c01f519bd995460228ed3dec4df51df92dc290fd",
106+
"node-downloader-helper": "2.1.9",
105107
"npm-check-updates": "^17.0.6",
106108
"npm-run-all2": "^6.2.2",
107109
"numerous": "1.0.3",
108-
"envosman": "workspace:*",
109110
"p-timeout": "^6.1.2",
110111
"parcel": "2.0.0-canary.1717",
111112
"path-exists": "^5.0.0",
@@ -115,8 +116,9 @@
115116
"readme-md-generator": "^1.0.0",
116117
"retry-as-promised": "^7.0.4",
117118
"semver": "7.6.3",
118-
"setup-python": "github:aminya/setup-python#a783db655c6e40317e2c0c96f9d162d9c9f4a751",
119+
"setup-apt": "workspace:*",
119120
"setup-brew": "workspace:*",
121+
"setup-python": "github:aminya/setup-python#a783db655c6e40317e2c0c96f9d162d9c9f4a751",
120122
"shx": "0.3.4",
121123
"simple-update-notifier": "^2.0.0",
122124
"terser-config-atomic": "^1.0.0",
@@ -129,8 +131,7 @@
129131
"untildify-user": "workspace:*",
130132
"util.types": "^0.0.2",
131133
"web-streams-polyfill": "^4.0.0",
132-
"which": "^4.0.0",
133-
"node-downloader-helper": "2.1.9"
134+
"which": "^4.0.0"
134135
},
135136
"productionDependencies": [
136137
"@actions/core",
@@ -149,7 +150,7 @@
149150
"exec-powershell",
150151
"execa",
151152
"is-url-online",
152-
"micro-memoize",
153+
"memoizee",
153154
"mri",
154155
"msvc-dev-cmd",
155156
"node-downloader-helper",

packages/envosman/package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"ci-info": "^4.0.0",
2424
"escape-path-with-spaces": "^1.0.2",
2525
"escape-quotes": "^1.0.2",
26-
"micro-memoize": "^4.1.2",
26+
"memoizee": "^0.4.17",
2727
"path-exists": "^5.0.0",
2828
"ci-log": "workspace:*",
2929
"exec-powershell": "workspace:*",
@@ -45,5 +45,7 @@
4545
"unix",
4646
"macos"
4747
],
48-
"devDependencies": {}
48+
"devDependencies": {
49+
"@types/memoizee": "0.4.11"
50+
}
4951
}

packages/envosman/src/rc-file.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { promises } from "fs"
22
import { grantUserWriteAccess } from "admina"
33
import { info, warning } from "ci-log"
4-
import memoize from "micro-memoize"
4+
import memoize from "memoizee"
55
import { pathExists } from "path-exists"
66
import { untildifyUser } from "untildify-user"
77
const { appendFile, readFile, writeFile } = promises
@@ -38,7 +38,7 @@ async function sourceRCInRc_(options: RcOptions) {
3838
/**
3939
* handles adding conditions to source rc file from .bashrc and .profile
4040
*/
41-
export const sourceRCInRc = memoize(sourceRCInRc_, { isPromise: true })
41+
export const sourceRCInRc = memoize(sourceRCInRc_, { promise: true })
4242

4343
async function addRCHeader(options: RcOptions) {
4444
// a variable that prevents source rc from being called from .bashrc and .profile

packages/setup-apt/README.md

+53-6
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,21 @@ Install a package using apt
100100

101101
**returns:** Promise<InstallationInfo>
102102

103+
```ts
104+
await installAptPack([{ name: "ca-certificates" }, { name: "gnupg" }])
105+
```
106+
107+
```ts
108+
await installAptPack([
109+
{
110+
name: "gcc",
111+
version,
112+
repository: "ppa:ubuntu-toolchain-r/test",
113+
key: { key: "1E9377A2BA9EF27F", fileName: "ubuntu-toolchain-r-test.gpg" },
114+
},
115+
])
116+
```
117+
103118
### `hasNala` (function)
104119

105120
Check if nala is installed
@@ -123,26 +138,58 @@ Get the environment variables to use for the apt command
123138

124139
**returns:** ProcessEnv
125140

141+
### `AddAptKeyOptions` (type)
142+
143+
### `addAptKey` (function)
144+
145+
Add an apt key
146+
147+
**Parameters:**
148+
149+
- options (`AddAptKeyOptions`) - The options for adding the key
150+
151+
**returns:** Promise<string>
152+
153+
```ts
154+
await addAptKey({
155+
key: "3B4FE6ACC0B21F32"
156+
fileName: "bazel-archive-keyring.gpg",
157+
})
158+
```
159+
160+
```ts
161+
await addAptKey({
162+
keyUrl: "https://bazel.build/bazel-release.pub.gpg",
163+
fileName: "bazel-archive-keyring.gpg",
164+
})
165+
```
166+
167+
### `defaultKeyStorePath` (variable)
168+
169+
### `KeyServerOptions` (type)
170+
171+
### `defaultKeyServer` (variable)
172+
126173
### `addAptKeyViaServer` (function)
127174

128175
Add an apt key via a keyserver
129176

130177
**Parameters:**
131178

132-
- keys (`string[]`) - The keys to add
133-
- name (`string`) - The name of the key
134-
- server (`string`) - The keyserver to use (Defaults to `keyserver.ubuntu.com`)
179+
- { key, keyServer = defaultKeyServer, fileName, keyStorePath = defaultKeyServer } (`KeyServerOptions`)
135180

136181
**returns:** Promise<string>
137182

138-
### `addAptKeyViaDownload` (function)
183+
### `KeyUrl` (type)
184+
185+
### `addAptKeyViaURL` (function)
139186

140187
Add an apt key via a download
141188

142189
**Parameters:**
143190

144-
- name (`string`) - The name of the key
145-
- url (`string`) - The URL of the key
191+
- options - The options for adding the key
192+
- { keyUrl, fileName, keyStorePath = defaultKeyStorePath } (`KeyUrl`)
146193

147194
**returns:** Promise<string>
148195

packages/setup-apt/package.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "setup-apt",
3-
"version": "1.0.1",
3+
"version": "2.0.0",
44
"description": "Setup apt packages and repositories in Debian/Ubuntu-based distributions",
55
"repository": "https://github.com/aminya/setup-cpp",
66
"homepage": "https://github.com/aminya/setup-cpp/tree/master/packages/setup-apt",
@@ -26,7 +26,8 @@
2626
"which": "4.0.0",
2727
"execa": "^7.2.0",
2828
"escape-string-regexp": "^5.0.0",
29-
"node-downloader-helper": "2.1.9"
29+
"node-downloader-helper": "2.1.9",
30+
"memoizee": "^0.4.17"
3031
},
3132
"engines": {
3233
"node": ">=12"
@@ -48,5 +49,7 @@
4849
"package",
4950
"apt-key"
5051
],
51-
"devDependencies": {}
52+
"devDependencies": {
53+
"@types/memoizee": "0.4.11"
54+
}
5255
}

packages/setup-apt/src/apt-env.ts

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* Get the environment variables to use for the apt command
3+
* @param apt The apt command to use
4+
* @private Used internally
5+
*/
6+
7+
export function getAptEnv(apt: string) {
8+
const env: NodeJS.ProcessEnv = { ...process.env, DEBIAN_FRONTEND: "noninteractive" }
9+
10+
if (apt === "nala") {
11+
// if LANG/LC_ALL is not set, enable utf8 otherwise nala fails because of ASCII encoding
12+
if (env.LANG === undefined) {
13+
env.LANG = "C.UTF-8"
14+
}
15+
if (env.LC_ALL === undefined) {
16+
env.LC_ALL = "C.UTF-8"
17+
}
18+
}
19+
20+
return env
21+
}

0 commit comments

Comments
 (0)