@@ -20,38 +20,17 @@ export function setupAptPack(
20
20
) : InstallationInfo {
21
21
info ( `Installing ${ name } ${ version ?? "" } via apt` )
22
22
23
- let apt : string
24
- if ( which . sync ( "nala" , { nothrow : true } ) !== null ) {
25
- apt = "nala"
26
- } else {
27
- apt = "apt-get"
28
- }
23
+ let apt : string = getApt ( )
29
24
30
25
process . env . DEBIAN_FRONTEND = "noninteractive"
31
26
32
27
if ( ! didUpdate || update ) {
33
- execSudo ( apt , [ "update" , "-y" ] )
28
+ updateRepos ( apt )
34
29
didUpdate = true
35
30
}
36
31
37
32
if ( ! didInit ) {
38
- // install apt utils and certificates (usually missing from docker containers)
39
- execSudo ( apt , [
40
- "install" ,
41
- "--fix-broken" ,
42
- "-y" ,
43
- "software-properties-common" ,
44
- "apt-utils" ,
45
- "ca-certificates" ,
46
- "gnupg" ,
47
- ] )
48
- try {
49
- execSudo ( "apt-key" , [ "adv" , "--keyserver" , "keyserver.ubuntu.com" , "--recv-keys" , "3B4FE6ACC0B21F32" ] )
50
- execSudo ( "apt-key" , [ "adv" , "--keyserver" , "keyserver.ubuntu.com" , "--recv-keys" , "40976EAF437D05B5" ] )
51
- execSudo ( "apt-key" , [ "adv" , "--keyserver" , "keyserver.ubuntu.com" , "--recv-keys" , "1E9377A2BA9EF27F" ] )
52
- } catch ( err ) {
53
- warning ( `Failed to add keys: ${ err } ` )
54
- }
33
+ initApt ( apt )
55
34
didInit = true
56
35
}
57
36
@@ -60,7 +39,7 @@ export function setupAptPack(
60
39
// eslint-disable-next-line no-await-in-loop
61
40
execSudo ( "add-apt-repository" , [ "--update" , "-y" , repo ] )
62
41
}
63
- execSudo ( apt , [ "update" , "-y" ] )
42
+ updateRepos ( apt )
64
43
}
65
44
66
45
if ( version !== undefined && version !== "" ) {
@@ -76,6 +55,40 @@ export function setupAptPack(
76
55
return { binDir : "/usr/bin/" }
77
56
}
78
57
58
+ function getApt ( ) {
59
+ let apt : string
60
+ if ( which . sync ( "nala" , { nothrow : true } ) !== null ) {
61
+ apt = "nala"
62
+ } else {
63
+ apt = "apt-get"
64
+ }
65
+ return apt
66
+ }
67
+
68
+ function updateRepos ( apt : string ) {
69
+ execSudo ( apt , apt !== "nala" ? [ "update" , "-y" ] : [ "update" ] )
70
+ }
71
+
72
+ /** Install apt utils and certificates (usually missing from docker containers) */
73
+ function initApt ( apt : string ) {
74
+ execSudo ( apt , [
75
+ "install" ,
76
+ "--fix-broken" ,
77
+ "-y" ,
78
+ "software-properties-common" ,
79
+ "apt-utils" ,
80
+ "ca-certificates" ,
81
+ "gnupg" ,
82
+ ] )
83
+ try {
84
+ execSudo ( "apt-key" , [ "adv" , "--keyserver" , "keyserver.ubuntu.com" , "--recv-keys" , "3B4FE6ACC0B21F32" ] )
85
+ execSudo ( "apt-key" , [ "adv" , "--keyserver" , "keyserver.ubuntu.com" , "--recv-keys" , "40976EAF437D05B5" ] )
86
+ execSudo ( "apt-key" , [ "adv" , "--keyserver" , "keyserver.ubuntu.com" , "--recv-keys" , "1E9377A2BA9EF27F" ] )
87
+ } catch ( err ) {
88
+ warning ( `Failed to add keys: ${ err } ` )
89
+ }
90
+ }
91
+
79
92
export function updateAptAlternatives ( name : string , path : string ) {
80
93
if ( isGitHubCI ( ) ) {
81
94
return execSudo ( "update-alternatives" , [ "--install" , `/usr/bin/${ name } ` , name , path , "40" ] )
0 commit comments