Skip to content

Commit a7b345b

Browse files
committed
Fix #2053 ArchLinux setup dependencies always fail
1 parent 77572d1 commit a7b345b

File tree

1 file changed

+60
-20
lines changed

1 file changed

+60
-20
lines changed

setup.ps1

Lines changed: 60 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
# refer https://gist.github.com/ryanmaclean/a1f3135f49c1ab3fa7ec958ac3f8babe #\
66
param( [string]$gradlewVersion, #\
77
[switch]$setupCMake #\
8-
) <#\
8+
) <#\
99
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `
1010
#vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
1111
# Bash Start ------------------------------------------------------------
1212
scriptdir="`dirname "${BASH_SOURCE[0]}"`"
13-
if ! which pwsh > /dev/null; then
13+
if ! command -v pwsh > /dev/null; then
1414
$scriptdir/1k/install-pwsh.sh
1515
fi
1616
pwsh $scriptdir/setup.ps1 "$@"
@@ -175,7 +175,8 @@ if ($IsWin) {
175175
if ($execPolicy -ne 'Bypass') {
176176
println "Setting system installed powershell execution policy '$execPolicy'==>'Bypass', please click 'YES' on UAC dialog"
177177
Start-Process powershell -ArgumentList '-Command "Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Bypass -Force"' -WindowStyle Hidden -Wait -Verb runas
178-
} else {
178+
}
179+
else {
179180
println "Nice, the system installed powershell execution policy is '$execPolicy'"
180181
}
181182
}
@@ -205,7 +206,7 @@ else {
205206
206207
if (!($axmolCmdInfo = (Get-Command axmol -ErrorAction SilentlyContinue)) -or $axmolCmdInfo.Source -ne "$AX_CLI_ROOT/axmol") {
207208
$stmt_export = '$env:PATH = "${env:AX_ROOT}/tools/cmdline:${env:PATH}"'
208-
if(!$profileContent.Contains($stmt_export)) {
209+
if (!$profileContent.Contains($stmt_export)) {
209210
$profileContent += "# Add axmol cmdline tool to PATH`n"
210211
$profileContent += '$env:PATH = "${env:AX_ROOT}/tools/cmdline:${env:PATH}"'
211212
$profileContent += "`n"
@@ -268,10 +269,20 @@ else {
268269
269270
270271
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
272283
$answer = Read-Host
273284
if ($answer -like 'y*') {
274-
if ($(Get-Command 'dpkg' -ErrorAction SilentlyContinue)) {
285+
if ($LinuxDistro -eq 'Debian') {
275286
println "It will take few minutes"
276287
sudo apt update
277288
# for vm, libxxf86vm-dev also required
@@ -300,7 +311,21 @@ if ($IsLinux) {
300311
301312
sudo apt install --allow-unauthenticated --yes $DEPENDS > /dev/null
302313
}
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+
304329
$DEPENDS = @(
305330
'git',
306331
'cmake',
@@ -312,7 +337,7 @@ if ($IsLinux) {
312337
'libxi',
313338
'fontconfig',
314339
'gtk3',
315-
'webkit2gtk4.0',
340+
'webkit2gtk',
316341
'vlc'
317342
)
318343
sudo pacman -S --needed --noconfirm @DEPENDS
@@ -341,9 +366,10 @@ if ($gradlewVersion) {
341366
$aproj_source_gradle = Join-Path $aproj_source_root 'build.gradle'
342367
$aproj_source_gradle_wrapper = Join-Path $aproj_source_root 'gradle/wrapper/'
343368
$vernums = $gradlewVersion.Split('.')
344-
if($vernums.Count -lt 3) {
369+
if ($vernums.Count -lt 3) {
345370
$gradle_tag = "v$gradlewVersion.0"
346-
} else {
371+
}
372+
else {
347373
$gradle_tag = "v$gradlewVersion"
348374
}
349375
@@ -373,18 +399,32 @@ if ($gradlewVersion) {
373399
}
374400
375401
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
386410
}
387411
}
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+
}
388428
}
389429
390430
$1k.pause("setup successfully, please restart the terminal to make added system variables take effect")

0 commit comments

Comments
 (0)