@@ -37,7 +37,6 @@ import actions.exec.ExecOptions
37
37
import actions.exec.exec
38
38
import actions.io.mkdirP
39
39
import actions.io.mv
40
- import actions.io.rmRF
41
40
import actions.io.which
42
41
import actions.tool.cache.cacheDir
43
42
import actions.tool.cache.downloadTool
@@ -58,7 +57,6 @@ import node.buffer.BufferEncoding
58
57
import node.fs.exists
59
58
import node.fs.mkdtemp
60
59
import node.fs.readdir
61
- import node.fs.stat
62
60
import node.fs.writeFile
63
61
import node.os.tmpdir
64
62
import node.path.path
@@ -71,12 +69,6 @@ import kotlin.time.Duration.Companion.minutes
71
69
import kotlin.time.Duration.Companion.seconds
72
70
import actions.tool.cache.extractZip as toolCacheExtractZip
73
71
74
- private const val BAD_WSL_EXE_PATH =
75
- " C:\\ Users\\ runneradmin\\ AppData\\ Local\\ Microsoft\\ WindowsApps\\ wsl.exe"
76
-
77
- private const val BAD_WSLCONFIG_EXE_PATH =
78
- " C:\\ Users\\ runneradmin\\ AppData\\ Local\\ Microsoft\\ WindowsApps\\ wslconfig.exe"
79
-
80
72
suspend fun wslOutput (vararg args : String ): String {
81
73
val stdoutBuilder = StringBuilder ()
82
74
val stdoutBuilderUtf16Le = StringBuilder ()
@@ -387,31 +379,12 @@ suspend fun verifyWindowsEnvironment() {
387
379
}
388
380
389
381
suspend fun installWsl () {
390
- // part of work-around for https://github.com/actions/toolkit/issues/1925
391
- val deleteWslExe =
392
- runCatching { stat(BAD_WSL_EXE_PATH ).isFile() }
393
- .getOrDefault(false )
394
- .not ()
395
- val deleteWslConfigExe =
396
- runCatching { stat(BAD_WSLCONFIG_EXE_PATH ).isFile() }
397
- .getOrDefault(false )
398
- .not ()
399
-
400
382
exec(
401
383
commandLine = " pwsh" ,
402
384
args = arrayOf(" -Command" , """ Start-Process wsl "--install --no-distribution"""" ),
403
385
options = ExecOptions (ignoreReturnCode = true )
404
386
)
405
-
406
- waitForWslStatusNotContaining(" is not installed" , 5 .minutes) {
407
- // part of work-around for https://github.com/actions/toolkit/issues/1925
408
- if (deleteWslExe) {
409
- rmRF(BAD_WSL_EXE_PATH )
410
- }
411
- if (deleteWslConfigExe) {
412
- rmRF(BAD_WSLCONFIG_EXE_PATH )
413
- }
414
- }
387
+ waitForWslStatusNotContaining(" is not installed" , 5 .minutes)
415
388
}
416
389
417
390
suspend fun installDistribution () {
@@ -420,31 +393,12 @@ suspend fun installDistribution() {
420
393
)
421
394
422
395
if (wslVersion() != 1u ) {
423
- // part of work-around for https://github.com/actions/toolkit/issues/1925
424
- val deleteWslExe =
425
- runCatching { stat(BAD_WSL_EXE_PATH ).isFile() }
426
- .getOrDefault(false )
427
- .not ()
428
- val deleteWslConfigExe =
429
- runCatching { stat(BAD_WSLCONFIG_EXE_PATH ).isFile() }
430
- .getOrDefault(false )
431
- .not ()
432
-
433
396
retry(10 ) {
434
397
executeWslCommand(
435
398
wslArguments = arrayOf(" --update" )
436
399
)
437
400
}
438
-
439
- // part of work-around for https://github.com/actions/toolkit/issues/1925
440
- waitForWslStatusNotContaining(" WSL is finishing an upgrade..." ) {
441
- if (deleteWslExe) {
442
- rmRF(BAD_WSL_EXE_PATH )
443
- }
444
- if (deleteWslConfigExe) {
445
- rmRF(BAD_WSLCONFIG_EXE_PATH )
446
- }
447
- }
401
+ waitForWslStatusNotContaining(" WSL is finishing an upgrade..." )
448
402
}
449
403
450
404
exec(
@@ -456,17 +410,13 @@ suspend fun installDistribution() {
456
410
457
411
suspend fun waitForWslStatusNotContaining (
458
412
text : String ,
459
- duration : Duration = 30.seconds,
460
- preAction : suspend () -> Unit = {}
413
+ duration : Duration = 30.seconds
461
414
) {
462
415
(2 .. duration.inWholeSeconds)
463
416
.asFlow()
464
417
.onEach { delay(1 .seconds) }
465
418
.onStart { emit(1 ) }
466
- .map {
467
- preAction()
468
- wslOutput(" --status" )
469
- }
419
+ .map { wslOutput(" --status" ) }
470
420
.firstOrNull { ! it.contains(text) }
471
421
}
472
422
0 commit comments