@@ -5,7 +5,7 @@ import { type ExecaError, execa } from "execa"
5
5
import which from "which"
6
6
import { addAptKeyViaServer } from "./apt-key.js"
7
7
import { isAptPackInstalled } from "./is-installed.js"
8
- import { updateRepos } from "./update.js"
8
+ import { updateAptRepos } from "./update.js"
9
9
10
10
/**
11
11
* The information about an installation result
@@ -63,7 +63,7 @@ export async function installAptPack(packages: AptPackage[], update = false): Pr
63
63
64
64
// Update the repos if needed
65
65
if ( update ) {
66
- updateRepos ( apt )
66
+ updateAptRepos ( apt )
67
67
didUpdate = true
68
68
}
69
69
@@ -85,15 +85,18 @@ export async function installAptPack(packages: AptPackage[], update = false): Pr
85
85
86
86
// Install
87
87
try {
88
- execRootSync ( apt , [ "install" , "--fix-broken" , "-y" , ...needToInstall ] , { ...defaultExecOptions , env : getEnv ( apt ) } )
88
+ execRootSync ( apt , [ "install" , "--fix-broken" , "-y" , ...needToInstall ] , {
89
+ ...defaultExecOptions ,
90
+ env : getAptEnv ( apt ) ,
91
+ } )
89
92
} catch ( err ) {
90
93
if ( isExecaError ( err ) ) {
91
94
if ( retryErrors . some ( ( error ) => err . stderr . includes ( error ) ) ) {
92
95
warning ( `Failed to install packages ${ needToInstall } . Retrying...` )
93
96
execRootSync (
94
97
apt ,
95
98
[ "install" , "--fix-broken" , "-y" , "-o" , aptTimeout , ...needToInstall ] ,
96
- { ...defaultExecOptions , env : getEnv ( apt ) } ,
99
+ { ...defaultExecOptions , env : getAptEnv ( apt ) } ,
97
100
)
98
101
}
99
102
} else {
@@ -134,7 +137,7 @@ export function getApt() {
134
137
* @param apt The apt command to use
135
138
* @private Used internally
136
139
*/
137
- export function getEnv ( apt : string ) {
140
+ export function getAptEnv ( apt : string ) {
138
141
const env : NodeJS . ProcessEnv = { ...process . env , DEBIAN_FRONTEND : "noninteractive" }
139
142
140
143
if ( apt === "nala" ) {
@@ -185,9 +188,9 @@ async function addRepositories(apt: string, packages: AptPackage[]) {
185
188
await installAddAptRepo ( apt )
186
189
for ( const repo of allRepositories ) {
187
190
// eslint-disable-next-line no-await-in-loop
188
- execRootSync ( "add-apt-repository" , [ "-y" , "--no-update" , repo ] , { ...defaultExecOptions , env : getEnv ( apt ) } )
191
+ execRootSync ( "add-apt-repository" , [ "-y" , "--no-update" , repo ] , { ...defaultExecOptions , env : getAptEnv ( apt ) } )
189
192
}
190
- updateRepos ( apt )
193
+ updateAptRepos ( apt )
191
194
didUpdate = true
192
195
}
193
196
}
@@ -198,15 +201,15 @@ async function aptPackageType(apt: string, name: string, version: string | undef
198
201
"search" ,
199
202
"--names-only" ,
200
203
`^${ escapeRegex ( name ) } -${ escapeRegex ( version ) } $` ,
201
- ] , { env : getEnv ( apt ) , stdio : "pipe" } )
204
+ ] , { env : getAptEnv ( apt ) , stdio : "pipe" } )
202
205
if ( stdout . trim ( ) !== "" ) {
203
206
return AptPackageType . NameDashVersion
204
207
}
205
208
206
209
try {
207
210
// check if apt-get show can find the version
208
211
// eslint-disable-next-line @typescript-eslint/no-shadow
209
- const { stdout } = await execa ( "apt-cache" , [ "show" , `${ name } =${ version } ` ] , { env : getEnv ( apt ) } )
212
+ const { stdout } = await execa ( "apt-cache" , [ "show" , `${ name } =${ version } ` ] , { env : getAptEnv ( apt ) } )
210
213
if ( stdout . trim ( ) === "" ) {
211
214
return AptPackageType . NameEqualsVersion
212
215
}
@@ -216,7 +219,7 @@ async function aptPackageType(apt: string, name: string, version: string | undef
216
219
}
217
220
218
221
try {
219
- const { stdout : showStdout } = await execa ( "apt-cache" , [ "show" , name ] , { env : getEnv ( apt ) , stdio : "pipe" } )
222
+ const { stdout : showStdout } = await execa ( "apt-cache" , [ "show" , name ] , { env : getAptEnv ( apt ) , stdio : "pipe" } )
220
223
if ( showStdout . trim ( ) !== "" ) {
221
224
return AptPackageType . Name
222
225
}
@@ -226,7 +229,7 @@ async function aptPackageType(apt: string, name: string, version: string | undef
226
229
227
230
// If apt-cache fails, update the repos and try again
228
231
if ( ! didUpdate ) {
229
- updateRepos ( getApt ( ) )
232
+ updateAptRepos ( getApt ( ) )
230
233
didUpdate = true
231
234
return aptPackageType ( apt , name , version )
232
235
}
@@ -258,15 +261,15 @@ async function installAddAptRepo(apt: string) {
258
261
execRootSync (
259
262
apt ,
260
263
[ "install" , "-y" , "--fix-broken" , "-o" , aptTimeout , "software-properties-common" ] ,
261
- { ...defaultExecOptions , env : getEnv ( apt ) } ,
264
+ { ...defaultExecOptions , env : getAptEnv ( apt ) } ,
262
265
)
263
266
}
264
267
265
268
/** Install gnupg and certificates (usually missing from docker containers) */
266
269
async function initApt ( apt : string ) {
267
270
// Update the repos if needed
268
271
if ( ! didUpdate ) {
269
- updateRepos ( apt )
272
+ updateAptRepos ( apt )
270
273
didUpdate = true
271
274
}
272
275
@@ -279,7 +282,7 @@ async function initApt(apt: string) {
279
282
if ( toInstall . length !== 0 ) {
280
283
execRootSync ( apt , [ "install" , "-y" , "--fix-broken" , "-o" , aptTimeout , ...toInstall ] , {
281
284
...defaultExecOptions ,
282
- env : getEnv ( apt ) ,
285
+ env : getAptEnv ( apt ) ,
283
286
} )
284
287
}
285
288
0 commit comments