5
5
# refer https://gist.github.com/ryanmaclean/a1f3135f49c1ab3fa7ec958ac3f8babe #\
6
6
param( [string]$gradlewVersion, #\
7
7
[switch]$setupCMake #\
8
- ) <#\
8
+ ) <#\
9
9
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `
10
10
# vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
11
11
# Bash Start ------------------------------------------------------------
12
12
scriptdir=" ` dirname " ${BASH_SOURCE[0]} " ` "
13
- if ! which pwsh > /dev/null; then
13
+ if ! command -v pwsh > /dev/null; then
14
14
$scriptdir /1k/install-pwsh.sh
15
15
fi
16
16
pwsh $scriptdir /setup.ps1 " $@ "
@@ -175,7 +175,8 @@ if ($IsWin) {
175
175
if ($execPolicy -ne 'Bypass') {
176
176
println "Setting system installed powershell execution policy '$execPolicy'==>'Bypass', please click 'YES' on UAC dialog"
177
177
Start-Process powershell -ArgumentList '-Command "Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Bypass -Force"' -WindowStyle Hidden -Wait -Verb runas
178
- } else {
178
+ }
179
+ else {
179
180
println "Nice, the system installed powershell execution policy is '$execPolicy'"
180
181
}
181
182
}
@@ -205,7 +206,7 @@ else {
205
206
206
207
if (!($axmolCmdInfo = (Get-Command axmol -ErrorAction SilentlyContinue)) -or $axmolCmdInfo.Source -ne "$AX_CLI_ROOT/axmol") {
207
208
$stmt_export = '$env:PATH = "${env:AX_ROOT}/tools/cmdline:${env:PATH}"'
208
- if(!$profileContent.Contains($stmt_export)) {
209
+ if (!$profileContent.Contains($stmt_export)) {
209
210
$profileContent += "# Add axmol cmdline tool to PATH`n"
210
211
$profileContent += '$env:PATH = "${env:AX_ROOT}/tools/cmdline:${env:PATH}"'
211
212
$profileContent += "`n"
@@ -268,10 +269,20 @@ else {
268
269
269
270
270
271
if ($IsLinux) {
271
- Write-Host "Are you continue install linux dependencies for axmol? (y/n) " -NoNewline
272
+ if ($(Get-Command 'dpkg' -ErrorAction SilentlyContinue)) {
273
+ $LinuxDistro = 'Debian'
274
+ }
275
+ elseif ($(Get-Command 'pacman' -ErrorAction SilentlyContinue)) {
276
+ $LinuxDistro = 'Arch'
277
+ }
278
+ else {
279
+ $LinuxDistro = 'Linux'
280
+ }
281
+
282
+ Write-Host "Are you continue install linux dependencies for axmol? (y/N) " -NoNewline
272
283
$answer = Read-Host
273
284
if ($answer -like 'y*') {
274
- if ($(Get-Command 'dpkg' -ErrorAction SilentlyContinue) ) {
285
+ if ($LinuxDistro -eq 'Debian' ) {
275
286
println "It will take few minutes"
276
287
sudo apt update
277
288
# for vm, libxxf86vm-dev also required
@@ -300,7 +311,21 @@ if ($IsLinux) {
300
311
301
312
sudo apt install --allow-unauthenticated --yes $DEPENDS > /dev/null
302
313
}
303
- elseif ($(Get-Command 'pacman' -ErrorAction SilentlyContinue)) {
314
+ elseif ($LinuxDistro -eq 'Arch') {
315
+ $mirror_list = [System.IO.File]::ReadAllText('/etc/pacman.d/mirrorlist')
316
+ $tsinghua_mirror = 'https://mirrors.tuna.tsinghua.edu.cn/archlinux/$repo/os/$arch'
317
+ if (!$mirror_list.Contains($tsinghua_mirror)) {
318
+ Write-Host "Are want add tsinghua mirror for speed up package install in china region? (y/N)" -NoNewline
319
+ $answer = Read-Host
320
+ if ($answer -like 'y*') {
321
+ $mirror_list = "$tsinghua_mirror`n$mirror_list"
322
+ $mirror_list_tmp_file = (Join-Path $AX_ROOT 'mirrorlist')
323
+ [System.IO.File]::WriteAllText($mirror_list_tmp_file, $mirror_list)
324
+ sudo mv -f $mirror_list_tmp_file /etc/pacman.d/mirrorlist
325
+ sudo pacman -Syyu --noconfirm
326
+ }
327
+ }
328
+
304
329
$DEPENDS = @(
305
330
'git',
306
331
'cmake',
@@ -312,7 +337,7 @@ if ($IsLinux) {
312
337
'libxi',
313
338
'fontconfig',
314
339
'gtk3',
315
- 'webkit2gtk4.0 ',
340
+ 'webkit2gtk ',
316
341
'vlc'
317
342
)
318
343
sudo pacman -S --needed --noconfirm @DEPENDS
@@ -341,9 +366,10 @@ if ($gradlewVersion) {
341
366
$aproj_source_gradle = Join-Path $aproj_source_root 'build.gradle'
342
367
$aproj_source_gradle_wrapper = Join-Path $aproj_source_root 'gradle/wrapper/'
343
368
$vernums = $gradlewVersion.Split('.')
344
- if($vernums.Count -lt 3) {
369
+ if ($vernums.Count -lt 3) {
345
370
$gradle_tag = "v$gradlewVersion.0"
346
- } else {
371
+ }
372
+ else {
347
373
$gradle_tag = "v$gradlewVersion"
348
374
}
349
375
@@ -373,18 +399,32 @@ if ($gradlewVersion) {
373
399
}
374
400
375
401
if ($IsLinux -and (Test-Path '/etc/wsl.conf' -PathType Leaf)) {
376
- Write-Host "Are want remove host windows path from wsl? (y/n) " -NoNewline
377
- $answer = Read-Host
378
- if ($answer -like 'y*') {
379
- $wsl_conf = [System.IO.File]::ReadAllText('/etc/wsl.conf')
380
- if (!$wsl_conf.Contains('appendWindowsPath')) {
381
- $wsl_conf += "`n[interop]`nappendWindowsPath = false"
382
- $wsl_conf_tmp_file = (Join-Path $AX_ROOT 'wsl.conf')
383
- [System.IO.File]::WriteAllText($wsl_conf_tmp_file, $wsl_conf)
384
- sudo mv -f $wsl_conf_tmp_file /etc/wsl.conf
385
- println "Update /etc/wsl.conf success, please run 'wsl --shutdown' on your host windows, then re-enter wsl"
402
+ $wsl_conf = [System.IO.File]::ReadAllText('/etc/wsl.conf')
403
+ $wsl_mods = 0
404
+ if (!$wsl_conf.Contains('appendWindowsPath')) {
405
+ Write-Host "Are want remove host windows path from WSL? (Y/n)" -NoNewline
406
+ $answer = Read-Host
407
+ if ($answer -notlike 'n*') {
408
+ $wsl_conf += "`n[interop]`nappendWindowsPath=false"
409
+ ++$wsl_mods
386
410
}
387
411
}
412
+ if ($LinuxDistro -eq 'Arch') {
413
+ if ($wsl_conf -match 'systemd.*=.*true') {
414
+ Write-Host "Are want disable systemd to solve Arch WSL graphics issue? (Y/n) " -NoNewline
415
+ $answer = Read-Host
416
+ if ($answer -notlike 'n*') {
417
+ $wsl_conf = $wsl_conf -replace 'systemd.*=.*true', 'systemd=false'
418
+ ++$wsl_mods
419
+ }
420
+ }
421
+ }
422
+ if ($wsl_mods) {
423
+ $wsl_conf_tmp_file = (Join-Path $AX_ROOT 'wsl.conf')
424
+ [System.IO.File]::WriteAllText($wsl_conf_tmp_file, $wsl_conf)
425
+ sudo mv -f $wsl_conf_tmp_file /etc/wsl.conf
426
+ println "Update /etc/wsl.conf success, please run 'wsl --shutdown' on your host windows, then re-enter wsl"
427
+ }
388
428
}
389
429
390
430
$1k.pause("setup successfully, please restart the terminal to make added system variables take effect")
0 commit comments